Commit 3dde9b2
committed
fix(agent): bill the context popover for the tool list that was actually sent
Both review points on #78 were right.
1. THE TOKEN ESTIMATE STILL COUNTED THE FULL TOOL LIST
`toolsTokensEst` falls back to a module constant on the plain path (no MCP, no recall) so
that path never re-stringifies. But that constant was built from TOOLS, and after this PR
there are TWO plain paths — a rootless run sends PORTABLE_TOOLS and was billed for TOOLS.
Measured: ~1000 tokens, about two thirds of the tool budget, reported against a window
that never spent it. That is worse than a missing feature; it is a meter reading high, and
the context popover exists precisely so that number can be trusted.
This is the same mistake as leaving baseTools on TOOLS, one line further down — which I
fixed, described in the PR body, and then missed here. PORTABLE_TOOLS_TOKENS_EST is a
second constant rather than a call-time derivation, because keeping the plain path free of
JSON.stringify is the whole reason the constant exists.
2. THE TEST DID NOT PIN read_command_output
It asserted seven of the eight gated tools. read_command_output was the omission, and it is
the plausible one to lose: it takes no path and reads as portable at a glance, so nothing
would have objected to un-gating it. Rootless it can only ever refer to a background
run_command that could not have started.
Guards, each bypass-verified by reverting the fix:
- read_command_output un-gated (the second review point)
- the estimate reverting to the full-TOOLS constant (the first)
- the estimate no longer switching on the root; the rootless estimate deleted
- PORTABLE_TOOLS no longer a filtered subset, which would make the estimate guard vacuous
6 tests in agentNoWorkspace, 33 suites green.1 parent b82f726 commit 3dde9b2
2 files changed
Lines changed: 35 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
89 | 94 | | |
90 | 95 | | |
91 | 96 | | |
| |||
756 | 761 | | |
757 | 762 | | |
758 | 763 | | |
759 | | - | |
760 | | - | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
761 | 769 | | |
762 | 770 | | |
763 | 771 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
59 | 64 | | |
60 | 65 | | |
61 | 66 | | |
| |||
82 | 87 | | |
83 | 88 | | |
84 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
85 | 109 | | |
86 | 110 | | |
87 | 111 | | |
| |||
0 commit comments