Skip to content

fix(agent): gate spoken narration on the rollout feature flag#3503

Closed
jonmcwest wants to merge 1 commit into
posthog-code/gate-speak-tool-strict-optinfrom
posthog-code/spoken-narration-flag-gate
Closed

fix(agent): gate spoken narration on the rollout feature flag#3503
jonmcwest wants to merge 1 commit into
posthog-code/gate-speak-tool-strict-optinfrom
posthog-code/spoken-narration-flag-gate

Conversation

@jonmcwest

Copy link
Copy Markdown
Contributor

Problem

Follow-up to #3500, stacked on its branch (do not merge before it).

#3500 makes narration strictly opt-in and gates the desktop on the user setting + ElevenLabs key — but the posthog-code-spoken-narration rollout flag still isn't checked anywhere outside the settings UI. #3500's comments describe the gate as "feature flag + setting + key"; the flag part wasn't actually wired. Anyone who toggled the setting on while the flag was enabled (and has a key) keeps narration forever after the flag is turned off, with no UI left to disable it, and desktop playback ignores the flag entirely.

Per the ask in #team-max-ai: the speak tool should run only when the flag is enabled, the setting is on, and an ElevenLabs key is configured.

Changes

  • New resolveLocalSpokenNarration in packages/core/src/sessions/spokenNarration.ts: narration threads into session start/reconnect only when spokenNarrationFlagEnabled && spokenNotifications && elevenLabsKeyConfigured. Pure and unit-tested; both sessionService call sites now share it.
  • SessionServiceDeps.settings gains spokenNarrationFlagEnabled — the host evaluates the flag (core has no feature-flag client) and supplies the fact. The renderer resolves it from FEATURE_FLAGS in sessionServiceHost.ts, failing closed when flags are unavailable or not yet loaded.
  • Desktop playback (SPEECH_SETTINGS_PROVIDER, SPEECH_NOTIFY_SETTINGS) now requires the flag alongside the setting, so a stale persisted setting can't keep spoken notifications alive with the flag off.

After this, #3500's "flag + setting + key" comments are accurate.

How did you test this?

  • New spokenNarration.test.ts (6 cases: all-on, each gate missing, all unset).
  • Full suites: @posthog/core (2403), @posthog/ui (1668), @posthog/agent (1394), @posthog/workspace-server (746) — all pass.
  • pnpm typecheck on core, ui, and apps/code; biome lint clean on touched files.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog Code

Generated-By: PostHog Code
Task-Id: 98ad1c64-54d6-4da0-81fe-97d3e4ce394f
@greptile-apps

greptile-apps Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix(agent): gate spoken narration on the..." | Re-trigger Greptile

@jonmcwest jonmcwest closed this Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant