Skip to content

refactor(tools): drop Wuu progressive tool loading for a stable prefix - #194

Merged
blueberrycongee merged 1 commit into
blueberrycongee:mainfrom
LeoLin990405:refactor/issue-168-drop-wuu-tool-search
Jul 29, 2026
Merged

blueberrycongee merged 1 commit into
blueberrycongee:mainfrom
LeoLin990405:refactor/issue-168-drop-wuu-tool-search

Conversation

@LeoLin990405

Copy link
Copy Markdown
Contributor

Summary

Implements the decision in #168: removes Wuu's provider-neutral wuu_tool_search progressive loading mode so the inference-request prefix stays stable, and keeps the local search executor that provider-native discovery depends on.

Changes

  • Loading policy is now native or flat. resolveToolLoadingModeForProvider resolves to native when the provider and model support deferred discovery, and flat otherwise. ShouldFallbackToWuuToolSearchByDefault had no remaining caller and is deleted.
  • Explicit native on an unsupported path degrades to flat, visibly. Previously it silently selected Wuu progressive loading. It now falls back to flat and 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.
  • The local search executor is untouched. internal/tools/tool_search.go and the discovery path stay: OpenAI and Anthropic native tool search still need Wuu to search the local catalog and return loadable schemas through tool_search_output / tool_reference. Every Native* runtime test still passes unchanged.

One deviation from the issue, worth a look

The scope says to remove the legacy tool_search alias and boolean migration path. Removing them outright makes any existing config that sets agent.tool_loading = "wuu_tool_search" fail Validate(), 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:

config before after
tool_loading: "wuu_tool_search" Wuu progressive auto + notice
tool_loading: "tool_search" (alias) Wuu progressive auto + notice
tool_search: true Wuu progressive auto
tool_search: false flat flat (unchanged)

auto rather than flat because the intent behind those values was "defer tools where you can", and auto still 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

  • Added or updated unit tests for the change
  • go test ./... passes
  • cd desktop && npm test passes
  • Manually verified the behavior in the desktop shell (if applicable)

Three 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 passing Validate(), supported values staying silent, and the legacy boolean mapping. make check passes; gofmt clean.

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

  • Risk level: medium — changes the tool surface sent to providers. No protocol or persisted-state change; the desktop and CLI read the resolved mode but do not set it.
  • Behaviour change to call out: anyone previously on the Wuu progressive path now gets a flat tool list, so their first request carries roughly 7.8 KB (~2.6K tokens by Wuu's estimator) more schema, in exchange for a prefix that stays cacheable.
  • Rollback: revert the commit.

Linked issues / docs

Closes #168

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
@blueberrycongee
blueberrycongee merged commit e81af50 into blueberrycongee:main Jul 29, 2026
5 checks passed
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.

Remove wuu_tool_search fallback to preserve prompt-cache stability

2 participants