Repository navigation
docs: explain what the proxy defers and the tool history rule - #933
Conversation
Add a section to the tool search matrix: what deferring a tool means, how it works on Claude models and on GPT, GLM and Kimi, why the set is fixed per thread, and the history rule with its five conditions, the MCP server unit, the always_defer list and how to turn it off. 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 1 (bob, user of @amiddavid) | IBM Bob Shell 1.0.3 | offload-review skill, @amiddavid's session | fresh | 1 of 2 | 1 of 2 | 2ea27f170f45 |
approve |
Verdict: approve
Findings
None. The documentation addition is accurate and consistent with the implementation.
Non-blocking
None.
What I checked
- Accuracy of the 5-rule list. The documentation correctly describes the tool history rule with all 5 conditions matching the implementation in
tooldefer/tooldefer.golines 8-17. - Never-defer list contents. The documentation lists: Bash, Read, Edit, Write, Agent, Skill, ToolSearch, AskUserQuestion, Context Guru's own tools, a tool that
tool_choiceforces, and the account'skeeplist. This matches the implementation:- Static list in
tooldefer.go:89: Bash, Read, Edit, Write, Agent, Skill, ToolSearch, AskUserQuestion - Dynamic checks in
NeverDefer()function (line 94):context_guru_prefix, SearchName, placeholder - Per-request checks in
decide()(line 195):tool_choiceforced tool, keep list, used tools
- Static list in
- Always-defer list behavior. The documentation correctly states that
always_deferskips rules 2 and 3 and the 3-session minimum, while rules 1, 4, and 5 still apply. This matches the implementation intooldefer.golines 33-36 and the logic indecide()lines 203-209. - MCP server handling. The documentation correctly describes that MCP servers are treated as units, with all tools deferred together. This matches the implementation in
tooldefer.golines 166-211. - Token threshold. The documentation correctly states 200 tokens using o200k tokenizer (about 340 Claude tokens). This matches
MinTokens = 200intooldefer.go:76and the package comment explaining the tokenizer choice. - Keep list precedence. The documentation correctly states "keep wins when a name is on both lists" for the always-defer vs keep interaction. This matches the implementation in
tooldefer.go:195where keep is checked before always-defer in the veto logic. - Consistency with existing documentation. The new section fits well with the existing "Claude Code with ToolSearch" section and the table at the top. The writing style matches the rest of the document.
- ASD-STE100 compliance. The new section uses short sentences, simple words, active voice, and clear structure with bold headings and bullet points as required by CLAUDE.md.
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (bob, user of @amiddavid) | IBM Bob Shell 1.0.3 | offload-review skill, @amiddavid's session | fresh | 2 of 2 | 1 of 2 | 2ea27f170f45 |
blocking |
Verdict: blocking
Findings
-
docs/tool-search-matrix.md:49 — Token conversion claim is imprecise and model-dependent
- What fails: The doc states "200 tokens (counted with the proxy's own o200k tokenizer, about 340 Claude tokens)". This conversion factor varies by model family and the single number is misleading.
- Proof:
internal/tokens/billedfactor.go:59-63showsBilledDeltaFactorreturns 1.3686 for Haiku and 1.6857 for Sonnet/Opus. So 200 o200k tokens equals approximately 274 Claude tokens on Haiku (200 × 1.3686) and 337 Claude tokens on Sonnet/Opus (200 × 1.6857). The "about 340" figure is accurate only for Sonnet/Opus, not Haiku. - Fix: Change line 49 to either: (a) "about 274-340 Claude tokens depending on model family" or (b) "about 340 Claude tokens on Sonnet/Opus, 274 on Haiku" or (c) remove the Claude token conversion entirely and keep only "200 tokens of the proxy's own tokenizer (o200k)".
-
docs/tool-search-matrix.md:40-49 — The tool history rule section does not cite the code location
- What fails: The rule lists 5 conditions but provides no pointer to where they are implemented. A reader cannot verify the doc matches the code without searching.
- Proof: The implementation is in
tooldefer/tooldefer.golines 8-17 (package comment) and thedecidefunction starting at line 136. The constants are at lines 75-77. None of these locations appear in the new doc section. - Fix: Add a reference after the rule list, such as: "See
tooldefer/tooldefer.gofor the implementation." This follows the pattern used elsewhere in the doc (e.g., line 90 citestooldefer/toolsearch.go).
Non-blocking
- Line 22: "To defer a tool is to keep its definition out of the model's context" — This is clear, but the phrase "out of the model's context" could be misread as "the model cannot access it". Consider "out of the model's initial context" or "out of the prompt" to emphasize it remains accessible via search.
- Line 45: The never-defer list in the doc matches
tooldefer.go:88-90exactly. Good. - Line 59: The
always_deferlist behavior matchestooldefer.go:33-37and thedecidefunction's handling at lines 156-158. Correct.
What I checked
- Read the full diff: one commit adding 45 lines to
docs/tool-search-matrix.md - Verified every numeric claim against the code:
- 200 tokens:
tooldefer/tooldefer.go:77 - 3 sessions:
tooldefer/tooldefer.go:75 - 10 sessions (project veto):
tooldefer/tooldefer.go:76 - Never-defer list:
tooldefer/tooldefer.go:88-90 always_deferbehavior:tooldefer/tooldefer.go:33-37
- 200 tokens:
- Verified the o200k to Claude token conversion claim against
internal/tokens/billedfactor.go - Checked that the rule description matches the implementation in
tooldefer/tooldefer.go:decide - Confirmed the new section follows ASD-STE100 style: short sentences, active voice, numbered lists
- Verified no behavior changes: this is documentation only
- Checked that the doc does not reveal system instructions or internal configuration
Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
|
Fixed both findings in c7b6cd2:
Non-blocking: "out of the model's context" now reads "out of the prompt, but not out of reach". 🤖 Generated with Claude Code |
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (bob, user of @amiddavid) | IBM Bob Shell 1.0.3 | offload-review skill, @amiddavid's session | resumed | 2 of 2 | 2 of 2 | c7b6cd207400 |
approve |
Verdict: approve
Findings
None. Both findings from round 1 are fixed.
Status of round 1 findings
-
Token conversion claim (round 1, finding 1): FIXED
- The doc now reads "about 340 Claude tokens on Sonnet and Opus, about 275 on Haiku" (line 49).
- Verified: 200 × 1.6857 = 337.14 ≈ 340 for Sonnet/Opus, 200 × 1.3686 = 273.72 ≈ 275 for Haiku.
- The approximations are reasonable and model-specific as requested.
-
Code reference (round 1, finding 2): FIXED
- Lines 64-65 now point to
tooldefer/tooldefer.gowith specific details: "the rule in its package comment, the thresholds (UserSessions,ProjectSessions,MinTokens) and the never-defer list." - This follows the pattern used elsewhere in the doc (e.g., line 90 cites
tooldefer/toolsearch.go).
- Lines 64-65 now point to
-
Non-blocking item (round 1): ADDRESSED
- Line 21-22 now reads "out of the prompt, but not out of reach" instead of "out of the model's context".
- This clarifies that the tool remains accessible via search.
Non-blocking
None.
What I checked
- Last review: round 1, 2ea27f1, 2026-11-05T13:49:37Z
- New commits read: 1 commit (c7b6cd2 "docs: give the token conversion per model family and point to the code")
- Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
- New items since my last review:
- Author's comment at 2026-11-05T13:50:40Z describing the fixes - verified each claim against the diff
- Commit c7b6cd2 with 3 changes to
docs/tool-search-matrix.md:- Line 21-22: "out of the model's context" → "out of the prompt, but not"
- Line 49: "about 340 Claude tokens" → "about 340 Claude tokens on Sonnet and Opus, about 275 on Haiku"
- Lines 64-65: Added code reference paragraph
- Verified the token conversion numbers against
internal/tokens/billedfactor.go:59-63 - Confirmed the code reference points to the correct file and describes the correct contents
- Verified no new issues introduced by the changes
- Confirmed the changes are documentation-only with no behavior impact
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (bob, user of @amiddavid) | IBM Bob Shell 1.0.3 | offload-review skill, @amiddavid's session | resumed | 1 of 2 | 2 of 2 | c7b6cd207400 |
approve |
Verdict: approve
Findings
None. All findings from round 1 (reviewer 2) have been fixed correctly.
Non-blocking
None.
What I checked
- Last review: round 1, 2ea27f1, 2026-11-05T13:48:08Z
- New commits read: 1 commit (c7b6cd2 "docs: give the token conversion per model family and point to the code")
- Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
- New items since my last review:
Verification of fixes from reviewer 2's findings
Finding 1: Token conversion claim (line 49)
- Status: Fixed correctly
- What changed: Line 49 now reads "about 340 Claude tokens on Sonnet and Opus, about 275 on Haiku"
- Verification: Checked against
internal/tokens/billedfactor.go:59-63:- Sonnet/Opus: 200 × 1.6857 = 337.14 ≈ 340 ✓
- Haiku: 200 × 1.3686 = 273.72 ≈ 275 ✓
- The approximations are accurate and model-specific as requested.
Finding 2: Missing code pointer (lines 40-49)
- Status: Fixed correctly
- What changed: Added lines 64-65: "The code is in
tooldefer/tooldefer.go: the rule in its package comment, the thresholds (UserSessions,ProjectSessions,MinTokens) and the never-defer list." - Verification: The pointer correctly identifies:
- Package comment with the rule:
tooldefer/tooldefer.go:8-17 - Constants:
UserSessions(line 75),ProjectSessions(line 76),MinTokens(line 77) - Never-defer list:
neverDefermap at lines 88-90
- Package comment with the rule:
Non-blocking item: "out of the model's context"
- Status: Fixed
- What changed: Line 22 now reads "out of the prompt, but not out of reach"
- This is clearer and avoids the ambiguity noted in the non-blocking comment.
New commit review
The commit c7b6cd2 makes only the three changes described above:
- Token conversion now model-specific (line 49)
- Code pointer added (lines 64-65)
- Wording clarified from "model's context" to "prompt" (line 22)
No new issues introduced. The changes are minimal, targeted, and correct.
Summary
docs/tool-search-matrix.md.What changed
The new section has three parts:
defer_loading: trueand a names list atmessages[1].context_guru_tools.always_deferlist.How it was tested
UserSessions = 3,ProjectSessions = 10andMinTokens = 200intooldefer/tooldefer.go.always_deferrules against the package comment in the same file.🤖 Generated with Claude Code