Conversation
🦋 Changeset detectedLatest commit: f6f0354 The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 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.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>; |
There was a problem hiding this comment.
🟡 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.
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
AsyncToolsetandAsyncRunContextfor long-running tools that can publish progress updates and final results after the initial tool call returns.get_running_tasksandcancel_taskhelper tools.@livekit/agents.Tests
pnpm test -- agents/src/llm/async_toolset.test.tspnpm build:agentspnpm exec eslint -f unix "src/llm/async_toolset.ts" "src/llm/async_toolset.test.ts"fromagents/Notes
pnpm run api:checkfromagents/is currently blocked by API Extractor rejecting existingexport * as ___syntax indist/index.d.ts.