fix(core): flip text content fields#2013
Open
rosetta-livekit-bot[bot] wants to merge 1 commit into
Open
Conversation
🦋 Changeset detectedLatest commit: 73862ee The changes in this PR will be included in the next version bump. This PR includes changesets to release 36 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#6353 to agents-js: assistant
textContentnow strips only LiveKit<expr/>markup, while provider/runtime paths use raw text viarawTextContentso model-facing expressive markup is preserved.Source diff coverage
Coverage classification
livekit-agents/livekit/agents/llm/_provider_format/anthropic.py- ported toplugins/anthropic/src/llm.ts; Anthropic context building now 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- ported toagents/src/llm/provider_format/google.ts; system messages now userawTextContent.livekit-agents/livekit/agents/llm/_provider_format/utils.py- ported toagents/src/llm/provider_format/utils.ts; mid-conversation instructions conversion now preserves raw instruction text.livekit-agents/livekit/agents/llm/chat_context.py- adapted toagents/src/llm/chat_context.tsandagents/src/tts/provider_format.ts; addedrawTextContent, made assistanttextContentstrip only<expr/>, addedstripMarkupJSON handling, and added the minimal expr-only stripping helper because the target lacked the Python TTS provider-format markup infrastructure.livekit-agents/livekit/agents/llm/utils.py- adapted toagents/src/llm/utils.ts; agents-js diff ops do not have Python'sto_update, so changed same-id message raw text is represented as remove/create.livekit-agents/livekit/agents/telemetry/traces.py- adapted/no code change; agents-js telemetry serialization already iterates message content directly rather than usingtextContent, so it already preserves raw text.livekit-agents/livekit/agents/tts/_provider_format.py- adapted toagents/src/tts/provider_format.ts; ported the expr-only strip behavior needed by the source change, not the full Python provider-format parser.livekit-agents/livekit/agents/voice/agent_activity.py- ported toagents/src/voice/agent_activity.ts; realtime reply input, preemptive transcript comparison, and user-input tracing now userawTextContent.livekit-agents/livekit/agents/voice/agent_session.py- not applicable; the exact debug logging path does not exist in agents-js.livekit-agents/livekit/agents/voice/remote_session.py- adapted/no code change; agents-js remote session serialization already iterates raw message content directly.livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/experimental/realtime/realtime_model.py- not applicable; agents-js has no AWS realtime plugin counterpart.livekit-plugins/livekit-plugins-langchain/livekit/plugins/langchain/langgraph.py- not applicable; agents-js has no LangChain plugin counterpart.livekit-plugins/livekit-plugins-phonic/livekit/plugins/phonic/realtime/realtime_model.py- ported toplugins/phonic/src/realtime/realtime_model.ts; system/developer messages, tail user text, and turn history now userawTextContent.livekit-plugins/livekit-plugins-turn-detector/livekit/plugins/turn_detector/base.py- adapted/no code change; agents-js keyterm/STT context paths intentionally use sanitizedtextContent, matching the source's new assistant-stripped behavior.livekit-plugins/livekit-plugins-ultravox/livekit/plugins/ultravox/realtime/realtime_model.py- not applicable; agents-js has no Ultravox plugin counterpart.livekit-plugins/livekit-plugins-xai/livekit/plugins/xai/realtime/realtime_model.py- not applicable; agents-js xAI realtime extends the OpenAI realtime implementation and does not contain the Python override/comparison path touched in the source diff.tests/test_expr_markup.py- ported toagents/src/llm/chat_context.test.ts; added the source tests for expr-only stripping, assistant/non-assistant text accessors, undefined text, andtoJSON({ stripMarkup: true }).Verification
pnpm test -- agents/src/llm/chat_context.test.ts agents/src/llm/utils.test.ts- passed.pnpm test -- plugins/anthropic plugins/phonic- passed after build; Phonic has no matching tests in this suite.pnpm test -- agents --exclude agents/src/voice/amd.test.ts- passed: 90 files, 1206 tests.pnpm build- passed.pnpm lint- passed with existing warnings.cue-clitext-mode runtime smoke against builtexamples/dist/warm_transfer.js(warm-transfer) - passed; observed one assistantconversation_item_addedframework event.Known unrelated verification blockers:
pnpm test -- agents plugins/anthropic plugins/phonicfails only becauseagents/src/voice/amd.test.tscurrently fails 11 AMD classification/timeout assertions; rerunningpnpm test -- agents/src/voice/amd.test.tsreproduces the same failures in isolation.pnpm api:checkis blocked by unrelated@livekit/agents-plugin-hedramissing API report warnings.@livekit/agentsand Phonic fail on unsupportedexport * as ___declarations, while Anthropic exits nonzero on pre-existing missing API report/release-tag warnings.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