feat(stt): add stt context options#2058
Open
rosetta-livekit-bot[bot] wants to merge 1 commit into
Open
Conversation
🦋 Changeset detectedLatest commit: 7a0c614 The changes in this PR will be included in the next version bump. This PR includes changesets to release 37 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ports livekit/agents#6475 to agents-js:
sttContextOptionswithkeyterms,keytermDetection, andforwardChatContext.keytermsOptionsmapped to the new STT context shape.sttContextOptions.forwardChatContext.agentContextCarryoverretained as an opt-out/compat flag.Source diff coverage
Coverage table
examples/voice_agents/basic_agent.pyexamples/src/basic_agent.ts: renamedkeytermsOptionstosttContextOptionsin the matching example.livekit-agents/livekit/agents/__init__.pyagents/src/voice/index.tsand rootagents/src/index.ts: root already re-exports voice; addedSTTContextOptionsto voice public exports.livekit-agents/livekit/agents/inference/stt.pyagents/src/inference/stt.ts: JS inference STT does not exposeagentContextCarryover; chat-context capability now follows AssemblyAI U3 Pro model support and is refreshed on model changes.livekit-agents/livekit/agents/voice/__init__.pyagents/src/voice/index.ts: exportedSTTContextOptions.livekit-agents/livekit/agents/voice/agent_activity.pyagents/src/voice/agent_activity.ts: STT conversation-item forwarding is gated onsttContextOptions.forwardChatContext.livekit-agents/livekit/agents/voice/agent_session.pyagents/src/voice/agent_session.tsandagents/src/voice/turn_config/utils.ts: addedsttContextOptions, preserved deprecatedkeytermsOptions, mapped old option to the new shape, and made the new option take precedence.livekit-agents/livekit/agents/voice/keyterm_detection.pyagents/src/voice/keyterm_detection.ts: addedSTTContextOptions, resolver defaults, and deprecated keyterms-to-STT-context mapping.livekit-plugins/livekit-plugins-assemblyai/livekit/plugins/assemblyai/stt.pyplugins/assemblyai/src/stt.ts: carryover is default-on for U3 Pro models, and deprecatedagentContextCarryoverremains as an opt-out/compat flag with warnings.tests/test_agent_session.pyagents/src/voice/agent_session.test.ts: added defaults, passthrough, deprecated mapping, and precedence tests.tests/test_inference_stt_context.pyagents/src/inference/stt.test.ts: added chat-context capability tests to the existing inference STT test file.tests/test_plugin_assemblyai_stt.pyplugins/assemblyai/src/stt.test.ts: added AssemblyAI carryover default/deprecation behavior tests.tests/test_stt_context.pyagents/src/voice/keyterm_detection.test.ts: added resolver and deprecated mapping tests.No source diff files were marked not applicable.
Validation
Passed:
pnpm test agents/src/voice/keyterm_detection.test.ts agents/src/voice/agent_session.test.ts agents/src/inference/stt.test.tspnpm test plugins/assemblyai/srcpnpm --filter @livekit/agents buildpnpm --filter @livekit/agents-plugin-silero buildpnpm --filter @livekit/agents-plugins-test buildpnpm --filter @livekit/agents-plugin-assemblyai buildpnpm --filter @livekit/agents lintpnpm --filter @livekit/agents-plugin-assemblyai lintpnpm --filter livekit-agents-examples lintpnpm buildpnpm lintpnpm format:checkcue-clitext-mode runtime validation against a temporary JS agent, asserting the expected assistantconversation_item_addedframework event.Known validation gaps:
pnpm test agents/srcfails on existingagents/src/voice/amd.test.tsexpectations;agents/src/voice/amd.test.tsalso fails when run alone with 11 AMD classification/timeout failures. The focused STT/session tests added by this PR pass.pnpm test agents/srcrun also observed oneagents/src/inference/eot/transports.test.tstimeout; that file passed in a focused rerun alongsideamd.test.ts.pnpm --filter @livekit/agents api:checkfails before API diffing on existing API Extractor unsupported syntax:export * as ___inagents/dist/index.d.ts.pnpm --filter @livekit/agents-plugin-assemblyai api:checkexits non-zero on existing API Extractor warnings/missing report (etc/agents-plugin-assemblyai.api.md).Ported from livekit/agents#6475
Original PR description
Adds
stt_context_optionsonAgentSession— a single conversation-aware STT option grouping statickeyterms, LLMkeyterm_detection, and aforward_chat_contexttoggle that forwards agent replies to STTs that consume context natively (e.g. AssemblyAI Universal-3 Pro).forward_chat_contextis on by default and is the only control for carryover, applied consistently across the inference STT and the AssemblyAI plugin. Agent replies are now sent to AssemblyAI u3-pro by default when used viaAgentSession; opt out withstt_context_options={"forward_chat_context": False}.Deprecated (still work, warn):
AgentSession(keyterms_options=...)→ usestt_context_optionsagent_context_carryover→ usestt_context_options.forward_chat_context(passFalseto opt out)Removes the unpublished
agent_context_carryoverparam from the inference STT.