Skip to content

fix: honor ignore on enter for toolsets#2011

Open
rosetta-livekit-bot[bot] wants to merge 1 commit into
mainfrom
nestled-bushiest-woofing
Open

fix: honor ignore on enter for toolsets#2011
rosetta-livekit-bot[bot] wants to merge 1 commit into
mainfrom
nestled-bushiest-woofing

Conversation

@rosetta-livekit-bot

@rosetta-livekit-bot rosetta-livekit-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Ports livekit/agents#6361 to JS by honoring ToolFlag.IGNORE_ON_ENTER after flattening ToolContext, so ignored tools nested inside a Toolset are hidden during onEnter replies and their nested tool-response follow-ups.

Also adds ignoreOnEnter to createEndCallTool, matching the source option for hiding the end-call tool during greetings.

Source diff coverage

Coverage classification
Source file Classification Target coverage
livekit-agents/livekit/agents/beta/tools/end_call.py Adapted agents/src/beta/tools/end_call.ts: added ignoreOnEnter?: boolean and maps it to ToolFlag.IGNORE_ON_ENTER; JS uses camelCase options and factory function style.
livekit-agents/livekit/agents/llm/tool_context.py Ported agents/src/llm/tool_context.ts: added internal _exclude() / flattened sync behavior that hides selected callable tools while preserving owning Toolset lifecycle/grouping.
livekit-agents/livekit/agents/voice/agent_activity.py Adapted agents/src/voice/agent_activity.ts: replaced top-level-only on-enter filtering with flattened ToolContext filtering for pipeline replies, added _onEnterIgnoredTools, and applied temporary filtered tools for realtime replies.
tests/test_agent_session.py Adapted agents/src/voice/agent_activity.test.ts: ported the source behavioral assertions to target unit-style coverage for bare plus toolset-nested ignored tools, nested async/tool-response context preservation, restoration outside onEnter, and agent/session scoping.
tests/test_tools.py Ported/adapted agents/src/llm/tool_context.test.ts: ported _exclude tests and adapted the end-call flag test to createEndCallTool({ ignoreOnEnter: true }).

Verification

  • pnpm test agents/src/llm/tool_context.test.ts agents/src/voice/agent_activity.test.ts passed.
  • pnpm --filter @livekit/agents typecheck passed.
  • pnpm --filter @livekit/agents build passed.
  • pnpm --filter @livekit/agents lint completed with existing warnings only.
  • pnpm test agents/src was run twice. The final run had 90 test files pass and 1 fail: agents/src/voice/amd.test.ts with 11 AMD-classification/time-out failures unrelated to this port.
  • pnpm --filter @livekit/agents api:check is blocked by existing API Extractor tooling: The "export * as ___" syntax is not supported yet in generated agents/dist/index.d.ts.
  • cue-cli runtime validation was attempted with a temporary built .mjs agent using a Toolset-nested ignored tool. The worker registered and ran onEnter, but cue-cli run --resume --until 'debug_message(.payload.visible_tools="keep")' timed out with zero captured framework events, so the cue-cli validation was inconclusive. The temporary agent was not committed.

Changeset

Added a patch changeset for @livekit/agents.


Ported from livekit/agents#6361

Original PR description

Closes #6354

ToolFlag.IGNORE_ON_ENTER was only honored for bare FunctionTool/RawFunctionTool instances in the on_enter reply filter — tools nested in a Toolset (e.g. EndCallTool) passed through unfiltered, so the model could fire a speculative end_call during the greeting turn (with delete_room=True, an instant hangup at pickup).

The filter now flattens toolsets and hides flagged tools via ToolContext._exclude, which drops them from the callable/LLM-visible set while keeping the owning toolset in place so executor routing and lifecycle are unaffected. Rather than threading the ignored set through the reply tasks, _on_enter_ignored_tools reads the on_enter contextvar directly; the reply task and its tool-response follow-ups inherit it through asyncio.create_task.

The realtime path is covered too: it only overrides its session tools when generate_reply is given tools=, so inside on_enter it now falls back to the agent's full set and hides flagged tools even without an explicit tools=.

EndCallTool gains an ignore_on_enter parameter (defaults to False, preserving current behavior) to opt into hiding end_call during the greeting.

@rosetta-livekit-bot rosetta-livekit-bot Bot requested a review from a team as a code owner July 9, 2026 12:27
@changeset-bot

changeset-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 07b0948

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 36 packages
Name Type
@livekit/agents Patch
@livekit/agents-plugin-anam Patch
@livekit/agents-plugin-anthropic Patch
@livekit/agents-plugin-assemblyai Patch
@livekit/agents-plugin-baseten Patch
@livekit/agents-plugin-bey Patch
@livekit/agents-plugin-cartesia Patch
@livekit/agents-plugin-cerebras Patch
@livekit/agents-plugin-deepgram Patch
@livekit/agents-plugin-did Patch
@livekit/agents-plugin-elevenlabs Patch
@livekit/agents-plugin-fishaudio Patch
@livekit/agents-plugin-google Patch
@livekit/agents-plugin-hedra Patch
@livekit/agents-plugin-hume Patch
@livekit/agents-plugin-inworld Patch
@livekit/agents-plugin-lemonslice Patch
@livekit/agents-plugin-liveavatar Patch
@livekit/agents-plugin-livekit Patch
@livekit/agents-plugin-minimax Patch
@livekit/agents-plugin-mistral Patch
@livekit/agents-plugin-mistralai Patch
@livekit/agents-plugin-neuphonic Patch
@livekit/agents-plugin-openai Patch
@livekit/agents-plugin-perplexity Patch
@livekit/agents-plugin-phonic Patch
@livekit/agents-plugin-resemble Patch
@livekit/agents-plugin-rime Patch
@livekit/agents-plugin-runway Patch
@livekit/agents-plugin-sarvam Patch
@livekit/agents-plugin-silero Patch
@livekit/agents-plugin-soniox Patch
@livekit/agents-plugin-tavus Patch
@livekit/agents-plugins-test Patch
@livekit/agents-plugin-trugen Patch
@livekit/agents-plugin-xai Patch

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

@rosetta-livekit-bot rosetta-livekit-bot Bot requested a review from longcw July 9, 2026 12:27

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants