Repository navigation
fix: key the usage cache by the request and keep warm reads cheap - #2239
Conversation
yyhhyyyyyy
left a comment
There was a problem hiding this comment.
This follow-up closes two gaps left by the tool-mode merge: the usage fixed-cost cache key now covers the whole ToolDefinition, and the execStop face that #2206 orphaned is removed, with ShellSession.md aligned to the current injects.
What I verified at 592f0d7
cargo run --locked -p xtask -- checkpasses: module and crate boundaries, access layer (172), service declarations, plugin locks, 45 plugin documents.- Re-adding
("execStop", "control")in a local worktree reproduces main's exact failure,Error: "execStop: internal(control) names no catalog service".session.exec.stopnow callsBackgroundExec(crates/dim-app-server/src/connection.rs:1627-1632), so the entry is dead, not hidden. cargo fmt --checkis clean;cargo clippy -p dim-agent-capabilities --lib --tests --locked -- -D warningsis clean.- The new unit test passes, and the nearest flow test,
capabilities_flowtestcontext_flow::context_reads::usage_reuses_counted_messages_and_current_registry_tools_without_extra_state_writes, still passes, so ready reads still reuse the fixed contribution. - Fingerprint stability: the key is SHA-256 over
serde_jsonof the definitions, and the tool vector and source order are deterministic (BTreeMap). Different declarations cannot share a key in practice. Extra misses are possible when onlysource,risk,metadataorfileChangeschange; that is conservative, never a stale hit. - Reachability of the stated stale hit is narrow:
crates/dim-agent-capabilities/src/tool_registry.rs:651-655rejects a reused source version, andcrates/dim-agent-capabilities/src/context_preparation.rs:78-82,238-245republishescontext/configuredwhensettings.toolsortool_sourceschange, which changes the configuration event id. The change is still the right alignment with whatContextCounter::fixedconsumes (crates/dim-agent-capabilities/src/host.rs:1351-1357), but it is defense in depth rather than a reachable bug fix.
Findings
-
(P3, inline on
context_usage.rs:1472) The new unit test does not pin the production cache key; it passes with the old(name, description)mapping restored. The nearest flow test is the place for it. -
(P3)
ShellSession.mdstill describes the pre-#2206 split.
- Problem: the rewritten intro says a stop resolves through
BackgroundExec, but the page still says ShellSession "owns ... the background jobs" (docs/architecture/rust-agent/plugins/ShellSession.md:11-12) and givesB:BackgroundExeconly the recovery purpose (:20). After #2206, BackgroundExec registers every shell task, owns its terminal, wake and notices, and is the one stop entry; ShellSession owns the shell, the command queue and the handoff. - Failure scenario: a later change reads the row as recovery-only and adds shell stop or job cleanup in ShellSession, reviving the two-provider stop route #2206 removed.
- Evidence:
docs/architecture/rust-agent/plugins/ShellSession.md:11-12,20;docs/design/shell-exec-recovery.md:3-6,20-23;docs/architecture/rust-agent/plugins/WorkspaceTools.md:649-654;crates/dim-agent-capabilities/src/shell_session.rs:258,990,1091;crates/dim-app-server/src/connection.rs:1627-1632. - Fix: say ShellSession owns the shell, the command queue and the foreground-to-background handoff, and give the row its actual use, for example "Register every shell task, own its terminal, wake and stop, and settle abandoned facts."
Other checks
- No Chinese translation mentions
ExecStop. The only remaining Englishdyn ExecStopclaim is the historical recorddocs/design/research/1295-host-platform-task-owner.md:331; its own section 7.3 note, added by #2206, supersedes it. Optional cleanup, not blocking. - No conflict with open PRs: #2227 and #2225 touch
crates/dim-app-server/src/lib.rsin other regions; no open PR touchescontext_usage.rsorShellSession.md. - CI at review time: macos-native and windows-cli pass, verify (linux) pending.
| .unwrap(); | ||
| let before = fingerprint(&vec![plain]).unwrap(); | ||
| let after = fingerprint(&vec![typed]).unwrap(); | ||
| assert_ne!(before, after, "a schema-only change changes the cache key"); |
There was a problem hiding this comment.
P3: this test cannot fail when the production change is reverted.
Problem: It calls fingerprint directly, so it only proves that a ToolDefinition serializes its schema. It never exercises the cache key at crates/dim-agent-capabilities/src/context_usage.rs:1112. I reverted :1112 to the previous (name, description) mapping and this test still passed. AGENTS.md:70 also puts assertions about a private helper in the nearest flow test, not in a standalone unit test.
Failure scenario: a later change, or a revert of the one line, restores the name/description key while this test stays green. A schema-only declaration change under an unchanged source digest then reuses the previous request's fixed cost and mis-prices usage, which is the regression the PR says it pins.
Evidence: crates/dim-agent-capabilities/src/context_usage.rs:1112 (production key), :1458-1472 (test calls fingerprint directly). The nearest flow test is crates/dim-agent-capabilities/tests/context_flow/context_reads.rs:3419.
Fix: extend that flow test: change a declared tool between two reads under one configuration and assert the fixed contribution is recomputed. If no reachable path exists, delete this unit test and say in the PR that the key is defense in depth.
There was a problem hiding this comment.
Not fixed in 5418a38. The new flow test exercises the production read path, but it still passes with the old (name, description) key restored (verified locally at 5418a38): the schema transition at crates/dim-agent-capabilities/tests/context_flow/context_reads.rs:5899-5909 also bumps the source version, which changes the outer sources summary (crates/dim-agent-capabilities/src/context_usage.rs:1107-1113) and forces the miss before the tool key matters. The test pins the behavior, not the key, and because the two keys are behaviorally identical on every reachable change I am not asking for another key-pinning test. What is still missing is the warm-read cost: request_tools selects data.request.tools and deserializes it before the cache check (crates/dim-agent-capabilities/src/context_usage.rs:1066,1095,1114-1133), so a warm reread still materializes, clones and parses the full declaration list. The review body has the P2 and the fix.
zerob13
left a comment
There was a problem hiding this comment.
Both intended fixes are present: schema-only changes can no longer reuse the old fixed cost, and the orphaned ExecStop mark is gone while shell Stop still routes to BackgroundExec. The exact CI run passed Linux, macOS, Windows and ci-ok.
Remaining acceptance condition: Repeated usage reads of the same request must reuse the fixed cost without serializing its tool schemas again, while the first request with a changed schema must use the new cost. The current cache path hashes the full declaration list before the cache lookup. This adds serialization proportional to total schema size on each warm read, contrary to the ContextUsage reuse contract. Verify one warm reread and one schema-only transition through the production path; the standalone hash test does not exercise either lookup. This is a static finding, not a measured latency claim.
The independent catalog fix is ready from this review's perspective and could land separately to unblock main.
|
Cache key. Production-path test. The standalone hash test is gone. The catalog fix (orphaned |
yyhhyyyyyy
left a comment
There was a problem hiding this comment.
This follow-up removes the orphaned execStop face and moves the usage fixed-cost key from the tool declarations to the last request. The catalog half is ready. The usage half still has one blocking gap: a warm reread materializes and parses the full request tool list before it checks the cache.
Verified at 5418a38
cargo run --locked -p xtask -- checkpasses, including the runtime-assembled catalog;cargo fmt --all --checkandcargo clippy --locked -p dim-agent-capabilities --lib --tests -- -D warningsare clean.- The new
usage_reuses_a_warm_request_and_prices_a_changed_tool_schemaand the nearest existing test,usage_reuses_counted_messages_and_current_registry_tools_without_extra_state_writes, pass. - The new test drives
ContextPreparation.usageinto the productionContextUsagepath (crates/dim-agent-capabilities/src/context_preparation.rs:871-876) and covers a first request, two warm rereads and a source version change. - The key is scoped correctly:
position.sequenceis the event's per-branch sequence,ContextUsageanddynamic_fixedare branch-scoped (crates/dim-agent-capabilities/src/defaults.rs:147-153,crates/dim-agent-capabilities/src/context_usage.rs:276-290), and the sources key/version summary is still in the key (crates/dim-agent-capabilities/src/context_usage.rs:1107-1113). Two tool sets cannot sharerequest:<sequence>across Sessions, branches or restarts. - Repeated reads of one request reuse the cached fixed number without calling
counter.fixed; the first request after a changed schema recomputes it. That half of the changes-requested condition holds.
P2: a warm reread still materializes and parses the request tool schemas
- Problem:
request_toolsselectsdata.request.tools(crates/dim-agent-capabilities/src/context_usage.rs:1066); the query projects that field into aserde_json::Value, and the in-memory query path serializes the selected field (crates/dim-agent-runtime/src/memory_timeline_store/query.rs:23-24,859-870,crates/dim-agent-runtime/src/event_property.rs:129-142);request_toolsclones the value (crates/dim-agent-capabilities/src/context_usage.rs:1087) and deserializes it intoVec<ToolDefinition>(:1095) beforecurrent_toolschecks the cache (:1114-1133). On a hit every one of those allocations is discarded. The commit message's "Warm reads no longer serialize the declaration list" does not hold for this path, anddocs/design/plugins/ContextUsage.md:61asks for the fixed number to be reused without re-serializing the tools. - Failure scenario: a client polls
session.context.usageon a Session with a large MCP tool catalog. Every poll materializes, clones and parses the full schema set, which can be hundreds of KB, although the fixed contribution is cached. The read stays proportional to schema size, which is exactly the cost the fix was meant to remove. - Evidence:
crates/dim-agent-capabilities/src/context_usage.rs:1066,1081-1098,1114-1133;crates/dim-agent-runtime/src/memory_timeline_store/query.rs:23-24,859-870;crates/dim-agent-runtime/src/event_property.rs:129-142;docs/design/plugins/ContextUsage.md:61. - Fix: query only
position.sequencefor the lastmodel/callfirst and check the cache; readdata.request.toolsonly on a miss.request:<sequence>is already the identity, so the tools are not needed on a hit. Thelive:<hash>fallback can stay.
Round 1 findings
-
P3(a), the key-pinning test: not fixed as stated. The flow test is in the right place and covers the behavior, but it passes with the old
(name, description)key restored; I verified this locally at 5418a38. The schema transition atcrates/dim-agent-capabilities/tests/context_flow/context_reads.rs:5899-5909also bumps the source version, which changes the outer sources summary (crates/dim-agent-capabilities/src/context_usage.rs:1107-1113) and forces the miss before the tool key matters. It pins behavior, not the key. Since the old and new keys are behaviorally identical on every reachable change, I withdraw the request for a key-pinning behavior test; the cost gap above is the remaining actionable part. -
P3(b),
ShellSession.md: partially fixed. The staleExecStopand fallback wording is gone. Two lines still describe the pre-#2206 split:docs/architecture/rust-agent/plugins/ShellSession.md:11-12says the part owns "the background jobs", and:20givesB:BackgroundExeconly the recovery purpose, whilecrates/dim-agent-capabilities/src/shell_session.rs:221-222,1089-1091callsbackground.startfor every explicit background job and foreground timeout, anddocs/design/shell-exec-recovery.md:3-4says BackgroundExec registers the task and publishes its terminal. Optional P3: say ShellSession owns the shell, queue and handoff, and give the row its actual use.
Other checks
- The
execStopremoval is complete: no code or catalog entry remains, andsession.exec.stoproutes toBackgroundExec(crates/dim-app-server/src/connection.rs:1627-1633). The historical record atdocs/design/research/1295-host-platform-task-owner.md:331is superseded by its own 7.3 note; optional cleanup, not blocking. - Before the first request, every read still hashes the full live definitions (
crates/dim-agent-capabilities/src/context_usage.rs:1116-1119); the contract allows that fallback and product paths end it at the first request, so I do not block on it. Amodel/callwhose request hastools: Nonealso takes the fallback because the row shape requires both values; both production prepare hosts declareSome(crates/dim-agent-capabilities/src/adapters.rs:242,crates/dim-agent-aimux/src/plugin.rs:372), so this is not reachable today and predates the PR. - The PR description is stale: it still says the key fingerprints the whole
ToolDefinitionand that the deleted unit test pins it. - Cross-PR: #2206 and #2197 are in main 06f1402. #2226 and #2234 do not touch these files. #2227 rewrites the same
ShellSession.mdlines and deletes the sameexecStopline, so the two will conflict on the page; whichever lands second should drop its duplicate. #2225 touches only the top oflib.rs. - CI at review time: macos-native, windows-cli, verify (linux) and ci-ok pass; static-checks and the other path-filtered jobs are skipped.
The catalog fix can land as is. The usage read needs the sequence-only first query to meet the acceptance condition.
| }), | ||
| select: QuerySelect::Fields { | ||
| fields: vec!["data.request.tools".into()], | ||
| fields: vec!["data.request.tools".into(), "position.sequence".into()], |
There was a problem hiding this comment.
P2: this select still materializes and parses the request tool schemas on every warm reread.
Problem: request_tools reads data.request.tools here; the query projects it to a serde_json::Value, serializing the selected field on the in-memory path (crates/dim-agent-runtime/src/memory_timeline_store/query.rs:23-24,859-870; crates/dim-agent-runtime/src/event_property.rs:129-142); request_tools clones and deserializes it (crates/dim-agent-capabilities/src/context_usage.rs:1087,1095) before the cache check at :1114-1133. On a hit the work is discarded, so the read cost stays proportional to the whole declaration list.
Failure scenario: a client polls session.context.usage on a Session with a large MCP tool catalog; each poll materializes, clones and parses the full schema set even though request:<sequence> already identifies the cached fixed cost.
Evidence: crates/dim-agent-capabilities/src/context_usage.rs:1066,1081-1098,1114-1133; docs/design/plugins/ContextUsage.md:61.
Fix: query only position.sequence first and check the cache; select data.request.tools only on a miss.
There was a problem hiding this comment.
Fixed in c6e3d52. current_tools now queries only position.sequence (crates/dim-agent-capabilities/src/context_usage.rs:1048-1088), checks the fixed cache (:1160-1170), and reads and parses data.request.tools only on a miss (:1171-1177); the live:<hash> fallback is unchanged (:1151-1158). On the SQLite store the position-only selection is served without decoding the event body (crates/dim-app-server/src/storage/query.rs:2552-2577). Both flow tests pass.
|
P2, warm-read cost. P3(b), ShellSession. The page now says the part owns the shell, the queue and the handoff, and the P3(a). Withdrawn on your side; the flow test stays as behavior coverage. The PR body is rewritten to the current state. |
zerob13
left a comment
There was a problem hiding this comment.
The previous acceptance items are closed: warm reads now use only the published request sequence, and the next request with a changed schema is priced correctly. The exact CI run is green.
Keep the fixed tool cost tied to what the request actually declared. In context_usage.rs, when a published request omits tools but the live registry has declarations, the cold read uses those declarations and caches their cost under that request's sequence. The fallback predates this revision; binding its result to the recorded request is new. This overstates the usage of a request that sent no declarations, contrary to the documented contract. Static finding. Acceptance: with a populated registry and a published request that omits tools, both the first read and a repeat read count no tool declarations; the repeat still does not project the schema. Before any request is published, the live registry remains the fallback.
yyhhyyyyyy
left a comment
There was a problem hiding this comment.
The follow-up now does what it says. The warm usage read checks the last request's position and the fixed cache before it touches the declaration list, and the ShellSession page matches the post-#2206 split. Both round 2 findings can be withdrawn. I found one optional test gap and no blocking issue.
Verified at c6e3d52
cargo run --locked -p xtask -- checkpasses (module and crate boundaries, access layer 172, service declarations, plugin locks, comment links, 45 plugin documents).cargo fmt --all -- --checkis clean.usage_reuses_a_warm_request_and_prices_a_changed_tool_schemapasses, and the nearest existing testusage_reuses_counted_messages_and_current_registry_tools_without_extra_state_writesstill passes.- I reverted c6e3d52 in the review worktree and reran both tests: both still pass. The tests pin behavior, not the read path; see the optional P3 below.
Round 2 P2: fixed, withdrawn
- The warm path calls
request_position(crates/dim-agent-capabilities/src/context_usage.rs:1048-1088), which selects onlyposition.sequence. The cache check at:1160-1170returns the cached fixed number.data.request.toolsis selected and parsed only on a miss (:1171-1177), and thelive:<hash>fallback is unchanged (:1151-1158). request:<sequence>cannot pair a fixed number with another request: the cache slot is branch scoped (crates/dim-agent-capabilities/src/context_usage.rs:280,1420;crates/dim-agent-capabilities/src/defaults.rs:147-153), a branch sequence is unique, and the version string still carries the sources summary (crates/dim-agent-capabilities/src/context_usage.rs:1144-1150,1159).- On the production SQLite store, a position-only selection is answered from the index without decoding the event body (
crates/dim-app-server/src/storage/query.rs:2552-2577), so a warm read no longer pays for the schema size. - If
request_positionreturnsSomebutrequest_toolsreturnsNone(atools-absent or malformed row), the read falls back toregistry.visible_definitions()as before (crates/dim-agent-capabilities/src/context_usage.rs:1133-1135,1171-1177). Neither production prepare host emitstools: None(crates/dim-agent-capabilities/src/adapters.rs:242,crates/dim-agent-aimux/src/plugin.rs:372), so that path is not reachable today.
Round 2 P3: fixed, withdrawn
docs/architecture/rust-agent/plugins/ShellSession.md:11-15 now says the part owns the shell, the queue and the handoff, and :21 gives B:BackgroundExec its registration and recovery job. That matches the code (crates/dim-agent-capabilities/src/shell_session.rs:988-990,1089-1091 call background.start for a foreground timeout and an explicit background job), the owner contract (docs/design/shell-exec-recovery.md:3-5), and docs/architecture/rust-agent/plugins/WorkspaceTools.md:652-654. The dependency table matches injects (crates/dim-agent-capabilities/src/shell_session.rs:1178-1186).
Optional P3: the flow test does not fail when the fix is reverted
- Problem: the new test asserts the fixed contribution and the
counter.fixedcall count, but nothing observes which fields the usage read selects. Reverting c6e3d52, so the read materializes and parsesdata.request.toolsbefore the cache check, leaves both tests green; I verified this locally. - Failure scenario: a later change reintroduces the eager read while the test stays green, and every warm usage poll on a large MCP catalog returns to paying for the full declaration list.
- Evidence:
crates/dim-agent-capabilities/tests/context_flow/context_reads.rs:5884-5895contains only token and counter assertions; the reverted tree passes. - Fix: wrap the store as
CountContextReadsdoes (crates/dim-agent-capabilities/tests/context_flow/context_reads.rs:259-268) and assert that reads after the first do not selectdata.request.tools. Optional from round 3.
Other checks
- The
execStopremoval is complete: noExecStopservice definition remains incrates/,register_facesno longer lists it (crates/dim-app-server/src/lib.rs:1690-1692),session.exec.stopuses the branch'sBackgroundExec(crates/dim-app-server/src/connection.rs:1627-1633), andxtask checkpasses.Call::ExecStopin the protocol is the RPC name, not the service face. The only stale English claim is the historical row atdocs/design/research/1295-host-platform-task-owner.md:331, superseded by its own 7.3 note at:343-346; optional cleanup. - The PR body now describes the request-position key, and the deleted unit test is gone; both match the code.
Cross-PR
- #2240 (626fb6a) deletes the same
("execStop", "control")line and rewrites the sameShellSession.mdlines. A local merge-tree of c6e3d52 and 626fb6a auto-mergescrates/dim-app-server/src/lib.rs(identical deletion) and conflicts only indocs/architecture/rust-agent/plugins/ShellSession.md: the intro (page lines 6-7), the ownership paragraph (11-15), and theB:BackgroundExecrow (21). TheB:Timeline,B:DispatcherandS:SessionLifecyclerow deletions are identical and merge cleanly. Whichever lands second must drop its duplicate and keep one wording; the intro and the paragraph are the real choices. - #2227 (548095f) still overlaps the same two files, conflicts only in
ShellSession.md, and carries a third wording. #2238 (b1f5f45) and #2234 (7cd0385) do not touch these files. #2225 changes an unrelated part oflib.rs. - c6e3d52 merges cleanly with origin/main 06f1402 (local merge-tree, no conflicts).
CI at review time
macos-native, windows-cli, verify (linux) and ci-ok pass; changes passes; static-checks, scripts, web, dependencies and acp-registry are skipped by path filters.
No blocking findings at c6e3d52.
|
The zero-declaration branch is the same query result that the existing flow test already reads when the request declares tools; if you want a dedicated fixture for a |
- The usage cache key fingerprints the whole tool definition, so a schema-only change no longer reuses the previous request's cost. - #2206 removed ExecStop after #2197 added its face; drop the face and the ShellSession page's stop wording, and align the dependency table with the part's injects. This restores the repository check. Refs #2135
A request always declares the same tools, so its position is the cache identity. Warm reads no longer serialize the declaration list; only the pre-request fallback hashes the live set. The standalone hash test is replaced by a flow test over a tool source whose schema changes: warm reads keep the fixed contribution, the next request prices the new schema. Refs #2135
The warm path queries the last request's position and checks the fixed cache; data.request.tools is read and parsed only when the entry is absent. ShellSession.md now describes the shell, queue and handoff and gives BackgroundExec its actual job registration. Refs #2135
A published request that omits tools no longer takes the live registry set on its cold read; the fallback stays for the pre-request window. The fixed contribution and its identity take the request's Option directly. Refs #2135
c4e9ecd to
9c5e9bc
Compare
|
Rebased onto |
yyhhyyyyyy
left a comment
There was a problem hiding this comment.
The follow-up now does what the acceptance asks: a published request's fixed tool cost comes from that request's own declaration, and a warm read still stops at the request position. The changes-requested finding is fixed and can be withdrawn. No blocking finding at 9c5e9bc. One optional test gap remains from round 3.
Verified at 9c5e9bc (base b622321)
cargo fmt --all -- --checkexits 0;cargo run --locked -p xtask -- checkexits 0 (774 modules, 4801 edges; access layer 172; 45 plugin documents).usage_reuses_a_warm_request_and_prices_a_changed_tool_schemaandusage_reuses_counted_messages_and_current_registry_tools_without_extra_state_writespass.- The branch merges cleanly with b622321;
git merge-tree --write-treereports no conflict. The diff is 2 files, +298/-13.
Changes-requested finding: fixed, withdrawn
- The read asks only for the last request position first and keys the slot as
request:<sequence>(crates/dim-agent-capabilities/src/context_usage.rs:1151-1159).data.request.toolsis selected and parsed only after a cache miss (:1171-1174,:1091-1133). A request that omitstoolstherefore staysNone, andcounter.fixedreceivestools.as_deref()(:1196), counting no declarations. WindowFacts::fixedserializes theOption(crates/dim-agent-capabilities/src/context_model.rs:181-191) andcount_tokensalready passesrequest.tools.as_deref()(:159-166), so the usage fixed matches the count of the request that was sent. This is whatdocs/design/plugins/ContextUsage.md:61asks: the last request's declared set, with the registry only as the pre-request fallback.- The pre-request fallback is unchanged (
context_usage.rs:1153-1158). A repeat read returns fromdynamic_fixedbefore readingdata.request.tools(:1161-1170).NoneandSome(empty)both count no declarations, and their identity fingerprints differ, which is harmless because the slot is replaced, not shared. - I exercised the acceptance locally with a throwaway
PrepareContextthat clearsrequest.toolsafter preparation, on top of the populatedschemaregistry with toolreport. At 9c5e9bc the first read counted no declarations and the repeat read selected nodata.request.tools; with the fix reverted the same test priced 3952 bytes and["echo", "wait", "branch", "report"]. The throwaway test is not in the branch.
Optional P3: the flow test does not pin either read path
- Problem:
usage_reuses_a_warm_request_and_prices_a_changed_tool_schema(crates/dim-agent-capabilities/tests/context_flow/context_reads.rs:5814-5948) asserts tokens andcounter.fixedcounts, not which fields the read selects. Reverting the position-only read leaves it green (verified in round 3), and there is no test for a request that omitstools. - Failure scenario: a later change reintroduces the eager
data.request.toolsread or the registry fallback while the suite stays green, restoring the warm poll cost and the overcount this PR removes. - Evidence:
context_reads.rs:5814-5948; the store wrapper at:16,260-268already records query specs. - Fix: extend the flow test with a
PrepareContextthat clearstoolsand assert that the first read counts no declarations and a repeat read selects nodata.request.tools. Optional from round 3.
Cross-PR, merge state and other checks
- #2240 merged as b622321 with the same
execStopdeletion and its ownShellSession.mdwording. This head is rebased onto it, the duplicate hunks are gone, and the PR now changes only the usage code and its test. The merge with b622321 is clean. - #2238, #2234 and #2226 do not touch these files. #2227 is a draft at 9d00639 and no longer touches
ShellSession.mdorlib.rs, so the earlier overlap is gone. No open PR touchescontext_usage.rs. - Optional wording: the PR body still describes dropping the
execStopface and rewritingShellSession.md, which are on main and no longer part of this diff. Trim that bullet. - CI at review time: macos-native and changes pass; verify (linux) is pending; windows-cli and the path-filtered jobs are skipped.
No blocking findings at 9c5e9bc.
zerob13
left a comment
There was a problem hiding this comment.
Approved. A published request that omits tools now counts zero tool declarations, even with a populated registry. Before the first request, the registry remains the fallback. I verified those paths in the code; the exact CI run exercises warm reuse and repricing when the next request changes a tool schema. Linux, macOS, and ci-ok passed; Windows was not selected. The rebase also removes the catalog and documentation edits already landed in #2240.
Follow-up to the tool modes implementation (#2135, merged in #2197).
The usage fixed cost is keyed by the last model request's position plus the tool sources' summary. A warm reread queries only
position.sequenceand returns the cached contribution without reading, cloning or parsingdata.request.tools; the tools are read once on a miss. A request that omitstoolscounts no declarations; the live registry is only the pre-request fallback.usage_reuses_a_warm_request_and_prices_a_changed_tool_schemacovers a bootstrap request, two warm rereads and a source version change with a larger schema.The orphaned
execStopface and theShellSessionpage landed in main with #2240, so this PR now carries only the usage cache.Verification:
cargo run --locked -p xtask -- checkexit 0; workspace clippy clean; the usage tests pass.Refs #2135