fix(core): flip text content fields#2013
Open
rosetta-livekit-bot[bot] wants to merge 4 commits into
Open
Conversation
🦋 Changeset detectedLatest commit: 8164139 The changes in this PR will be included in the next version bump. This PR includes changesets to release 39 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 |
Remove unmatched expressive delimiters so malformed model output cannot leak into user-facing text, and lock in raw-content diff behavior. Co-authored-by: Cursor <cursoragent@cursor.com>
Preserve expr-markup behavior while adopting current chat-context update APIs and the Rosetta patch release policy. Co-authored-by: Cursor <cursoragent@cursor.com>
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#6353 to agents-js: assistant
textContentstrips only LiveKit<expr/>markup, while provider/runtime paths userawTextContentso model-facing expressive markup is preserved. The follow-up repair also strips unmatched opening and closing<expr>delimiters independently, matching Python's current_split_exprbehavior for malformed model output.Current
mainnow contains the overlapping raw-content implementation from #2087. This branch mergesmain, adopts its current chat-context update API, and retains the verified expr-only helper and malformed-marker regressions without reintroducing obsolete remove/create diff behavior.Source diff coverage
Coverage classification
livekit-agents/livekit/agents/llm/_provider_format/anthropic.py- represented byplugins/anthropic/src/llm.ts; Anthropic context building usesrawTextContent.livekit-agents/livekit/agents/llm/_provider_format/aws.py- not applicable; agents-js has no AWS provider-format counterpart.livekit-agents/livekit/agents/llm/_provider_format/google.py- represented byagents/src/llm/provider_format/google.ts; system messages userawTextContent.livekit-agents/livekit/agents/llm/_provider_format/utils.py- represented byagents/src/llm/provider_format/utils.ts; mid-conversation instructions preserve raw instruction text.livekit-agents/livekit/agents/llm/chat_context.py- adapted toagents/src/llm/chat_context.tsandagents/src/tts/provider_format.ts;rawTextContentpreserves exact model content, assistanttextContentstrips only expr markup, andstripMarkupJSON handling is assistant-only.livekit-agents/livekit/agents/llm/utils.py- represented byagents/src/llm/utils.ts; current-maintoUpdateoperations compare same-ID messages byrawTextContent, matching Python's current API more directly than the branch's obsolete remove/create adaptation.livekit-agents/livekit/agents/telemetry/traces.py- adapted/no additional diff; agents-js telemetry uses raw message content.livekit-agents/livekit/agents/tts/_provider_format.py- adapted toagents/src/tts/provider_format.ts; paired, self-closing, and independent unmatched expr delimiters are removed while provider-native markup remains untouched.livekit-agents/livekit/agents/voice/agent_activity.py- represented byagents/src/voice/agent_activity.ts; realtime reply input, preemptive transcript comparison, and user-input tracing userawTextContent.livekit-agents/livekit/agents/voice/agent_session.py- not applicable; the exact Python debug logging path does not exist in agents-js.livekit-agents/livekit/agents/voice/remote_session.py- adapted/no additional diff; agents-js remote-session serialization transports raw message content.textContent, matching Python's behavior.tests/test_expr_markup.py- represented byagents/src/llm/chat_context.test.ts; coverage includes expr-only stripping, assistant/non-assistant accessors, undefined text, JSON stripping, malformed delimiters, and stream-assembled markers.agents/src/llm/utils.test.tscovers same-ID raw-content updates through current-maintoUpdatesemantics.Release decision
Per the explicit Rosetta release policy, every entry in
.changeset/fuzzy-crabs-express.mdispatch: core, Anthropic, and Phonic.Verification
Exact head:
8164139685385cd78c4afcf02551977010f7b5da.pnpm test agents/src/llm/chat_context.test.ts agents/src/llm/utils.test.ts agents/src/tts/tts.test.ts agents/src/voice/agent_activity.test.ts- passed: 4 files, 170 tests.pnpm test agents/src/llm/provider_format/google.test.ts agents/src/llm/provider_format/utils.test.ts plugins/anthropic/src/llm.test.ts- passed: 3 files, 38 tests.pnpm build- passed after merging current main and again before the temporary TypeScript Cue agent was run.pnpm typecheck- passed.pnpm lint- passed.pnpm format:check- passed.git diff --check- passed.Known unrelated API tooling limitations:
pnpm api:checkstops atplugins/bey, whose package definesapi:checkwithout anapi-extractor.json.pnpm --filter @livekit/agents api:checkis blocked by API Extractor 7.43.7 rejecting generated TypeScript 5.9export * asdeclarations. This PR does not add a public export.Cue voice E2E
sid_b18f4f9c7058.8164139685385cd78c4afcf02551977010f7b5da(also embedded in the decisive debug event).pr2013-expr-final-81641396; the source file was removed and the worker stopped after verification.Alpha <expr type="break" label="1s"/> bravo.agent_state_changed(.new_state="AS_SPEAKING") -> debug_message(.payload.kind="expr_text_clean",.payload.text="Alpha bravo",.payload.head="8164139685385cd78c4afcf02551977010f7b5da").ChatMessage.textContent, and persisted JSON/events contained no literal expr markup.cartesia/sonic-3,characters_count=12,audio_duration=0.734, confirming the cleaned text was sent to TTS.c0acbe9654bb8adf33120721cd018007c44cae80210cf9bd9ea6083121d42a40.77c74cc5db1b6e58f55ecfbc9d75e68fa84a2045bddb9f4187fb898a1d12f81e.Alpha Bravo.No markup was spoken.Ported from livekit/agents#6353
Original PR description
Before:
text_contentraw content, with expressive tags and bracket tags;plain_text_contentclean content, without any tags;Now:
text_contentclean content, without any expressive-only tagsexprraw_text_contentraw content withexprtags