feat(assemblyai): add language_codes steering param, enable agent_context_carryover by default#6443
Merged
tinalenguyen merged 9 commits intoJul 17, 2026
Conversation
…ns mutations Hoist language_codes normalization and validation to the start of both STT.update_options and SpeechStream.update_options, before any _opts mutations. This prevents partial updates when _normalize_language_codes raises ValueError (e.g., too many codes, 'multi' combined with others).
…ext_n_turns=0 in carryover default
tinalenguyen
approved these changes
Jul 17, 2026
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.
What
Two related upgrades to the AssemblyAI streaming STT plugin:
1.
language_codes— multi-language steeringlanguage_codes: list[str]parameter:language_codes=["en", "es"]biases transcription toward that set of languages instead of open detection/code-switching (Universal-3 Pro family only). The existing singularlanguage_codekeeps working unchanged as documented shorthand for a one-element list; passing both raisesValueError."en-US"/"english"→"en") and deduped preserving order; server limits are validated client-side (max 10 codes,"multi"must be sent alone) so misconfiguration fails at construction instead of as a websocket error.STT.update_options(language_codes=...)/SpeechStream.update_options(...), sent as anUpdateConfigurationmessage; an explicit[]clears steering back to the model default. Useful for agents that detect the caller's language and re-steer without reconnecting. Validation runs before any option mutation, so a rejected update never leaves options partially applied.language_codes=["en","es"]), the same convention askeyterms_prompt. Note for existinglanguage_codeusers: the singular is now also sent aslanguage_codes=["es"]— behaviorally identical, since the server declareslanguage_code/language_codes/languageas aliases for the same field.2.
agent_context_carryover— on by default, with a server-cap guardagent_contextlonger than 1750 chars, and an invalid mid-streamUpdateConfigurationcancels the entire streaming session. The plugin now enforces the cap client-side: the auto-carryover handler truncates oversize assistant replies (keeping the tail — the end of the reply is what the user responds to), and explicitagent_contextinput fails fast withValueError. Also fixes the stale "max 1500 characters" docstring (server cap is 1750).agent_context_carryoverdefaults to enabled on Universal-3 Pro family models (tri-stateNotGivenOr[bool]): the server already carries prior user turns automatically, so assistant-reply carryover completes the conversation context the models are designed to use. Opt out withagent_context_carryover=False; settingprevious_context_n_turns=0(documented as "disable context carryover") also suppresses the default. On unsupported models the default is silently off; explicitly passingTruethere keeps today's warning.agent_context(documented in the docstring; disable carryover to manage context manually).Testing
tests/test_plugin_assemblyai_stt.py: 43 new tests — normalization/dedup, mutual exclusion, U3-Pro gating on both construction and update paths, max-10/multi validation, JSON-array wire format for both spellings,UpdateConfigurationenqueue incl. empty-list clear, no-partial-update on validation failure, STT→stream propagation, truncation boundaries at exactly 1750/1751, tail-keeping, the four tri-state carryover cases, and handler safety for user/textless/handoff conversation items. Full file: 101 passed; ruff and strict mypy clean.