fix: pair tool outputs with their call by call_id when copying a chat context - #2531
Open
rosetta-livekit-bot[bot] wants to merge 1 commit into
Open
rosetta-livekit-bot[bot] wants to merge 1 commit into
rosetta-livekit-bot[bot] wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 7509935 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 |
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.
Ports livekit/agents#7330.
Summary
callIdwhen filtering a chat context by tools.@livekit/agents.Source diff coverage
livekit-agents/livekit/agents/llm/chat_context.py: Adapted toagents/src/llm/chat_context.ts; ports call-ID pairing incopy({ toolCtx })and the internal upsert behavior required by the voice changes.livekit-agents/livekit/agents/voice/agent_activity.py: Adapted toagents/src/voice/agent_activity.ts; records each realtime call with its output using JS event arrays and naming.livekit-agents/livekit/agents/voice/agent_session.py: Adapted toagents/src/voice/agent_session.ts; upserts tool items so execution-started calls are not duplicated.tests/test_chat_ctx.py: Adapted toagents/src/llm/chat_context.test.ts; ports all five new tool-filtering regression cases.tests/test_realtime_tool_call_created_at.py: Adapted toagents/src/voice/realtime_tool_output_commit.test.ts; ports the no-duplicate normal execution assertion and rejected-arguments call/output pairing case into the existing JS realtime harness.Verification
./node_modules/.bin/vitest run agents(2,724 passed, 5 skipped)./node_modules/.bin/turbo run build./node_modules/.bin/eslint -f unix "agents/src/**/*.ts" "plugins/*/src/**/*.{ts,js}" "examples/src/**/*.ts"./node_modules/.bin/prettier --check "**/src/**/*.{ts,tsx,md,json}"./node_modules/.bin/turbo run api:check --filter=@livekit/agentscue-cliruntime validation was attempted after building, but the configured LiveKit worker registration was rejected with HTTP 401, so no remote framework-event session could be driven.Ported from livekit/agents#7330
Original PR description
Problem:
ChatContext.copy(tools=...)filtered function items by tool name, butFunctionCallOutput.nameis optional and defaults to"", so a name-less output was removed while itsFunctionCallwas kept.group_tool_callsthen removed the orphaned call too, and a completed tool exchange disappeared from the request, leaving the user message that asked for the tool with no answer.Fix: An output is tested by its own name when it has one, and by
call_idagainst the surviving calls when it has none, so a named output behaves exactly as before. The realtime completion path also records a tool call next to its output, in the agent context and insession.history, because a call rejected before execution never reaches the execution-started callback that was its only record.Addresses #7324.
Context for reviewing and coding agents