Skip to content
Source
Sign inSign up
TanStack/ai

feat(ai-harness): routing.handoffTool can return undefined for the built-in tool #2286 (GitHub #2285)

Mergedimsherrill(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/2285/headmerged by AlemTuzlak View on GitHub

Showing 5 changed files with 8 additions and 2 deletions (loading 2).

x
0 of 5 viewed, 5 left
5 additions and 0 deletions.changeset/handoff-tool-undefined.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/ai-harness': patch
+---
+​
+`routing.handoffTool` can return `undefined` for a speaker. That speaker gets the built-in `handoff` tool, so an app can make custom tools for some speakers only.
1 addition and 1 deletiondocs/harness/handoffs.mdModified
View file
@@ -113,7 +113,7 @@
- `handoff({ to, note })` hands off. For the main model, the tool call is already in the transcript. The harness adds no note messages.
- A tool handoff from a root agent still adds the two note messages.
- `state` is the same function as `ctx.harness.state`. Use it to read the work that your agents keep there, for example `await state({ key: 'order', initial: '' }).get()`. Then put that work in the note. See [Share state between agents](./subagents#share-state-between-agents).
-- The tool can have any name. With `giveModelsHandoffTool: false`, the harness does not call `handoffTool`.
+- The tool can have any name. Return `undefined` to give that speaker the built-in `handoff` tool. With `giveModelsHandoffTool: false`, the harness does not call `handoffTool`.
​
Give one speaker an app tool with the same name as the tool that `handoffTool` returns. It replaces the harness tool. Its code hands off with `ctx.context.run.handoff` (main model) or `ctx.harness.handoff` (root agent), as in [Hand off from code](#2-hand-off-from-code).
​
2 additions and 1 deletionpackages/ai-harness/src/define.tsModified
View file
@@ -213,6 +213,7 @@
* Make the handoff tool of each speaker. The harness calls it once per
* speaker (the main model and each root agent) per turn. The returned
* tool replaces the default `handoff` tool, and it can have any name.
+ * Return `undefined` to give that speaker the default `handoff` tool.
* Not called when `giveModelsHandoffTool` is false.
* @example