refactor(tools): drop Wuu progressive tool loading for a stable prefix - #194
Merged
blueberrycongee merged 1 commit intoJul 29, 2026
Conversation
wuu_tool_search omitted deferred schemas from the first request and appended matched ones to the top-level tools array on a later step. Anthropic caches on tools -> system -> messages and OpenAI requires identical tool definitions and ordering, so each load invalidated the cached prefix past the insertion point, including the system prompt and history. Long tool loops made that cost unpredictable. Flattening the 7 deferred tools adds ~7.8 KB of schema, a fixed cost a stable prefix amortizes. Loading resolves to native where the provider and model support deferred discovery, and flat everywhere else. The local search executor stays: OpenAI and Anthropic native tool search still need Wuu to search the local catalog and return loadable schemas through tool_search_output / tool_reference. Explicit native on an unsupported provider or model now degrades to flat with a deduped stderr notice rather than silently selecting a different strategy — the user asked for deferred tools and is not getting them. Configs naming the removed mode keep starting. wuu_tool_search, the tool_search alias, and tool_search: true resolve to auto with a one-time deprecation notice; failing validation would turn a retired tuning knob into a startup error. Closes blueberrycongee#168
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
Implements the decision in #168: removes Wuu's provider-neutral
wuu_tool_searchprogressive loading mode so the inference-request prefix stays stable, and keeps the local search executor that provider-native discovery depends on.Changes
nativeorflat.resolveToolLoadingModeForProviderresolves tonativewhen the provider and model support deferred discovery, andflatotherwise.ShouldFallbackToWuuToolSearchByDefaulthad no remaining caller and is deleted.nativeon an unsupported path degrades toflat, visibly. Previously it silently selected Wuu progressive loading. It now falls back toflatand prints a notice naming the provider, the model, and the mode actually in effect — the user asked for deferred tools and is not getting them. Deduped per provider+model over the process lifetime, because tool loading is re-resolved on every session build and every provider switch.internal/tools/tool_search.goand the discovery path stay: OpenAI and Anthropic native tool search still need Wuu to search the local catalog and return loadable schemas throughtool_search_output/tool_reference. EveryNative*runtime test still passes unchanged.One deviation from the issue, worth a look
The scope says to remove the legacy
tool_searchalias and boolean migration path. Removing them outright makes any existing config that setsagent.tool_loading = "wuu_tool_search"failValidate(), which turns a retired tuning knob into a hard startup error for someone who set it once and forgot.This keeps those spellings parsing and resolves them to
auto, with a one-time deprecation notice naming the replacement:tool_loading: "wuu_tool_search"auto+ noticetool_loading: "tool_search"(alias)auto+ noticetool_search: trueautotool_search: falseautorather thanflatbecause the intent behind those values was "defer tools where you can", andautostill gives native discovery on providers that support it. The validation message no longer advertises the removed mode, and an unknown value still errors. Happy to make it a hard error instead if you would rather force the edit.Test plan
go test ./...passescd desktop && npm testpassesThree existing runtime tests asserted the removed behavior and now assert the flat outcome, including that the flat surface stops shipping the deferred-catalog prompt and declares the formerly deferred tools directly. New tests cover: the fallback notice contents and its per-provider+model dedupe, the retired values resolving to
auto, a retired value still passingValidate(), supported values staying silent, and the legacy boolean mapping.make checkpasses;gofmtclean.Not verified in the desktop shell — this is core-side resolution with no renderer surface, and I could not launch Electron in this environment.
Risk and rollback
Linked issues / docs
Closes #168