Skip to content

fix(web): use session flavor label in voice context formatters#1

Draft
heavygee wants to merge 1 commit into
mainfrom
fix/voice-flavor-labels
Draft

fix(web): use session flavor label in voice context formatters#1
heavygee wants to merge 1 commit into
mainfrom
fix/voice-flavor-labels

Conversation

@heavygee
Copy link
Copy Markdown
Owner

@heavygee heavygee commented May 24, 2026

Summary

Replaces hardcoded Claude Code strings in voice context injections with the active session's flavor label (Cursor, Codex, Gemini, OpenCode, etc.) sourced from getFlavorLabel() in @hapi/protocol. Falls back to coding agent for unknown or missing flavors.

web/src/realtime/hooks/contextFormatters.ts — threads agentLabel (optional, default 'coding agent') through formatPlainText, formatPermissionRequest, formatMessage (text blocks + tool-call lines), formatNewMessages, formatHistory, formatSessionFull, formatReadyEvent.

web/src/realtime/hooks/voiceHooks.ts — adds getAgentLabel(session) helper using getFlavorLabel() from @hapi/protocol; passes label into all formatter calls.

Why shared/src/voice.ts is not touched

The system prompt in voice.ts contains example text that references "Claude" (e.g. the permission request example: "Claude wants to run a bash command"). We considered updating this but deliberately chose not to.

The argument for changing it: be as accurate as possible even in the ConvAI prompt.

The argument against, which won: once this PR (and tiann#682) are merged, every context update ConvAI receives will carry the correct agent label — "Cursor is requesting permission to use Bash", not "Claude Code is requesting...". At that point ConvAI's spoken responses will naturally reflect the right terminology, because LLMs follow the context they receive rather than parroting example text from a system prompt verbatim. The voice.ts wording only remains a real-world problem if these formatter fixes are not in place — which is an argument for merging this PR, not for also editing the system prompt. Touching system prompt wording without that being strictly necessary felt like stepping into editorial territory that belongs to the maintainers.

Happy to follow up separately on voice.ts if desired once these changes land.

Test plan

  • bun test web/src/realtime/hooks/contextFormatters.test.ts (8 tests — all assert label appears, none hardcode Claude Code)
  • Manual: voice session active, speech input and response verified end-to-end
  • Manual: ConvAI response correctly reflected active session context

Issues

Fixes tiann#680

@heavygee heavygee force-pushed the fix/voice-flavor-labels branch 3 times, most recently from e68ef31 to 8179263 Compare May 24, 2026 23:41
Replaces hardcoded 'Claude Code' strings in voice context injections with
the active session's flavor label (Cursor, Codex, Gemini, etc.) via
getFlavorLabel() from @hapi/protocol. Falls back to 'coding agent' for
unknown or missing flavors.

Threads an agentLabel param through formatMessage, formatPermissionRequest,
formatReadyEvent, formatNewMessages, formatHistory, and formatSessionFull.
voiceHooks resolves the label once per call via session.metadata.flavor.

Fixes tiann#680

via [HAPI](https://hapi.run)

Co-Authored-By: HAPI <noreply@hapi.run>
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.

bug(voice): context formatters hardcode "Claude Code" for all agent flavors

1 participant