Repository navigation
feat(harness): add toolsearch for deferred tools - #114
Merged
Merged
Conversation
The model searches the deferred tools it is not offered yet with BM25 over each tool's name, description and parameter text, and the matches are loaded for its next request. A load writes one `agent` revision in the settling event; the offered set per request is the declared tools plus `modelTools.add` minus `modelTools.remove`. When it differs from what the transcript declares, a `system` entry carries `toolsAdded`/`toolsRemoved` and context assembly turns it into an aikit system message, so the request prefix stays cached. A call to a registered tool outside the selection fails with `ToolUnavailable`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
`ContextCodec.decodeMessage` returns the stored message of a `user`, `assistant` or `system` entry, so a thread's history decodes whole once a tool was loaded. `ContextCodec.parts` reads a message's parts; a system message has none. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
`unknown-tool` and `invalid-arguments`, like the other error codes; the unknown-tool text reads `Unknown Tool`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Summary
Built-in
toolsearchtool: the model finds tools it isn't offered yet (exposuredeferred) and loads them for its next request, without the prompt changing every time one is registered.toolsearch(packages/harness/src/plugin/builtin/tool/toolsearch.ts, ranker insrc/tool/search.ts): BM25 over each tool's name, description and parameter text;limitdefaults to 8; fixed description;exposure: "model". ShipsoptInlike grep/find/ls.agent: theToolSettledprojector writes oneagentrevision adding the matches tomodelTools.addat the settle event's own seq (no second event).direct/model) tools, plusmodelTools.add(deferred only), minusmodelTools.remove;agentis read once per request.Registry.resolve(selection)exposeswire(declared),offeredanddeferred; the system prompt's tool index lists declared tools only, so a load never moves the prefix.session.thread.tools.changedappends asystementry (toolsAdded,toolsRemoved, declaration hash) when the offered set differs from what the transcript replays to; context assembly turnssystementries into aikitSystemMessages.ToolUnavailable: a call to a registered tool outside the selection (removed, or deferred and not loaded) fails with a tagged error result; unknown names keepUnknown tool.Tests
End-to-end, each ending in an
__artifacts__/snapshot (test/tools.toolsearch.test.ts): a search loads a tool and the next request offers it through asystementry; empty/bad query and no matches; the limit and the default; a fork cut before the load does not offer the tool while one cut after does; calling an unloaded or removed tool returnsToolUnavailable. Plus one live run withopenai-codex/gpt-6-luna(test/tools.toolsearch.live.test.ts), passing.tools.exposure.jsonchanged on purpose: calling a registered deferred tool is nowToolUnavailableinstead ofUnknown tool.