Repository navigation
feat(tooldefer): the proxy answers Claude Code's ToolSearch: one search tool per request (#898) - #900
Conversation
…earch tool serves a request (#898) On a Claude model with Claude Code's own ToolSearch, a new thread gets no server-side search tool. The proxy replaces the result of a ToolSearch call that touches a tool it deferred with tool_reference blocks, on the next request. The answer is kept in the thread record by tool_use id and replayed byte for byte. A second probe gates the mode. Without ToolSearch, the server-side search stays. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
…sult; disable on a format change (#898) On a Claude model with Claude Code's own ToolSearch, a new thread gets no server-side search tool. Every ToolSearch call goes to Claude Code. On the next request the proxy adds tool_reference blocks for its own deferred tools to a select:A,B result, and replays the list byte for byte from the thread record. A hash of the ToolSearch description gates the mode. An unknown hash, a non-select query that names our tool, or a call to a tool no search loaded disables the mode for that hash (cg_tooldefer_client_disabled_total). Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
Fill T1 to T4 with the metric, the /stats field and the log line from PR #900 (open, not reviewed). Add how each reason counts, the disable scope, today's known-good hash, and the log join T4 needs. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
Codex on gpt-5.5 declares its own tool_search. After #897 the proxy adds no context_guru_tools to such a request and defers nothing on it. Our search is only for a Responses client that declares no tool_search of its own. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.317 | offload-review skill, @amiddavid's session | fresh | 2 of 2 | 1 of 2 | dec692db349c |
blocking |
Verdict: blocking
Findings
-
tooldefer/apply.go:253 — the ledger keeps counting a client-mode load as saved, and never counts its cost
- What fails: a thread in client-search mode loads a deferred tool (the proxy writes a
tool_referenceinto a ToolSearch result). From that request on,/statsand the dashboard net-saving panel report wrong dollars:DeferredTokensstill counts the tool as saved, andLoadedTokensandWrongGuessesstay 0. - Proof: two halves.
- The savings side weighs from the client's body:
loaded := Loaded(r.Orig)(apply.go:253). But the client's next request carries Claude Code's own result, not our augmented one — we change only the bytes we send upstream. SoLoaded(r.Orig)never sees a client-mode load, andweighkeeps the tool inDeferredTokenson every later request. The ledger's own model says this is wrong: ledger.go:67-69, "minus those of tools a search has already loaded in this transcript (those are paid inline again)". The API expands the reference on every request that carries it. - The cost side reads only server-side searches:
deferLedgerfillsLoadedTokensandWrongGuessesfromu.SearchLoadedandst.loaded(proxy/tooldefer.go:656-660), both parsed from server_tool_use / tool_search_tool_result blocks in the response. A client-mode response has none.o.Loadsis used only for the history (noteSearchLoads, proxy/tooldefer.go:453-456), never for the ledger.
- The savings side weighs from the client's body:
- Fix: in client mode weigh from the augmented body (
Loaded(out), or addo.Loadsto the exclusion set), and passo.LoadsintodeferLedgeras the loaded names (loaded tokens, wrong guesses).
- What fails: a thread in client-search mode loads a deferred tool (the proxy writes a
-
tooldefer/toolsearch.go:190 — an errored search result still books the tools as used
- What fails: Claude Code's ToolSearch returns an error or a shape the proxy does not know (for example the string
"Error: boom"). The query wasselect:Workflow. The proxy writes notool_reference(thedefault: continueat line 205), but it has already stored the answer and appended the names toa.Loads(lines 183-191). The host then callsnoteSearchLoads, which records Workflow as used in the tool history. The model never saw the schema, yet the user's later sessions keep that tool loaded (never deferred again, 30-day retention). - Proof: trace
AugmentSearches:rec.Answers[id] = names,a.Loads = append(a.Loads, names...),a.Answered++all run before the result-shapeswitch; only the reference write is skipped bycontinue. The testTestClientModeAddsOnlyOurToolsToSelectQueriesasserts the result text is untouched but does not checko.Loads, so the false booking passes unnoticed. - Fix: store the answer and book the loads only when the proxy actually writes a reference — that is, only for the
noMatchTextand all-refs-array shapes. For any other shape, leave the call unanswered (it will be re-tried on the next request, same pure function).
- What fails: Claude Code's ToolSearch returns an error or a shape the proxy does not know (for example the string
-
docs/data-dependence.md:187 — the row was not updated for the new stored field
- What fails:
RecordgainsAnswers(tool_use id → tool names, tooldefer/tooldefer.go:341), kept on disk undercg:tdf:for Claude Code threads. The toolfilter row describes the call-id record only "on GPT, GLM and Kimi" (#825). A reader who asks what deferral keeps for a Claude Code thread now gets an incomplete answer. CLAUDE.md makes this update mandatory for every PR that changes a feature's data dependence, and asks the row's "Decided by" to confirm it before merge. - Proof: the diff touches
docs/reference/presets.mdand addsdocs/tool-search-matrix.md;docs/data-dependence.mdis unchanged. The stored data changed: a new field, with call ids, on the Claude Code path the row does not cover. The feature also now reads tool_result text to decide behavior (the no-match text inAugmentSearches, "not loaded" / "no such tool" inUnloadedCall) — worth a plain-words note in the row. - Fix: extend the toolfilter row: the thread record now also keeps, for each ToolSearch call the proxy answered on a Claude Code thread, the call id and the tool names it added (#898). Have the row's "Decided by" confirm it on the PR.
- What fails:
Non-blocking
AddBacksnow mixes two things: #825 add-backs (the tool returns totools) and #898 client-mode loads (the tool stays deferred; a reference is written). The/statstext foradd_backssays "tools a search added back", which no longer covers both (proxy/tooldefer.go:455, gate.go).- A direct call to a deferred tool, which the API accepts (see the known limits on
Rebuild, tooldefer.go:417-419), counts as abreakin client mode: it disables the mode for the tenant and hash for 24 h. The matrix documents this as the design, and it fails toward not deferring, but the server-side mode has no such false positive. ListTokenscounts the server names-list head (apply.go:267) while client mode sendsClientToolNamesList, a different text. A few tokens per request.DisableClientbypasses the live-mark check forReasonBreak(gate.go:432), so break counts once per breaking thread. The metric help text says "once per tenant and hash per 24 h". Several live threads breaking after one format change each add 1.- Past
maxAnswers(256), answers are recomputed on every request and the loads re-booked each time (AddBacks, historyObserve). Rare, but the counters inflate. AddKnownDescHashwrites the package-levelknownDescHashesmap with no lock. Fine while only tests call it, but the function is exported.
What I checked
- The full diff of all three commits, line by line, and the code around each change:
tooldefer/apply.go,rewrite.go,tooldefer.go,toolsearch.go,gate.go,probe.go,proxy/tooldefer.go,promexport.go. - The systems the change sits in: the ledger (
tooldefer/ledger.go), the #825 in-band search (tooldefer/clientsearch.go), the prober, the store keys, and the data-dependence doc. - The fail-open paths: unknown description hash, non-select query, break,
client_search_gone,AugmentSearcheserror shapes, the panic recover inApply. Each sends the original request. The break path changestoolsonce, as documented. - Byte stability of the answered round within a thread and across a restart (replay from
Record.Answers), and the re-decide path for a record lost mid-thread (a client thread has nohasSearchTurn, so it re-decides; loads in the transcript count as uses, so loaded tools stay loaded). - The probe:
ClientProbeBodyshape, its verdict, the route-suffixed probe key, and the beta handling instartProbe. - Tests added in
tooldefer/toolsearch_test.goandproxy/tooldefer_test.go: coverage of the select-only rule, the three disable reasons, the replay, the live-thread stickiness, and the end-to-end path. - Docs:
presets.md, the newtool-search-matrix.md(claims match the code),docs/design.md. - No Go builds or tests were run (not approved; Go is not on this machine).
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.317 | offload-review skill, @amiddavid's session | fresh | 1 of 2 | 1 of 2 | dec692db349c |
blocking |
Verdict: blocking
Findings
-
tooldefer/toolsearch.go:286 — a legal call to a deferred tool reads as a break and disables client search for the whole tenant, for 24 h
- What fails: the model calls a deferred tool with no
tool_referencein the transcript, and the call is legal. Two ways this happens: (a) the model calls the tool directly —tooldefer.go:417says the API accepts that ("a tool the model called directly while it was deferred, with no search (the API accepts that)"); (b) an earlier request of the same thread forced the tool withtool_choice, sorewritekept it loaded for that request (tooldefer/rewrite.go:55), the model called it, and the next request defers it again. In both casesUnloadedCallsetsbrokeon!loaded[n]alone, whatever the call's outcome. - Proof: trace for (b): request N carries
tool_choice: {type: tool, name: Workflow}→rewritecallswithoutName(set, "Workflow")→ Workflow goes out loaded → the model calls it → request N+1 defers Workflow again →UnloadedCall(apply.go:237) sees the tool_use with no load →ReasonBreak→Gate.DisableClientmarks the description hash for the tenant, 24 h (apply.go:246, gate.go:218), andSave(..., Record{})un-defers the thread, one cache rewrite. In server-side mode the same two events are harmless. Neither case has a test;TestClientModeBreakDisablescovers only the true break. - Fix: count a break only when the call's own
tool_resultis an error that names the tool as not loaded (the second half of the doc's trigger), or when the call has no result yet and no load anywhere. A call with a successful result means the API accepted it: book it as a use, not a break. Also record the tools atool_choicerequest kept loaded, so their calls never count as breaks.
- What fails: the model calls a deferred tool with no
-
docs/tool-search-matrix.md:13 — the matrix states, as current behavior, a guard that is not in this PR or in its base
- What fails: the Codex gpt-5.5 row says "The proxy adds no
context_guru_tools. Codex's loads count as uses in the history", and line 16 says "the proxy checks the tools, not the model". No such check exists at this head:NativeSearch/NativeLoadslive in commitf6b2a4f0on the unmerged branchfeat/codex-native-876(#876, #897). I verified withgit merge-base --is-ancestor: that commit is in neither the base (47de51a9) nor the head. At this head,ApplySearch→rewriteSearch(tooldefer/clientsearch.go:426) still addscontext_guru_toolsto a Codex request and removes deferred tools — the very behavior that branch's message says draws a 400 from OpenAI ("OpenAI refuses a second tool_search with a 400"). - Proof:
grep -rn '"tool_search' --include='*.go'over the tree finds no tools check outside thetool_search_tool_bm25names;rewriteSearchskips only requests that already hold our ownClientSearchName. - Fix: mark both rows as pending #876/#897, the way the gpt-5.6 row says "Not built yet". Or merge that branch first. As written, an operator reads the matrix and believes Codex requests are left alone; the code at this head changes them.
- What fails: the Codex gpt-5.5 row says "The proxy adds no
-
proxy/tooldefer.go:455 — client-search loads inflate
add_backs, whose documented meaning is "tools added back totools"- What fails:
noteSearchLoads(proxy/tooldefer.go:504) doesAddBacks.Add(len(names)). The new call site feeds it client-searchLoads. A client-search load adds atool_referenceto a message; it adds no tool back totoolsand causes no cache miss ontools. The/statscomment (proxy/tooldefer.go:744) still definesadd_backsas "#825 ... tools it added back (one cache miss ontoolseach)". The counter now mixes two different events. - Proof: apply.go:251 sets
o.LoadsfromAugmentSearches, which only editsmessages(toolsearch.go:215);toolsis untouched afterrewrite. - Fix: count client-search loads in their own counter (or in
wrong_guesses's input, as the comment says the ledger already does for loaded tools), and keepadd_backsfor the #825 path.
- What fails:
Non-blocking
Gate.DisableClient(gate.go:224) skips the once-per-live-mark check forReasonBreak, so every break counts. The Prometheus help text (promexport.go:589) and the/statscomment say "Each counts once per tenant and hash per 24 h". Pick one.docs/data-dependence.md'stoolfilterrow (line 187) was not updated for the newAnswersfield: tool names bytool_useid, kept in the thread record. Same data class (metadata), but the row lists the record's contents in detail and CLAUDE.md asks for it.- The
cg.tooldefer_probelog line (proxy/tooldefer.go:583) is identical for the server probe and the client probe: both log the trimmed route. The two cannot be told apart in the log. AugmentSearchesbooksa.Loads(a use in the history) even when it could not write the answer — the result was an error or an unknown shape (toolsearch.go:204). The tool then counts as used though nothing loaded it.
What I checked
- Read the full diff of all three commits and the whole of every changed file:
tooldefer/apply.go,gate.go,probe.go,rewrite.go,tooldefer.go,toolsearch.go, both test files,proxy/tooldefer.go,proxy/tooldefer_test.go,promexport.go, both docs. - Traced the client-mode decision, the rewrite, the augmentation, the replay and the three disable paths line by line. Checked the fail-open paths: on
Bad, break and panic the original body goes out. - Checked byte stability of the replayed answers, the
max_resultscap, theselect:parsing, and the restart path against the unit tests. - Verified the Codex claim in the new doc against the tree and the git history (
f6b2a4f0not an ancestor of base or head). - Checked boundaries: the new logic lives in
tooldefer, the host wiring inproxy, the probe goes throughdispatch. No violation found. - Did not run builds or tests (not approved). Did not read the PR conversation or the other review, per round 1.
…898) - A break is a deferred tool's own error that says it is not loaded. A direct call that worked is a use (direct_calls). A tool_choice tool never breaks. - Client-mode loads leave DeferredTokens and count as loaded in the ledger. - An errored or unknown result books nothing. - client_loads is its own counter; add_backs stays for the #825 path. - The list weight in client mode is the client list. Probe logs say server or client. - Matrix rows marked "after #897"; data-dependence toolfilter row extended. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
|
Round 1 fixes are in Reviewer 1
Reviewer 2
Tests (box 2, |
Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
Rewrite K1 to K6 for the per-wait ping plan (#867) with a v0.6.6 baseline, add K7 (no sweep question in a tool wait) and K8 (no ping when done), close G1 with wake_cause. Add breaches B5 to B7. Update T4 and the #900 signals. Add the expand-rate section E1 to E3 and gap G9 (no per-component expand count). Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
|
Head
|
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.317 | offload-review skill, @amiddavid's session | resumed | 2 of 2 | 2 of 2 | 937a0724a748 |
approve |
Verdict: approve
Findings
None. All six round-1 findings (mine and reviewer 1's) are fixed. The fixes are correct; I found no new defect in them. Details under "What I checked".
Round-1 findings, resolved
Mine:
- Ledger blind to client-mode loads — fixed. The savings side now merges
Loaded(out)into the loaded set in client mode (apply.go:264-270), so a tool the references load leavesDeferredTokenson the request that writes them and on every replay. The cost side appendsdi.outcome.Loadsto the ledger's loaded names (proxy/tooldefer.go:684), soLoadedTokensandWrongGuessessee the load once, at the request that writes it — the same once-only semantics as a server-side search.TestClientModeWeighsTheLoadcovers the weight drop and the client list. - Errored search result booked a use — fixed.
AugmentSearchesnow checks the result shape first andcontinues on an error or unknown shape before anything is stored or booked (toolsearch.go:178-191). The answer is stored anda.Loadsbooked only when a reference is really written, and only for the names actually added (toolsearch.go:206-218).TestClientModeErrorResultBooksNothingchecksLoads,Answered, the bytes, and that the call stays answerable later. I also re-checked the replay path: the stored set isadd, and the replay writes the same references, so the bytes stay stable. - data-dependence row — fixed. The toolfilter row now names the #898 record (each search call id and the names the proxy added) and the two places where the feature reads result text, in plain words (docs/data-dependence.md:187). The row's deferral decider (David Amid, #485) is the PR author, so the confirmation is the author's own commit; if the team wants it explicit, one line on the PR closes it.
Reviewer 1's (I checked each myself):
- Break rule — fixed, and I verified the new rule end to end.
ReadCalls(toolsearch.go:292-320) setsbrokeonly when a deferred tool's own error result says "not loaded", "no such tool" or "does not exist", and removes that call from the direct set. A call no search loaded that worked is returned asdirectand booked as a use (direct_calls, apply.go:241-250, proxy/tooldefer.go:458-461). A tooltool_choiceforces suppresses the break for that request (forcedAny, apply.go:246, 294-299); the next unforced request still fires it, so nothing is lost.TestClientModeBreakRulecovers the true break, the direct call, the forced call and the good load. - Matrix rows stated unmerged behavior — fixed by the merge. #897 (
dd3cfa6f) is now in main and in this branch (527fdf59).NativeSearch/NativeLoadsare in the tree,ApplySearchreturnsnative_searchand defers nothing, and the matrix rows match the code. I checked the branch footprint against the new base: 13 files, all this PR's; no #897 change is reverted, and the presets.md conflict keeps both the #898 and the #876 sentences. add_backsmixing — fixed. Client-mode loads go tonoteClientLoadsand the newclient_loadscounter;add_backsstays for the #825 path (proxy/tooldefer.go:455-461, 518-524; gate.go). The/statscomment and the matrix name the new fields.
Declined non-blocking items, with reasons I accept:
- Past
maxAnswers, re-booking per request. The recompute is a pure function of the transcript, the historyObserveis idempotent per session; only theclient_loadscounter can inflate, past 256 answered searches in one thread. Rare, stats-only. Accepted. AddKnownDescHashwithout a lock. Test-only writer, read-only in production. Accepted.
Non-blocking
direct_callscounts per request that carries the call, not once per call (the code comment at proxy/tooldefer.go:459 says so; the/statstext does not). A thread with one direct call adds 1 per request. Say "per request" in the/statscomment, or dedupe per thread, asclient_loadsdoes.- The data-dependence row names two error phrases ("not loaded", "does not exist"); the code matches three (
no such tooltoo, toolsearch.go:308). One word in the row. ListTokensin client mode now counts the client list (apply.go:285-287). The firsttokens.Count(NamesList(names))call is dead work there; harmless.
What I checked
- Last review: round 1, dec692d, 2026-11-04T17:20:08Z
- New commits read: 4 —
dd3cfa6ffeat(tooldefer): keep a client's own tool_search on Responses (#897, arrived via the merge),e7302b79fix(tooldefer): round 1 of #900,527fdf59merge origin/main,937a0724docs: resolve the presets.md merge conflict - Read in full: 2 reviews, 2 comments, 0 inline comments (from the three files; the inline file is empty)
- New items since my last review, and what I did about each:
- Reviewer 1's round-1 review (17:22): read in full; verified each of their three findings against the fix commit myself (traces above), not just the author's reply.
- Author comment (17:37, fix summary): checked every claim against the code — break rule, ledger, counters, docs, probe log kind, tests.
- Author comment (17:48, merge note): verified the merge — footprint vs the new base is 13 files, all this PR's; the presets.md conflict keeps both features' sentences; the matrix no longer says "after #897" and its rows match the merged code.
- The fix commit line by line:
ReadCalls(break vs direct, thedeleteon break, the dedup by tool),forcedAny, theAugmentSearchesrestructure (shape check first, store-and-book only on a real write, theknownreplay path, byte stability of the replayed round), the weigh fix (Loaded(out)merge), the client list weight,noteClientLoads/DirectCallsbooking, the ledger append, the/statsand Prometheus text. - The #897 code that arrived with the merge (
NativeSearch,NativeLoads, thenative_searchbranch, the native-loads history booking, both test files): read as new code; no defect found. - Fail-open paths re-checked after the restructure:
Bad, break, error shape, and the sjson error path each return the un-augmented body; the break path still changestoolsonce, as documented. - No Go builds or tests were run (not approved; Go is not on this machine). The author's box-2
-raceruns and the mutation check are reported in the PR comments; I read them but did not re-run them.
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.317 | offload-review skill, @amiddavid's session | resumed | 1 of 2 | 2 of 2 | 937a0724a748 |
approve |
Verdict: approve
No new blocking finding. All 6 findings from round 1 (3 mine, 3 reviewer 2's) are fixed and verified in the code.
Earlier findings
Mine, round 1
- Break false positive (toolsearch.go:286) — fixed in
e7302b79. Verified:ReadCalls(toolsearch.go:292) setsbrokeonly when the call's owntool_resulthasis_errorand its text says "not loaded", "no such tool" or "does not exist".- A worked direct call goes to
o.Directand thedirect_callscounter, not to the break. forcedAny(apply.go:296) keeps atool_choice-forced tool from breaking.- Tests cover the true break, the direct call, the call after
tool_choice, and the good load (TestClientModeBreakRule).
- Matrix rows ahead of unmerged code (docs/tool-search-matrix.md:13) — fixed. The base is now
dd3cfa6f, which holds #897.NativeSearchandNativeLoadsare in the tree (tooldefer/clientsearch.go:712, 729). The rows no longer say "after #897". The claims match the code. add_backsconflation (proxy/tooldefer.go:455) — fixed. Client-mode loads count in the newclient_loadscounter (noteClientLoads).add_backsstays with the #825 path. The/statscomment and the Prometheus help text state the split.
Reviewer 2, round 1 (verified on my own, not repeated as findings)
- Ledger — fixed.
weighmergesLoaded(out)whenrec.Client(apply.go:264-270), so a client-mode load leavesDeferredTokens.deferLedgerappendsdi.outcome.Loadsas loaded names.ListTokenscountsClientToolNamesListin client mode (apply.go:285-287). Test:TestClientModeWeighsTheLoad. - Errored result books tools — fixed.
AugmentSearcheschecks the result shape first (toolsearch.go:181-191): only the no-match text or an all-refs array is extended; any other shapecontinues with nothing stored or booked. The answer is kept only when a reference is really written (toolsearch.go:206-218). Test:TestClientModeErrorResultBooksNothing. - Data-dependence row — fixed. The toolfilter row now names the answers record and the two places the feature reads result text, in plain words.
Author's two "not changed" calls — accepted. Both are test-only concerns (maxAnswers recompute past 256; AddKnownDescHash without a lock, exported for tests).
Non-blocking
forcedAnyreads only this request'stool_choice. A break on one tool in the same request that forces another deferred tool goes unseen. The next request without the force catches it. Detection is delayed one turn at most.- The data-dependence row names the error texts "not loaded" or "does not exist".
ReadCallsalso matches "no such tool" (toolsearch.go:308). One phrase missing in the doc. applyClientSearchre-booksNativeLoadson every request that carriestool_search_outputitems. Booking is idempotent, so only the history write repeats.
What I checked
- Last review: round 1,
dec692db349c22b26ccf6a6038b8cd5d55a69737, 2026-11-04T17:22:04Z. - New commits read: 4 —
dd3cfa6ffeat(tooldefer): keep a client's own tool_search on Responses and defer nothing there (#876) (#897);e7302b79fix(tooldefer): round 1 of #900: break rule, ledger, counters, docs (#898);527fdf59merge origin/main into feat/client-search-b;937a0724docs: resolve the presets.md merge conflict. - Read in full: 2 reviews, 2 comments, 0 inline comments.
- New items since my last review: the 4 commits above, the author's two replies, and the merge of #897 into the base. For each I read the full diff
dec692db..HEAD(640 lines) and the final state of the changed files; for each round-1 finding I traced the fix in the code; for the merge I checked thatpresets.mdkeeps both the #898 row text and #897's sentence, and that no #897 file was reverted (git diff --stat dd3cfa6f..HEAD: 13 files, all from this PR). - The new code in
e7302b79I reviewed as a first review:ReadCalls,forcedAny, theAugmentSearchesrework, the ledger merge, the new counters and their help texts, and the tests. No new blocking defect. - No Go builds or tests were run (not approved; Go is not on this machine). The author reports them green on box 2 with
-race.
mkdocs build --strict fails when a page is not in nav. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
|
Head |
|
Head
|
Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
Refs #898 (step 2, Claude Code only). Design: #898 comment. Matrix: docs/tool-search-matrix.md.
Behavior change (needs a human's yes)
ultrahighusers on a Claude model, when the request has Claude Code's ownToolSearch. New threads only.tool_search_tool_bm25next toToolSearch. Two search tools.ToolSearch. The proxy addstool_referenceblocks for its own deferred tools to Claude Code'sselect:result. One search tool.ToolSearchin the request: the server-side search stays. A live thread keeps its mode.toolfilter: {defer: off}orENABLE_TOOL_SEARCH=false. The mode also turns itself off (see Disable).Data dependence change
toolfilterrow indocs/data-dependence.mdchanges (data dependence goes up a little, still no stored customer text).ToolSearchresult in two places: the "No matching deferred tools found" text, and the "not loaded" / "no such tool" / "does not exist" error.Summary
ToolSearchcall goes to Claude Code as today. On the next request, the proxy appendstool_referenceblocks for its own deferred tools to thetool_result. Claude Code's own result stays.select:Name1,Name2form is read. Every other query passes through.Facts from live probes (benchmark gateway, nonce per request)
{"query","max_results"}(default 5), from 78 real captures.tool_reference. Plain clientToolSearch, onedefer_loadingtool, no server-side search: 200, and the model called the tool. A text-only result did not expand.select:<unknown>gives the textNo matching deferred tools found. Inselect:Known,Unknownthe unknown name is dropped without a note.select:in any case (Select:), names split on,, each trimmed (select:A, Bworks), capped atmax_results. The proxy accepts the same.88033eceb421f1c2) over 109 captures.Disable, never switch
The proxy marks the hash of
ToolSearch's description as disabled throughGate(ClientDisabled,DisableClient: same shape, TTL 24 h and caps asBreak). It never falls back to another search tool.unknown_descriptionknownDescHashes). The thread defers nothingnon_select_query_for_our_toolselect:breakdirect_calls), not a break. A tool thattool_choicekept loaded never breakstoolschanges once: one cache rewrite. New threads defer nothing until the mark expires.knownDescHashes.tool_referencefor this model". The hash list covers the syntax.For production monitoring
cg_tooldefer_client_disabled_total{reason="unknown_description"|"non_select_query_for_our_tool"|"break"}/stats:tool_defer.client_search_disabled={unknown_description, non_select_query_for_our_tool, break}cg.tooldefer_client_search_disabledwithreason,desc_hash(8 chars),session,thread. No query text.What changed
tooldefer/toolsearch.go:AugmentSearches,selectNames,DescHash,UnloadedCall, client probe.tooldefer/gate.go: disabled marks and counters.RecordgetsClientandAnswers.Apply: the mode choice, the disable paths.Rewriteadds no server-side search in the mode.proxy/tooldefer.go,proxy/promexport.go: probe, log,/stats, metric.docs/tool-search-matrix.md(new), one sentence indocs/reference/presets.md.How it was tested
Box 2, fresh tar sync into an empty dir, foreground,
-race:./tooldefer/... ./apply/...ok;./proxy/...ok (520 s).Unit tests:
ToolSearch; it stays without it or with an unknown client probeselect:of ours is appended;Select: A; mixed with the client's own (cap kept); error results untouchedMutation check: reading the stored list is turned off.
TestClientModeReplaysByteForByteAfterRestartfails. Restored.Data dependence
See "Data dependence change" at the top. The
toolfilterrow indocs/data-dependence.mdis extended. Storage: the thread record keeps each search call id and the tool names the proxy added. Nothing else is stored. Reading: the no-match text and the "not loaded" error text of aToolSearchresult, in the request only. Query text and result text are not kept.Technical notes
direct_calls). A tooltool_choicekept loaded never breaks.Base
#897 has merged. This branch contains it (merged from main), and the matrix no longer says "after #897".
Open questions
Select:and spaces are accepted because Claude Code does. A change in that rule shows up as a miss, not as a disable.🤖 Generated with Claude Code
EOF
python3 -I -c "
import json;print(json.dumps({'body':open('/tmp/client-search-b-body.md').read()}))" > /tmp/client-search-b-body.json
gh api -X PATCH repos/rossoctl/context-guru/pulls/900 --input /tmp/client-search-b-body.json --jq '.body[:80]'