Skip to content

feat(agents): add async toolset#1417

Open
u9g wants to merge 3 commits intomainfrom
riot-lurid-myopic
Open

feat(agents): add async toolset#1417
u9g wants to merge 3 commits intomainfrom
riot-lurid-myopic

Conversation

@u9g
Copy link
Copy Markdown
Contributor

@u9g u9g commented May 7, 2026

Summary

  • Add AsyncToolset and AsyncRunContext for long-running tools that can publish progress updates and final results after the initial tool call returns.
  • Include duplicate-call handling plus built-in get_running_tasks and cancel_task helper tools.
  • Export the async toolset API and add a changeset for @livekit/agents.

Tests

  • pnpm test -- agents/src/llm/async_toolset.test.ts
  • pnpm build:agents
  • pnpm exec eslint -f unix "src/llm/async_toolset.ts" "src/llm/async_toolset.test.ts" from agents/

Notes

  • pnpm run api:check from agents/ is currently blocked by API Extractor rejecting existing export * as ___ syntax in dist/index.d.ts.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 7, 2026

🦋 Changeset detected

Latest commit: f6f0354

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

This PR includes changesets to release 30 packages
Name Type
@livekit/agents Patch
@livekit/agents-plugin-anam 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-elevenlabs Patch
@livekit/agents-plugin-fishaudio Patch
@livekit/agents-plugin-google Patch
@livekit/agents-plugin-hedra 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-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-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

Copy link
Copy Markdown
Contributor

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

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

devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 8 additional findings in Devin Review.

Open in Devin Review

Comment on lines +270 to +279
this.tools = {
...Object.fromEntries(
Object.entries(tools).map(([name, functionTool]) => [
name,
this.wrapTool(name, functionTool),
]),
),
get_running_tasks: this.getRunningTasksTool(),
cancel_task: this.cancelTaskTool(),
} as ToolContext<UserData>;
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.

🟡 Built-in tools silently overwrite user-provided tools with the same name

In the AsyncToolset constructor, user-provided tools are spread first, then the built-in get_running_tasks and cancel_task tools are unconditionally added, silently overwriting any user tool with the same name. If a user passes a tool named cancel_task or get_running_tasks in their tools object, their tool is wrapped via wrapTool (line 272-275) but then immediately discarded when the built-in tool overwrites it (line 277-278). There is no warning or error. The user's custom tool logic will never execute, which is difficult to diagnose.

Prompt for agents
In the AsyncToolset constructor (agents/src/llm/async_toolset.ts, lines 263-280), the built-in tools get_running_tasks and cancel_task are added after spreading user-provided tools, silently overwriting any user tool with the same name. The fix should either: (1) throw an error if the user provides a tool with a reserved name, (2) log a warning that the tool is being overwritten, or (3) check for name collisions before merging. The reserved names are get_running_tasks and cancel_task. This check should happen before the Object.fromEntries spread on line 271.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

1 participant