Repository navigation
feat: add the Session tool mode and its registry projection - #2197
Conversation
zerob13
left a comment
There was a problem hiding this comment.
The registry projection and persisted default are the right foundation. Against the accepted tool-mode design, these behaviors still need to hold:
- Check tool eligibility before creating call state. The top-level Loop path can create handler state before the execution check rejects a tool excluded from the current mode. A refused top-level call must leave no pending response, while a permitted delegated child still works.
- Settle Goal before Shell becomes effective. Mode publication is outside the settle gate. A concurrently started or resumed Goal can survive the switch, and queued Goal work or its missing pause context can leak into the first Shell turn. Verify that entry through either update or registration pauses active Goals, withdraws pending Goal work, and gives the first Shell request the pause context.
- Use the correct mode when recovering queued input. Recovery can first apply an input with a Normal pin in a persisted Code Mode or Shell Session. Already-applied work must retain its recorded pin; work applied for the first time during rebuild must use the effective mode at application.
- Initialize new member Sessions with the creator's current choice. Collaboration creation can fall back to profile defaults. Verify that a member created in Code Mode starts with that choice and does not change when the creator later switches.
- Make the first-party controls work on a real handshake. The server feature and the client check disagree on how update support is discovered, so a supported switch may never reach the server. Verify Web and TUI can persist a switch, show the effective mode on fallback, refresh an already-open second view, and remember the last successful choice for new Sessions.
- Count the tools the model actually sees. Usage caching and manual compaction can retain or count hidden tools after a mode-only change. The reported and compaction tool costs should follow the visible set without a separate tool-source update.
These are static findings. The current head conflicts with main and has no exact merge CI; verify the real Web/TUI, recovery and Goal flows on the rebased result. Downstream dim-electron adaptation is not part of this verdict.
zerob13
left a comment
There was a problem hiding this comment.
Reviewed f2f6c8de447276e4461a2f2caf4dd1db152ea6b8. The TUI row reorder is fine. The six existing acceptance conditions in the previous review remain open: reject hidden tools before side effects; settle Goal and include the pause context on the first Shell request; recover held inputs with the effective mode and retain already-applied pins; inherit the creator's live mode for new members; verify both UI clients against the real handshake and persist only a successful choice; and calculate usage from visible declarations after a switch.
New evaluation regression: the isolated product preflight now expects execute from the default Normal-mode probe, which intentionally does not declare it. This can abort evaluation before the judged turn. Make the expected list match the probe mode and verify that Normal preflight reaches the turn with execute absent.
No exact current-head CI is available; the merge conflict is a separate gate.
yyhhyyyyyy
left a comment
There was a problem hiding this comment.
Reviewed the full main...head diff at f2f6c8de against 8dbcec62 (round 1), including the two follow-up commits that reorder the settings rows, add execute to the eval run list, and adjust the settings test navigation. Scope: the Session tool mode of #2135 and its integration, namely the persisted choice and the two Session methods, the ToolRegistry visible/delegated projection and ModeTransition, origin-based admission, the turn pin through compaction and rebuild, Goal settle/pause/withdrawal on an effective shell transition, the product shell profile, and the web/TUI controls. I verified each of the six items in review 6067380589 at this head; the evidence below identifies which part fails.
Blocking findings
1. P1: neither first-party client can change the mode. Both clients gate the control on session.tool_mode.update, but hello.features adds only session.tool_mode and session.create.toolMode (crates/dim-app-server/src/transport.rs:826-827). Web supports is exact membership (web/src/stores/connection.ts:41-43), so toolModeControl (web/src/features/chat/ChatPage.vue:60) is always undefined and the composer menu is never mounted. The TUI requires both names (crates/dim-cli/src/session_host.rs:2035-2038; crates/dim-client/src/lib.rs:295-299), so Command::SetToolMode is silently dropped after the row already advanced locally (crates/dim-cli/src/ui/tui.rs:5214-5221). Failure: no first-party path changes the mode; the TUI row then keeps a value the Session does not have because tool_mode_read prevents a re-read (crates/dim-cli/src/ui/tui.rs:5178-5182). Fix: check session.tool_mode only, the name the design defines (docs/design/agent-tool-modes.md:272), or advertise the exact name both clients check.
Also in this finding: the TUI row renders the chosen mode, not the mode in force (crates/dim-cli/src/ui/tui.rs:5171; tool_mode_effective is stored but never used), contradicting docs/design/agent-tool-modes.md:398-402, and the added docs/design/cli-commands.md:975-980 documents that contradiction. The TUI cycles unavailable modes without checking session.tool_mode.codemode / .shell (crates/dim-cli/src/ui/tui.rs:9805-9812), remembers no choice for session.create, and the web writes localStorage before the update succeeds (web/src/features/chat/ChatPage.vue:66-69). A second open view does not refresh after another view switches: there is no mode event and the load runs only when the view becomes ready (web/src/features/chat/ChatPage.vue:37).
2. P2: the Goal settle gate ends before the mode is published. session.tool_mode.update runs settle_update under the mode gate (crates/dim-app-server/src/session_tool_mode.rs:110-115), but settle_update releases the gate when the settle returns (crates/dim-agent-capabilities/src/tool_registry.rs:522-525); the record write and set_tool_mode run after it (crates/dim-app-server/src/session_tool_mode.rs:116-122). Goal set/resume take the same gate and check effective_tool_mode_now (crates/dim-goal/src/session.rs:237-243), and the continuation path reads the live mode (crates/dim-goal/src/branch.rs:2095-2101), so a call that commits in that window sees normal, survives the settle, and its trigger can be applied after shell takes effect. The design requires the gate through the publish (docs/design/agent-tool-modes.md:129-137, :144-150). Failure: an operator switches to shell while a resume or continuation commits; the goal stays active in shell and its queued work can start a turn.
A second gap: a shell-pinned turn waits only for the settle marker (crates/dim-agent-capabilities/src/agent_loop.rs:1240-1245), while its history cutoff is the ModelStart sequence captured before that wait (:1246-1258); a pause Append input committed during the settle (crates/dim-goal/src/session.rs:126-129, crates/dim-goal/src/text.rs:435-451) is applied asynchronously (crates/dim-agent-capabilities/src/input_queue.rs:140-143) and is excluded when its sequence is after ModelStart. Failure: the first shell turn runs without the committed pause text, against docs/design/agent-tool-modes.md:151-154 and :233-235.
Also, settle_entry does not re-check the chosen or mounted mode under the gate (crates/dim-agent-capabilities/src/tool_registry.rs:487-505), so a registration that races an update to normal, or an execute excluded by the mount list, still pauses active goals although the Session stays normal. Fix: hold the gate across settle, record and live replacement; give a shell-pinned turn a pause-adoption barrier before its request cutoff; re-check the mode and mount in settle_entry.
3. P2: a rebuilt InputQueue stamps normal on first-time applications. QueueState::release hardcodes ToolMode::Normal (crates/dim-agent-capabilities/src/input_queue.rs:195); rebuild uses it for every queued input it releases (crates/dim-agent-capabilities/src/input_queue/recovery.rs:416-445), while the live path stamps effective_tool_mode_now() (crates/dim-agent-capabilities/src/input_queue.rs:284-293). Failure: restart a Session persisted as shell with a queued input; the input is applied as normal, the turn pins normal, and the request declares the direct work surface (crates/dim-agent-capabilities/src/tool_registry.rs:1025-1048), handing the model the file tools the operator excluded. A persisted codemode Session behaves the same way on its first post-restart input. Already-applied work keeps its recorded pin because the Loop reads data.tool_mode (crates/dim-agent-capabilities/src/agent_loop.rs:671-731).
A smaller related window: settle_entry clears the settling marker before the refresh task has published the entry registration (crates/dim-agent-capabilities/src/tool_registry.rs:494-505, :1152-1168), and effective_tool_mode_now reads the old sources without refreshing (:535-539), so the first input after a registration can also pin normal. Fix: pass the effective mode into release/rebuild as on_event does, and publish the registration projection before clearing the marker.
4. P2: a member Session does not inherit the creator's mode. Collaboration::establish builds the member config from the target profile (crates/dim-app-server/src/collaboration.rs:324-328) and copies cwd, permission and model, never the tool mode; the design requires the creator's current mode (docs/design/agent-tool-modes.md:187, :283-284). Failure: a member created from a codemode or shell Session starts normal, gets the direct tool surface, and keeps it when the creator switches. Fix: copy the creating Session's live registry value (ToolRegistry::tool_mode), not Session::config().tool_mode: session.tool_mode.update rewrites the stored record and the registry, not the live SessionConfig, so the creation config is stale. No test covers the member case.
5. P2: usage and manual compaction count tools the model does not see. The usage cache check at crates/dim-agent-capabilities/src/context_usage.rs:1072-1081 keys only on the configuration event and source versions; a mode switch changes neither, so it returns the cached fixed tool cost before visible_definitions() at :1082 and keeps returning it until a source version changes. Failure: after normal to shell, session.context keeps reporting the work tools' cost; after shell to normal it undercounts. The later identity does include the tools, but the early return prevents it from running. Manual compaction builds its request from the adopted configuration's data.settings.tools (crates/dim-agent-capabilities/src/context_policy.rs:400-424, called at crates/dim-agent-capabilities/src/agent_loop.rs:439-444), the callable set, not the visible projection; in shell and codemode, and for the two entry tools in normal, the estimate counts hidden declarations. The design says usage follows visible and a delegated-only tool never appears in the usage counter (docs/design/agent-tool-modes.md:236-237, :553). Fix: include the visible set, or the mode plus projection, in the cache key, and project configured_request with the boundary turn's mode.
6. P2: a refused top-level call still registers handler state. The Loop claims every call of a batch before it appends step/tool-call (crates/dim-agent-capabilities/src/agent_loop.rs:1742-1758), and ToolBinding::claim looks the name up in snapshot.tools, now the union of visible and delegated (crates/dim-agent-capabilities/src/tool_binding.rs:288-289). The origin check runs later in ToolExecutor::admit (crates/dim-agent-capabilities/src/tool_executor.rs:693-701). Failure: in codemode, a top-level ask_user, delegated but not visible, is found by claim, which registers a waiter (crates/dim-agent-questions/src/lib.rs:338-373, :456-458); admit then refuses the call as an unknown tool, but until the request snapshot is released session.question.respond accepts an answer for a call that never ran (:424-445). The design requires a refused call to register no waiter and take no effect (docs/design/agent-tool-modes.md:214-219). A permitted delegated child still works because child calls have no pre-claim and AskUser::execute registers its own waiter (crates/dim-agent-capabilities/src/tool_executor.rs:748-757). Fix: claim only names in snapshot.visible for the top-level batch, or pass the origin into claim.
P3 findings
- The doc comments above
NoToolsare swapped (crates/dim-agent-capabilities/src/defaults.rs:335-338):tool_hostlost its one-line doc andNoToolshas two. - The owner docs do not carry the new contracts:
ToolRegistry.mdadds the projection but not the mode gate or theModeTransitionregistration settle (docs/architecture/rust-agent/plugins/ToolRegistry.md:33-48), although the design assigns both to ToolRegistry (docs/design/agent-tool-modes.md:536-540), andLoop.mdgains no turn mode pin, which the design requires (design:544-548). - Tests: the PR body lists Goal settle/pause/refusal/withdrawal, admission, delegated children and web/TUI settings, but the diff adds no Goal test, no admission or child test, and the web test only adds a mock field;
session_tool_mode_flowcovers create/get/update and two request surfaces (crates/dim-app-server/tests/session_tool_mode_flow.rs:165-306). The behaviors in findings 2 through 6 are untested. The last two commits adapt the existing settings test navigation and addexecuteto the eval run list, but add no test for the tool-mode row or the client gate.
Cross-PR, main and CI
git merge-tree --write-tree f2f6c8de 8dbcec62conflicts only incrates/dim-app-server/src/connection.rs, in thesession.exec.stopblock. main already routes throughservice_opt::<dyn ExecStop>and mapsexec_stop::TaskError::Read(main'scrates/dim-app-server/src/connection.rs; commits1cb76a86c,1641ece36), and main'sShellSessionfalls back toBackgroundExecinside itsExecStopimpl (main'scrates/dim-agent-capabilities/src/shell_session.rs). This head rewrites the block withservice::<dyn ExecStop>,Err(_) => None, and onlyClosedbefore an outerBackgroundExecfallback. With the product mountingShellSession, main's trait impl covers both task kinds, so this hunk is redundant; dropping it resolves the conflict and keeps the read-fault mapping.- Pairwise merges with #2174 a05a442, #2206 55636b7, #2209 d9e79eb and #2208 7b1103a also conflict at that same block, since all are based on current main; #2202 6867cb6 instead conflicts in
crates/dim-codemode/tests/flow.rs, where it reshapes the samecreate_sessioncall this PR addstool_modeto. #2205 is in main. No merge is clean. - CI at f2f6c8d:
static-checks,dependencies,scripts,changesandacp-registrypassed;windows-clifailed in its native boundary flow step;verify (linux)andwebwere in progress andverify (macos)andmacos-nativewere queued while the run was still in progress, so the failing job logs were not available. The earlier head's two deterministic failures, the settings panel row overflow and the missingexecutein the eval run list, are addressed by the previous two commits.git diff --checkis clean.
Verification
- Reviewed the full 77-file
main...headdiff at f2f6c8d against 8dbcec6, the design and contracts, the storage and client paths, the merge results, and the exact-head CI runs. - No local build or test run: the reviewed head is a one-line test change on a tree whose earlier CI compiled the workspace, and the exact-head CI was still running at review time. The interleavings in findings 2 and 6 were checked statically, not reproduced.
- Unverified: the race windows in findings 2 and 6, member inheritance at runtime, web and TUI behavior beyond static inspection, any merge resolution, and the windows-cli failure at this head, whose logs were unavailable while the run was in progress.
|
|
||
| /// Whether a call may name `name`: a top-level call only inside the | ||
| /// request's visible set, a Code Mode child only inside its delegated set. | ||
| pub fn admit(&self, request_id: &str, name: &str, child: bool) -> Result<(), String> { |
There was a problem hiding this comment.
[P2] The check is correct for execution, but the claim already happened. Loop claims every batch call before it appends step/tool-call (crates/dim-agent-capabilities/src/agent_loop.rs:1742-1750), and ToolBinding::claim looks the name up in snapshot.tools, now the union of visible and delegated (:288-289). In codemode, a top-level ask_user is delegated but not visible, so claim registers a waiter (crates/dim-agent-questions/src/lib.rs:338-373), then this check refuses the call as an unknown tool; until the request snapshot is released, session.question.respond accepts an answer for a call that never ran (:424-445). The design requires a refused call to register no waiter (docs/design/agent-tool-modes.md:214-219). A permitted child still works because child calls have no pre-claim. Fix: in ToolBinding::claim, claim only names in snapshot.visible for the top-level batch, or pass the origin.
There was a problem hiding this comment.
[Withdrawn] The hidden top-level call cannot reach claim: a ToolStart not offered in the request is rejected before the batch exists (crates/dim-agent-capabilities/src/output.rs:800), so the waiter scenario does not occur. The new visible filter in claim (crates/dim-agent-capabilities/src/tool_binding.rs:288-289) is an extra guard.
| .await | ||
| .map_err(|error| RpcError::app(-32000, FAILED, error.to_string()))?; | ||
| } | ||
| tools.set_tool_mode(mode); |
There was a problem hiding this comment.
[P2] settle_update holds the mode gate only inside itself (crates/dim-agent-capabilities/src/tool_registry.rs:522-525); the record write above and this line run after it is released. Goal set/resume take the gate and check the effective mode (crates/dim-goal/src/session.rs:237-243), and the continuation path reads the live mode (crates/dim-goal/src/branch.rs:2095-2101), so a call that commits between the settle and this line sees normal, survives the switch, and its trigger can be applied into the first shell turn. The design requires the gate through the publish (docs/design/agent-tool-modes.md:129-137, :144-150). The first shell request also waits only for the settle marker (crates/dim-agent-capabilities/src/agent_loop.rs:1240-1245), whose history cutoff is the ModelStart sequence taken before the wait (:1246-1258), so a pause appended during the settle can be excluded from that request. Fix: hold the gate across settle, record and set_tool_mode, and wait for the pause to be adopted before the shell request cutoff.
There was a problem hiding this comment.
[Fixed, one remaining] The mode gate now spans settle, record and live replacement (crates/dim-app-server/src/session_tool_mode.rs:110-123), and settle_entry re-checks the chosen mode and the entry under the gate (crates/dim-agent-capabilities/src/tool_registry.rs:498-502). The pause-exclusion part is withdrawn: the Dispatcher is serial and start_preparation now waits for the entry settle and raises its cutoff (crates/dim-agent-capabilities/src/agent_loop.rs:1246-1250), so a committed pause precedes a shell turn's request. Remaining: the settle does not withdraw a set/resume trigger because it is not in Owner::queued (crates/dim-goal/src/session.rs:129-149; crates/dim-goal/src/branch.rs:757-758); see the new inline comment.
| self.starting = true; | ||
| } | ||
| vec![Decision::Apply(entry.id.clone(), mode)] | ||
| vec![Decision::Apply(entry.id.clone(), mode, ToolMode::Normal)] |
There was a problem hiding this comment.
[P2] QueueState::release has no mode, so rebuild stamps every first-time application normal (crates/dim-agent-capabilities/src/input_queue/recovery.rs:416-445), unlike the live path which uses effective_tool_mode_now() (crates/dim-agent-capabilities/src/input_queue.rs:284-293). After a restart of a persisted shell or codemode Session, the queued input is applied as normal and its turn declares the direct work surface (crates/dim-agent-capabilities/src/tool_registry.rs:1025-1048), so a shell turn gets the file tools the operator excluded. Applied inputs keep their recorded pin (crates/dim-agent-capabilities/src/agent_loop.rs:671-731). Fix: pass the effective mode into release/rebuild the way on_event does, only for Apply decisions.
There was a problem hiding this comment.
[Fixed, one race remains] rebuild now reads the effective mode once and stamps only Apply decisions (crates/dim-agent-capabilities/src/input_queue/recovery.rs:441-449). The new test does not exercise that line: the held input is applied by the live on_event after the restored turn ends; see the test comment. The effective read can still see unadopted sources and pin normal; see the registration comment.
There was a problem hiding this comment.
[Fixed for the rebuild release] 38d10fe pins crates/dim-agent-capabilities/src/input_queue/recovery.rs:441-449 with the test above: the applied record for the rebuild-released input carries the persisted shell, and forcing the release mode to normal fails the assertion. The note that the effective read can still see unadopted sources now applies only to a part that registers an entry tool without begin_entry and settle_entry; the product ShellToolsPlugin and the test helpers settle, so no product path is open. Withdrawn.
| }, { immediate: true }) | ||
| const toolModeControl = computed(() => { | ||
| const session = view.value | ||
| if (session?.status !== "ready" || !connection.supports("session.tool_mode") || !connection.supports("session.tool_mode.update")) return undefined |
There was a problem hiding this comment.
[P1] session.tool_mode.update is never advertised. hello.features adds only session.tool_mode and session.create.toolMode (crates/dim-app-server/src/transport.rs:826-827), and supports is exact membership (web/src/stores/connection.ts:41-43), so this expression is always false and ComposerToolModeMenu is never mounted. The web cannot switch a mode the daemon supports. The TUI has the same check (crates/dim-cli/src/session_host.rs:2035-2038). Fix: check session.tool_mode only, as the design defines the pair (docs/design/agent-tool-modes.md:272), or advertise the exact name. Also line 67 records the choice before the update succeeds, so a failed switch still changes the mode used for new Sessions.
There was a problem hiding this comment.
[Fixed] ChatPage.vue:63-73 gates on session.tool_mode and the per-mode features; the update name is not required. The choice is stored only after a successful update (:71-73), and a focus listener re-reads (:37-42).
There was a problem hiding this comment.
[Fixed] ChatPage.vue:63-73 gates on session.tool_mode and the per-mode features; the update name is not required. The choice is stored only after a successful update (:71-73), and a focus listener re-reads (:37-42).
| Command::SetToolMode { mode } => { | ||
| if self | ||
| .client | ||
| .supports(&["session.tool_mode", "session.tool_mode.update"]) |
There was a problem hiding this comment.
[P1] Client::supports requires every name (crates/dim-client/src/lib.rs:295-299), and session.tool_mode.update is never advertised (crates/dim-app-server/src/transport.rs:826-827), so this branch never runs. The row already advanced locally before sending (crates/dim-cli/src/ui/tui.rs:5214-5221), and tool_mode_read prevents a re-read on the next open (:5178-5182), so Enter changes the label without changing the Session. The read above uses only session.tool_mode and works, which is the right check for both.
There was a problem hiding this comment.
[Fixed] The TUI gates on session.tool_mode (crates/dim-cli/src/session_host.rs:749, :2053), shows the chosen and effective modes (crates/dim-cli/src/ui/tui.rs:9828-9834), cycles only advertised modes (:5230-5231), writes the saved choice only after a successful update (:2794-2799), and re-reads after an error (:2066-2069).
| return Ok(cached.clone()); | ||
| } | ||
| let (tools, sources) = self.registry.snapshot(); | ||
| let tools = self.registry.visible_definitions(); |
There was a problem hiding this comment.
[P2] The early cache above (:1072-1081) keys only on the configuration event and source versions. A mode switch changes neither, so the cached fixed tool cost is returned before this line and keeps being returned until a source changes; after normal to shell the usage still counts the hidden work tools, and after shell to normal it undercounts. The later identity does include the tools, but the early return prevents it. Fix: include the visible set, or the mode, in the cache key; project with the request pin rather than the live mode.
There was a problem hiding this comment.
[Fixed for correctness, P3 remains] The early cache return is gone and the lookup key includes the visible tools fingerprint (crates/dim-agent-capabilities/src/context_usage.rs:1059-1076), so the stale cost is no longer returned. The stored versions at :1078-1084 are sources only, so the cache now never hits; the live mode at :1059 is not the turn pin. The idle manual compaction also defaults to normal (crates/dim-agent-capabilities/src/agent_loop.rs:439-445). See the P3 comments.
There was a problem hiding this comment.
[Fixed] The early cache return is gone, the lookup key includes the visible set, and the adopted-configuration path reprices (crates/dim-agent-capabilities/src/context_usage.rs:1013-1028, :1104-1118). The pinned-mode read added at 79d8c1e is tracked in 4703876386. Withdrawn as a P2.
| .as_ref() | ||
| .map(|setting| setting.document.enabled), | ||
| prompts: self.prompt_origins(), | ||
| tool_mode: tool_mode_label(&self.tool_mode), |
There was a problem hiding this comment.
[P2] This is the chosen mode, not the mode in force. The design requires the row to show effective, so a fallback is not reported as running (docs/design/agent-tool-modes.md:398-402); tool_mode_effective is stored in the same struct but never read. The added docs/design/cli-commands.md:975-980 now documents the chosen-mode row and contradicts the design. The picker also cycles all three modes without checking session.tool_mode.codemode / .shell (crates/dim-cli/src/ui/tui.rs:9805-9812), so an unavailable mode can be selected. Fix: render tool_mode_effective, gate the cycle on the advertised per-mode features, and correct the CLI doc.
There was a problem hiding this comment.
[Fixed in code, doc remains] The row now shows the chosen and effective modes (crates/dim-cli/src/ui/tui.rs:9828-9834), and the cycle uses the advertised modes (:5230-5231). docs/design/cli-commands.md:975-980 still says the row shows the chosen mode and cycles all three, contradicting the design (docs/design/agent-tool-modes.md:398-402) and the code; see the body.
There was a problem hiding this comment.
The row half is fixed: the TUI shows the chosen mode and the effective one on fallback (crates/dim-cli/src/ui/tui.rs:9822-9830). The doc half moved: docs/design/cli-commands.md:975-981 now matches the code, but the picker still cycles only advertised modes (crates/dim-cli/src/ui/tui.rs:9814-9820), while the feature design requires all three with unavailable marks (docs/design/agent-tool-modes.md:398-402; the web does this in web/src/features/chat/ComposerToolModeMenu.vue:12-18). See the new inline on cli-commands.md:977.
There was a problem hiding this comment.
[Fixed] At 76a945c the TUI cycles all three modes (crates/dim-cli/src/ui/tui.rs:9822-9828) and docs/design/cli-commands.md:973-984 matches, so the picker contract is met. The unavailable mark now compares the localized label with the raw advertised names (crates/dim-cli/src/ui/tui.rs:9831-9833), so every fallback is marked; see the new inline on that line.
| } | ||
|
|
||
| /// Installs `driver` as the Session `ToolHost`. | ||
| /// A `ToolHost` with no host tools: the minimal profile's only tool is |
There was a problem hiding this comment.
[P3] The two doc comments are stacked on NoTools: the pre-existing Installs driver as the Session ToolHost line above now documents NoTools, and this added comment documents it too, while pub fn tool_host below has no doc. Move the first line back above tool_host.
There was a problem hiding this comment.
[Fixed] NoTools and tool_host each have their own doc comment again (crates/dim-agent-capabilities/src/defaults.rs:335-354).
| TaskError::Closed => RpcError::reloading(), | ||
| TaskError::Read(error) => error.into(), | ||
| })?; | ||
| let live = match session |
There was a problem hiding this comment.
[P2] This block conflicts with current main at exactly these lines. main already uses service_opt::<dyn ExecStop> here and maps exec_stop::TaskError::Read; main's ShellSession trait impl falls back to BackgroundExec on Unknown, so it covers both shell and native tasks once the product mounts ShellSession. This service call with Err(_) => None drops the read-fault distinction and duplicates that fallback. After rebasing, keep main's block and drop this hunk; it also resolves the only merge conflict with main.
There was a problem hiding this comment.
[Fixed] The block now uses service_opt::<dyn ExecStop> and maps exec_stop::TaskError::Read (crates/dim-app-server/src/connection.rs:1628-1645); HEAD now merges cleanly with main and with #2178, #2174, #2206 and #2210. Only #1881 conflicts, in docs/design/plugins/Report.md, a file this PR does not touch.
f2f6c8d to
da27d45
Compare
|
Clients (P1). Both check Goal gate (P2). Recovery (P2). First-time applications during rebuild take the effective mode at application ( Members (P2). A new member copies the creator's live registry value ( Usage and compaction (P2). The usage cache key includes the visible declarations, and manual compaction projects the callable set with the boundary turn's mode. Claim (P2). A top-level batch claims only names in P3. The Merge/CI. The branch is rebased; |
|
Added Test coverage still to add: member inheritance, first-time recovery under a persisted mode, and the usage-cache/manual-compaction costs after a mode-only change. I am following with them. |
zerob13
left a comment
There was a problem hiding this comment.
Reviewed b62125b51b902d1d25e3e0a26de0afee1547cd7b. The merge conflict, pre-claim admission, member inheritance, and queue recovery's hard-coded Normal pin are resolved. The earlier claim about ordinary streamed model output reaching the waiter is withdrawn: it already has a guard before pre-claim. The update now holds its transition gate through publication, both clients use the advertised feature, and the new test verifies the explicit update writes a pause marker.
- Apply Shell mode only after Goal is settled. Entry registration can still miss the newly registered declarations before refresh, and ordinary Goal set/resume triggers are not tracked for withdrawal. A stored pause marker is not sufficient evidence that the first Shell request sees it. Verify that a newly effective Shell mode leaves no held Goal work and that the first model request includes the pause text. Entry registration
- Refresh and reuse the effective Session choice. An already-attached TUI must see a mode changed elsewhere on reopening settings, and ordinary
/newmust reuse the last successful choice. Creation paths - Respect visible declarations in usage and idle compaction. Without changing any tool source, switching mode must update what
/usagecounts and what idle manual compaction budgets, including when declarations were already adopted. Usage path - Keep the Normal eval preflight mode-correct. The default probe must reach the evaluated turn without declaring Shell-only
execute. Preflight - New regression: startup model preview with a saved mode. The preview reuses creation params, so it sends the saved
toolModeto a method whose strict schema does not accept it. Reopening Home after saving a mode must still load model preview, while a subsequent Session create keeps the saved choice. Preview request · Schema
|
Remaining review test: the usage cache and manual compaction costs after a mode-only change. |
|
All four remaining review tests are in on
The code conditions from both reviews are in the previous commit; the branch is rebased on |
yyhhyyyyyy
left a comment
There was a problem hiding this comment.
Reviewed the full merge-base...head diff at eccd6d384 (85 files, +2316/-99, base a22915de; origin/main 076df0a1), including the fix commit and the four test commits added after the previous review. Scope: the Session tool mode of #2135 and its integration, namely the persisted choice and the two Session methods, the ToolRegistry visible/delegated projection and ModeTransition, origin-based admission, the turn pin through compaction and rebuild, Goal settle/pause/withdrawal on an effective shell transition, the product shell profile, and the web/TUI controls.
Prior review status (review 6067606211)
- Finding 1, P1, client gate: fixed. Web gates on
session.tool_modeand the per-mode features (web/src/features/chat/ChatPage.vue:63-73), stores the choice only after a successful update, and re-reads on focus (:37-42). The TUI gates onsession.tool_mode(crates/dim-cli/src/session_host.rs:749,:2053), shows the chosen and effective modes (crates/dim-cli/src/ui/tui.rs:9828-9834), cycles only advertised modes (:5230-5231), writes the saved choice only after a successful update (:2794-2799), and re-reads after an error (:2066-2069). - Finding 2, P2, settle gate: fixed in part.
session.tool_mode.updatenow holds the mode gate across settle, record and live replacement (crates/dim-app-server/src/session_tool_mode.rs:110-123), andsettle_entryre-checks the chosen mode and the entry under the gate (crates/dim-agent-capabilities/src/tool_registry.rs:498-502). The pause-exclusion sub-claim is withdrawn: the Dispatcher is serial andstart_preparationnow waits for the entry settle and raises its cutoff (crates/dim-agent-capabilities/src/agent_loop.rs:1246-1250), so a committed pause precedes a shell turn's request. Remaining: the settle does not withdraw aset/resumetrigger, and the registration settle can be skipped before the entry is adopted. See findings 1 and 2 below. - Finding 3, P2, rebuilt InputQueue: fixed at
crates/dim-agent-capabilities/src/input_queue/recovery.rs:441-449, which reads the effective mode once and stamps only Apply decisions. Remaining: the effective read can see unadopted sources; the new test does not exercise this line. See findings 2 and the test note. - Finding 4, P2, member inheritance: fixed at
crates/dim-app-server/src/collaboration.rs:324-330; the new test pins the chosen mode (crates/dim-app-server/tests/transport_flow/collaboration.rs:1150-1156). A later creator switch and the member's effective fallback are not tested. - Finding 5, P2, usage and manual compaction: fixed for correctness. The early cache return is gone and the lookup key includes the visible tools fingerprint (
crates/dim-agent-capabilities/src/context_usage.rs:1059-1076); manual compaction uses the open turn's mode (crates/dim-agent-capabilities/src/agent_loop.rs:439-450). Remaining P3 items are below. - Finding 6, P2, hidden top-level claim: withdrawn. A
ToolStartnot offered in the request is rejected before the batch is claimed (crates/dim-agent-capabilities/src/output.rs:800), so the waiter scenario does not occur; the new visible filter inclaim(crates/dim-agent-capabilities/src/tool_binding.rs:288-289) is an extra guard. - P3 defaults docs: fixed.
NoToolsandtool_hosteach have their own comment (crates/dim-agent-capabilities/src/defaults.rs:335-354). - P3 owner docs:
ToolRegistry.md,Loop.md,PromptSources.md,ShellSession.mdandShellTools.mdcarry the new contracts;Goal.mdandCodeMode.mddo not. - P2 conflict in
crates/dim-app-server/src/connection.rs: fixed. The block now usesservice_opt::<dyn ExecStop>and mapsexec_stop::TaskError::Read(crates/dim-app-server/src/connection.rs:1628-1645), and the face route registersexecStop,modeTransitionandshellSession(crates/dim-app-server/src/lib.rs:1692-1712).
Blocking findings
1. P2: the shell settle does not withdraw the set/resume trigger. The Goal settle withdraws the ids in changes.queued(&key) (crates/dim-goal/src/session.rs:126-149), and that list is filled only by Owner::write and Owner::write_if_head (crates/dim-goal/src/branch.rs:541-545, :560-567). A set or resume trigger does not take that path: change_inner writes it in the record batch through append_business_if_head (crates/dim-goal/src/branch.rs:757-758), which assigns a new id and never records it, although the trigger would match queued_goal_input (:2805-2811; crates/dim-goal/src/text.rs:379-391, :452-464). Failure: with a turn running, call session.goal.resume or set, then update the mode to an effective shell. The goal is paused and any continuation is withdrawn, but the Queue trigger stays held by the InputQueue; when the turn ends it is applied with the shell pin and starts a shell turn carrying the goal instruction. The design requires the settle to withdraw the unapplied set/resume trigger and the continuation (docs/design/agent-tool-modes.md:139-142, :147-149). The withdrawal errors are also ignored (crates/dim-goal/src/session.rs:140-148), so a failed withdrawal does not block the update. Fix: record the trigger's event id from the append_business_if_head batch in Owner::queued, as write does, or query the branch's unapplied Goal Queue inputs at settle time, and surface a failed withdrawal.
2. P2: the registration settle is skipped before the entry is adopted. settle_entry checks entry_declared (crates/dim-agent-capabilities/src/tool_registry.rs:499) against sources without a refresh (:530-538), while register only adds to Registrations (:347-356); refresh is what adopts the registration (:648-748). A part that calls begin_entry, register and settle_entry in one apply, as the product's ShellToolsPlugin does (crates/dim-agent-capabilities/src/shell_tools.rs:134-143) and the new test helper mirrors (crates/dim-app-server/tests/storage_flow/queue_recovery.rs:36-48), reaches settle_entry with the entry still absent, clears settling (crates/dim-agent-capabilities/src/tool_registry.rs:499-501), and never runs transition.settle. The background task then adopts the entry and publishes the mode (:1165-1181) without the settle. Failure: a Session restored with toolMode: shell, or a shell-mode Session whose execute re-registers, makes shell effective without pausing an active goal; an input applied in the window before the refresh reads effective_tool_mode_now() (crates/dim-agent-capabilities/src/input_queue.rs:287-294; crates/dim-agent-capabilities/src/input_queue/recovery.rs:441-449), which reads the unadopted sources (crates/dim-agent-capabilities/src/tool_registry.rs:547-552), and pins normal, so its turn declares the direct work surface the shell mode hides. The design requires the registration settle before the publish (docs/design/agent-tool-modes.md:129-137). Fix: refresh and adopt under the mode gate before entry_declared, and make the apply path read an adopted projection or trigger the refresh.
3. P2: the added CLI contract text contradicts the design and the code. docs/design/cli-commands.md:975-980 says the row shows the chosen mode and that Enter cycles normal -> codemode -> shell. The design says the row shows the effective mode and the picker lists all three with unavailable entries marked (docs/design/agent-tool-modes.md:398-402), and the code shows the chosen and effective modes when they differ (crates/dim-cli/src/ui/tui.rs:9828-9834) and cycles only advertised modes (:5230-5231). Failure: an operator reads the contract and expects a fallback mode to be reported as running and expects to reach every mode; the code does neither. Fix: align the text with the effective row and the advertised cycle, or align the clients with the contract and list all three modes with unavailable marks.
4. P2, cross-review: the evaluation preflight still expects a hidden entry tool. I agree with the earlier review's evaluation regression: RUN_TOOLS still lists execute (xtask/src/scenario_eval.rs:504), the product probe creates a Session without toolMode and runs normal (:3908-3930), where execute is hidden (crates/dim-agent-capabilities/src/tool_registry.rs:1027-1044), so the tools-product check's absent set (xtask/src/scenario_eval.rs:4285-4298) fails and the static first-request pin (:17291-17298) expects a name the request cannot declare. No commit in this round changes it.
P3
- The usage cache never hits. The lookup key includes the visible tools fingerprint (
crates/dim-agent-capabilities/src/context_usage.rs:1066), but on a miss the entry is stored with a sources-only fingerprint (:1078-1084,:1107-1111), so the next lookup cannot match and every usage read runssnapshotand the Timeline query again. The value is now correct, but the cache is dead.visible_definitions()also uses the live mode (:1059;crates/dim-agent-capabilities/src/tool_registry.rs:567-570), not the mode pinned by the turn atthrough, so a switch during a running turn reprices that turn's request. - A manual compaction with no open turn takes
ToolMode::default(), which isnormal(crates/dim-agent-capabilities/src/agent_loop.rs:439-445). On a Session whose chosen mode is shell or codemode,session.context.compactwhile idle builds the summary request from the normal projection (crates/dim-agent-capabilities/src/context_policy.rs:400-410), declaring the tools the mode hides. The running-turn case is fixed; the idle case is not. - The four new tests pin the update pause, the member's chosen mode, the usage recompute after an idle switch, and the live application of a restored input. They do not pin the rebuild path, the trigger withdrawal, the member's effective mode or a later creator switch, the running-turn pin, or the cache. The restore test in particular uses a second held input behind a 5 s turn (
crates/dim-app-server/tests/storage_flow/queue_recovery.rs:574-590), sorebuildholds it (crates/dim-agent-capabilities/src/input_queue/recovery.rs:427-431) and the liveon_eventapplies it after the restored turn ends (crates/dim-agent-capabilities/src/input_queue.rs:287-294); the fixed line:441-449is not exercised. The test helper'ssettle_entryis also the no-op described in finding 2. The goal test (crates/dim-goal/tests/goal_product_flow.rs:2377-2423) covers the update pause but not theset/resumewithdrawal or the refusal in shell. The PR body's test checklist claims the latter two and the registration settle. docs/architecture/rust-agent/plugins/Goal.mdandCodeMode.mddo not carry the settle/withdrawal and origin admission contracts the design assigns to their owners;ToolRegistry.mdandLoop.mdwere updated.- Optional: the TUI does not re-read the mode after another client switches, the TUI picker omits unavailable modes instead of showing them marked, the PromptSources Windows guidance follows the mode only on a source reload,
Owner::queuedgrows without pruning, and the savedtool_modevalue read forsession.createis not validated.
Merge, CI and verification
git merge-tree --write-treeat this head is clean with origin/main and with #21780506c22b, #21740133e3be8, #22063c4ef46eand #221053df6fcb(rechecked at publish). The only conflict is with #1881ff9825d2indocs/design/plugins/Report.md, a file this PR does not touch; the main and #1881 sides conflict there independently of this PR.git diff --checkis clean.- CI at
eccd6d384:changes,scripts,static-checks,macos-native,windows-cliandwebsucceeded;dependenciesandacp-registrywere skipped;verify (linux)was still running at publish. The previous head'swindows-clifailure is now green. - I did not run a local build or test. The four new tests were read statically; the race interleavings in findings 1 and 2 and the evaluation preflight were not reproduced; the web/TUI behavior was checked statically. The exact-head CI will run the new tests, but a green run does not cover the untested paths above.
| if let Err(error) = changes.change(&key, Change::PauseMode).await { | ||
| return Err(HostError::failed(error.to_string())); | ||
| } | ||
| let queued = changes.queued(&key); |
There was a problem hiding this comment.
[P2] The settle withdraws only changes.queued(&key) here, and that list is filled only by Owner::write and Owner::write_if_head (crates/dim-goal/src/branch.rs:541-545, :560-567). A set or resume trigger is not written there: change_inner appends it in the record batch through append_business_if_head (crates/dim-goal/src/branch.rs:757-758), which assigns a new id and never records it, although the trigger would match queued_goal_input (:2805-2811; crates/dim-goal/src/text.rs:379-391, :452-464). Failure: with a turn running, call session.goal.resume or set, then update the mode to an effective shell. The goal is paused and any continuation is withdrawn, but the Queue trigger stays held; when the turn ends it is applied with the shell pin and starts a shell turn carrying the goal instruction, against the design's requirement to withdraw the unapplied set/resume trigger (docs/design/agent-tool-modes.md:139-142, :147-149). The ignored withdrawal errors at :140-148 also let a failed withdrawal pass. Fix: record the trigger id from the append_business_if_head batch in Owner::queued, or query the branch's unapplied Goal Queue inputs at settle time, and surface a failed withdrawal.
There was a problem hiding this comment.
Fixed at c8c98da. change_inner records the trigger id from the batch when it is a queued Goal input (crates/dim-goal/src/branch.rs:765-768), Changes::take_queued drains it under the settle (crates/dim-goal/src/branch.rs:122-130), and a failed session.input.withdraw now fails the update (crates/dim-goal/src/session.rs:140-159). The new goal test holds a turn, queues resume, switches to shell and asserts InputDeleted for the trigger id; I ran it at this head and it passes (goal_suite, 1 passed). The withdrawal is still skipped when the InputQueue already applied the trigger, as the design allows.
| return Ok(()); | ||
| } | ||
| let _gate = self.mode_gate.lock().await; | ||
| if self.tool_mode() != mode || !self.entry_declared(mode) { |
There was a problem hiding this comment.
[P2] The registration settle is skipped before the entry is adopted: entry_declared (:499, implemented at :530-538) reads sources without a refresh, while register (:347-356) only adds to Registrations; refresh (:648-748) is what adopts the entry. A part that calls begin_entry, register and settle_entry in one apply, as the product's ShellToolsPlugin does (crates/dim-agent-capabilities/src/shell_tools.rs:134-143) and the new test helper mirrors (crates/dim-app-server/tests/storage_flow/queue_recovery.rs:36-48), reaches settle_entry with the entry still absent, clears settling (:499-501), and never runs transition.settle. The background task then adopts the entry and publishes the mode (:1165-1181) without the settle. Failure: a Session restored with toolMode: shell, or a shell-mode Session whose execute re-registers, makes shell effective without pausing an active goal; an input applied in the window before the refresh reads effective_tool_mode_now() (crates/dim-agent-capabilities/src/input_queue.rs:287-294; crates/dim-agent-capabilities/src/input_queue/recovery.rs:441-449), which reads the unadopted sources (:547-552), and pins normal, so its turn declares the direct work surface the shell mode hides. The design requires the registration settle before the publish (docs/design/agent-tool-modes.md:129-137). Fix: refresh and adopt under the mode gate before entry_declared, and make the apply path read an adopted projection or trigger the refresh.
There was a problem hiding this comment.
Fixed at c8c98da for the adoption order. entry_declared now refreshes through snapshot() (crates/dim-agent-capabilities/src/tool_registry.rs:529-536), so settle_entry (crates/dim-agent-capabilities/src/tool_registry.rs:494-510) adopts the registration under the gate before it checks and settles. The queue_recovery ModeEntry helper now settles, and the restore test pins shell. Remaining: no test makes execute register after a Session is live and asserts the settle pauses an active goal and withdraws its queued trigger; the path is exercised only during initial apply, where no goal exists yet (P3).
There was a problem hiding this comment.
Still open at 38d10fe, P3. No test registers an entry tool on a live Session with an active goal and asserts that the settle pauses it and withdraws its queued trigger. The path is settle_entry after begin_entry and register (crates/dim-agent-capabilities/src/tool_registry.rs:494-511); only the initial apply exercises it, where a restored goal is paused (crates/dim-goal/src/read.rs:19-31), so active is false and no pause is written. Add a test that registers execute after the Session is live while a goal is active.
There was a problem hiding this comment.
[Still open] The live-registration test is still missing at 42c592e. The original skip is closed, but the refresh that closed it now runs before transition.settle, so shell is effective while the Goal pause is pending; that pre-settle window is P2-1, with the new inline at crates/dim-agent-capabilities/src/tool_registry.rs:505. The activation task added at 42c592e does not cover it, and for a restored goal it hits the same reload pause this thread notes, so it writes nothing. The test should register execute on a live Session with an active goal, apply an input while the settle waits, and assert both the pause and the withdrawn queued trigger in the first shell request.
There was a problem hiding this comment.
[Partially addressed at 49c14ad] The new test the_first_shell_request_in_the_settle_window_carries_the_pause sets settling on the live registry, submits an input, settles, and asserts the first execute request carries the pause; it fails when the wait is removed. It does not register execute live (the fixture registers it at Session start) and it does not assert the withdrawal of a queued Goal trigger in the same window, so the oracle is narrower than this comment asked for. No test covers a failed settle or a later session.tool_mode.get and update after one. The pause half of the P2 is fixed; the remaining gaps are P3-4 in the review.
There was a problem hiding this comment.
[Still open at 12a70b7] No test registers the entry tool live; the window test registers execute at Session start and calls begin_entry and settle_entry by hand. No test covers a failed settle, an open turn whose pin differs from the live mode, or an older pending input, and tool_mode_row, next_tool_mode and the Home guard still have no unit tests.
There was a problem hiding this comment.
Still open at dc94f53. The new commit adds no test: every construction passes tool_mode: None, no test registers the entry tool live with an active goal, no test covers a failed settle, and tool_mode_row, next_tool_mode and the Home guard still have no unit tests.
There was a problem hiding this comment.
[Partly fixed at fa0499f] The settle-specific tests are deleted with the mechanism. Remaining gaps: no test writes or reads the turn/start pin; no test asserts goal_update in a shell request (the unit list at crates/dim-agent-capabilities/src/tool_registry.rs:1178 omits it); no test switches a live Session to an effective shell. Details in the review body.
There was a problem hiding this comment.
Partly fixed at dd973c5: the Goal support leftovers are gone. Remaining gaps: no case covers a switch between two requests of one turn or the request after a tool result reading the live mode again, and the ToolBinding::bind fallback for a request whose adopted list lacks the entry tool has no test. The transport codemode case covers the idle switch to the next request.
| EventKind::InputApplied(data) if data.input_id == held => data.tool_mode, | ||
| _ => None, | ||
| }); | ||
| assert_eq!( |
There was a problem hiding this comment.
[P3] The test does not exercise the rebuild fix. The held input is a second Queue input behind a 5 s wait turn that is open at close (:574-590), so InputQueue::rebuild holds it (crates/dim-agent-capabilities/src/input_queue/recovery.rs:427-431); after restore the in-flight turn ends and the live on_event applies it with effective_tool_mode_now (crates/dim-agent-capabilities/src/input_queue.rs:287-294), not the rebuild release override at crates/dim-agent-capabilities/src/input_queue/recovery.rs:441-449. The test can pass without the fixed line. The helper's settle_entry is also the no-op described in the registration comment. Fix: restore a Session with a single unapplied Queue input and no open turn, or assert the live path separately and add a rebuild-specific case.
There was a problem hiding this comment.
Still open at c8c98da. The new test submits the wait turn first and the held input behind it, so on restore the turn is open, rebuild holds the input (crates/dim-agent-capabilities/src/input_queue/recovery.rs:427-431), and the live on_event applies it after the restored turn ends (crates/dim-agent-capabilities/src/input_queue.rs:285-294). I instrumented both points and reran the test: rebuild released 0 inputs on both rebuilds, the live path applied twice. The fixed release path (crates/dim-agent-capabilities/src/input_queue/recovery.rs:441-449) is not exercised. Close with no open turn and one unreleased queue input, or call rebuild directly.
There was a problem hiding this comment.
[Fixed] The new a_rebuild_releases_a_queued_input_under_the_persisted_mode at 38d10fe creates a shell Session with no input, closes it, appends one Queue input/message at head + 1, restores it and waits idle, then asserts the input/applied for event-{head+1} carries ToolMode::Shell (crates/dim-app-server/tests/storage_flow/queue_recovery.rs:617-682). With no open turn the rebuild releases that input, so the test reaches crates/dim-agent-capabilities/src/input_queue/recovery.rs:441-449; the appended event is at or before the rebuild's through, so the live path cannot produce the record. I forced the release mode to ToolMode::Normal and the test failed at crates/dim-app-server/tests/storage_flow/queue_recovery.rs:674 with Some(Normal) against Some(Shell), then reverted the probe. Withdrawn.
| .lock() | ||
| .unwrap() | ||
| .as_ref() | ||
| .map(|turn| turn.tool_mode) |
There was a problem hiding this comment.
[P3] A manual compaction with no open turn takes ToolMode::default(), which is normal, at :439-445. On a Session whose chosen mode is shell or codemode, session.context.compact while idle builds the summary request from the normal projection (crates/dim-agent-capabilities/src/context_policy.rs:400-410), declaring the tools the mode hides. The running-turn case is fixed; the idle case is not. Fix: fall back to effective_tool_mode_now() when self.turn is None.
There was a problem hiding this comment.
Fixed at c8c98da. The idle manual compaction uses ToolBinding::effective_mode (crates/dim-agent-capabilities/src/agent_loop.rs:439-445), which reads the registry's current effective mode; the running-turn case keeps the turn's pin. The usage path still reads the live mode; see the context_usage thread.
| return Ok(cached.clone()); | ||
| } | ||
| let (tools, sources) = self.registry.snapshot(); | ||
| let (_, sources) = self.registry.snapshot(); |
There was a problem hiding this comment.
[P3] The lookup at :1066 includes the visible tools fingerprint, but on a miss the entry is stored with a sources-only fingerprint (:1078-1084, :1107-1111), so the next lookup cannot match and dynamic_fixed never hits; every usage read runs snapshot and the Timeline query again. The value is correct, but the cache is dead. visible_definitions() at :1059 also uses the live mode (crates/dim-agent-capabilities/src/tool_registry.rs:567-570), not the mode pinned by the turn at through, so a switch during a running turn reprices that turn's request. Fix: store the same versions key, and project with the turn pin.
There was a problem hiding this comment.
Cache fixed, live-mode read remains. The lookup and the stored key now both use the sources plus visible-tools fingerprint (crates/dim-agent-capabilities/src/context_usage.rs:1052-1066, :1100-1106), so dynamic_fixed can hit; the transport_flow codemode test would fail on the old stale return. Still open: current_tools calls visible_definitions(), which projects the live chosen mode (crates/dim-agent-capabilities/src/tool_registry.rs:565-568), not the mode pinned by the turn at through. A usage read for a turn before a switch is repriced with the new mode. Read the applied input's data.tool_mode at or before through (it is on input/applied) and add a usage assertion at an old boundary.
There was a problem hiding this comment.
[Fixed in part] 79d8c1e adds mode_at (crates/dim-agent-capabilities/src/context_usage.rs:1047-1096) and current_tools projects with it (:1111), so a read whose newest applied input is the turn's driving input uses the recorded mode; the codemode usage test passes. Two residuals: the newest applied input can be a mid-turn steer or append, stamped with the live mode at application (crates/dim-agent-capabilities/src/input_queue.rs:287-294) while the turn keeps its pin (crates/dim-agent-capabilities/src/agent_loop.rs:240-247, :560-580, :1655); and with no record the fallback uses the live mode (:1095), not the normal the field doc states (crates/dim-agent-types/src/events.rs:288-290). Both are in the new inlines.
|
1. Shell settle (P2). 2. TUI (P2). 3. Usage and idle compaction (P2/P3). The cache stores the full visible key (it now hits), and an idle manual compaction uses the mode in force from the registry instead of 4. Eval preflight (P2). The normal probe's expected declarations and the static first-request pin exclude 5. Startup preview (P2). P3 docs. Not done (optional): the TUI picker still cycles the advertised modes rather than listing all three marked; PromptSources reads the mode on source reload; |
zerob13
left a comment
There was a problem hiding this comment.
Reviewed 6f78bbc429c09daebb675133f4196ac2e921764b against the previous acceptance criteria. Settings reopen refresh, saved-mode startup preview, and idle compaction now meet their criteria. Normal eval runtime preflight no longer expects execute.
- Settle Goal before the first Shell request. Registration now refreshes before checking and tracks ordinary set/resume triggers. But Shell can become visible before settlement, so the first request can select its inputs before the pause is applied. Verify that this actual request includes the pause text and that held Goal input does not start a turn. Registration · Input selection
- New regression: preserve pending Goal withdrawals across failure. Settlement pauses the Goal, drains all tracked IDs, then attempts withdrawal. If the provider is unavailable, settlement can succeed with work still queued. If a withdrawal errors, retry can skip the paused branch after its remaining IDs have been lost. Verify that a partial failure can be retried and Shell cannot become effective with those inputs still held. Settlement · Tracking
- Reuse the saved choice in ordinary
/new. Starting the next Session from an attached TUI must carry the last successfully saved mode. That path still omits it. Creation paths - Update
/usagefor already adopted tools. An idle mode switch must update the visible tool count without requiring a model turn or tool-source change. The adopted path still bypasses projection. Usage read
Separately, the native model-probe assertion still expects the full RUN_TOOLS list, including Shell-only execute, from a Normal request. The assertion should reflect Normal mode. Exact-head Linux CI was still running at review. The behavioral findings above are static.
yyhhyyyyyy
left a comment
There was a problem hiding this comment.
Reviewed the full merge-base...head diff at c8c98da9 (87 files, +2427/-110, base a22915de; origin/main c68dad5a), including the four fix commits and the new test commit. Scope: the Session tool mode of #2135, namely the persisted choice and the two Session methods, the ToolRegistry visible/delegated projection and ModeTransition, origin-based admission, the turn pin through compaction and rebuild, Goal settle/pause/withdrawal on an effective shell transition, the product shell profile, and the web/TUI controls.
Verdict: REQUEST_CHANGES.
Prior review status (review 6068168300)
- P2-1, the shell settle did not withdraw a
set/resumetrigger: fixed.change_innerrecords the trigger id from the batch (crates/dim-goal/src/branch.rs:765-768),Changes::take_queueddrains it under the settle (crates/dim-goal/src/branch.rs:122-130), and a failed withdrawal now fails the update (crates/dim-goal/src/session.rs:140-159). The new test holds a turn, queuesresume, switches to shell and assertsInputDeletedfor the trigger id; I ran it at this head and it passes. - P2-2, the registration settle was skipped before adoption: fixed in code.
entry_declaredrefreshes throughsnapshot()(crates/dim-agent-capabilities/src/tool_registry.rs:529-536), sosettle_entry(:494-510) adopts the registration under the gate before it checks and settles. The new test helper settles and the restore test passes with shell pinned. No test makes a late registration pause an active goal (P3 below). - P2-3, the CLI contract text: remains in part. The added text now matches the TUI for the cycle and the row, but it still contradicts the feature design on the picker. See finding 2.
- P2-4, the evaluation preflight: fixed. The normal probe expectation excludes the normal-hidden entry tools (
xtask/src/scenario_eval.rs:3704-3708), the static first-request pin does too (:17299), andc8c98da9re-baselines the native probe test (:20514-20529). The preflight no longer aborts before the judged turn. The new commit changes only the test expectation, which matches the design's normal projection; see the P3 coverage note. - P3 usage cache never hits: fixed. The lookup and the stored key now both use the sources plus visible-tools fingerprint (
crates/dim-agent-capabilities/src/context_usage.rs:1052-1066,:1100-1106). - P3 idle manual compaction defaulted to normal: fixed (
crates/dim-agent-capabilities/src/agent_loop.rs:439-445). - P3
Goal.mdandCodeMode.mdlacked the new owner contracts: fixed (Appendix H and Admission by origin). - P3 trigger withdrawal was not tested: fixed by the new goal test. The other test gaps remain (P3 below).
Blocking findings
1. P2: the TUI does not send the saved tool mode on /new after a Session. The saved mode is added only in session_create_from_options (crates/dim-cli/src/lib.rs:590-595). Worker::start_session calls that function only when initial is true (crates/dim-cli/src/session_host.rs:939-948); after any attached Session, home() (crates/dim-cli/src/session_host.rs:2847-2866) leaves model and model_session set, so a /new returns Home with initial == false. The else branch builds session_create_params (crates/dim-cli/src/lib.rs:576-582, no mode) and adds modelFromSession (crates/dim-cli/src/session_host.rs:977-980). The row update saves the choice (crates/dim-cli/src/ui/tui.rs:2792-2796), but the next creation ignores it. Failure: select shell in /settings, run a turn, /new, send the first message; the new Session is created without toolMode and starts normal, so the operator's remembered choice is silently dropped. The design requires both clients to send the remembered choice on the next creation (docs/design/agent-tool-modes.md:374-381). Fix: add the same offered saved-mode member in the else branch, or move the injection into session_create_params and gate it where the client is available; add a flow that updates a mode, runs /new, and reads the new Session's mode.
2. P2: the CLI contract and the feature design disagree on the picker. docs/design/cli-commands.md:975-981 now says Enter cycles the modes the daemon advertises. The TUI does that (crates/dim-cli/src/ui/tui.rs:9814-9820; the available set comes from crates/dim-cli/src/session_host.rs:737-745). The feature design requires the picker to list all three modes and show an unavailable one as marked (docs/design/agent-tool-modes.md:398-402, :241-245). The web lists all three and marks them (web/src/features/chat/ComposerToolModeMenu.vue:12-18); the TUI omits them. Failure: on a daemon that advertises a subset, an operator cannot see that a mode exists but is unavailable, and the two contract pages promise different pickers. AGENTS.md makes the feature design authoritative until it is changed with maintainer agreement. Fix: cycle all three in the TUI and mark the unavailable ones like the web, or update agent-tool-modes.md sections 4 and 8 to the advertised-only behavior and keep both pages consistent. The row wording is now consistent, so only the picker remains.
P3
/settingsis available at Home (crates/dim-cli/src/ui/commands.rs:173,Needs::Nothing). The addedCommand::ReadToolMode(crates/dim-cli/src/ui/tui.rs:5141) then callssession.tool_mode.getwith an empty session id (crates/dim-cli/src/session_host.rs:748-766); the App Server requires a session id (crates/dim-app-server/src/connection.rs:560-585) and answers invalid, so opening/settingsbefore the first Session shows atool mode: ...notice. Enter on the row sends an update with the same empty id and fails again. Skip both whensession_idis empty.docs/design/cli-commands.md:975-976still says the panel reads the mode when it first opens.ce742a6a5now reads on every/settingsopen (crates/dim-cli/src/ui/tui.rs:5141); update the sentence.- The new commit only re-baselines the native probe test.
RUN_TOOLSstill listsexecute, andNORMAL_HIDDENnow filters it from the product expected set (xtask/src/scenario_eval.rs:3704-3708), the static pin (:17299) and the native probe test (:20514-20529). The product still hidesexecutein normal (crates/dim-agent-capabilities/src/tool_registry.rs:1025-1030), so the filter is right for a normal probe and consistent with the design. The cost is coverage: every eval check forexecuteis now filtered, so a product that no longer registeredexecutewould keep the eval green, and the only shell-surface run left is the minimal-execution profile. If the run list's guarantee that a listed tool the product stopped serving fails a check should coverexecute, add a shell-mode probe or assert the mount list's registration. The test's doc comment still calls the set "the run list" (:20495-20499). - Tests: trigger withdrawal is now pinned and passes. Still unpinned: the rebuild release line (I instrumented both apply paths and reran the restore test: rebuild released 0 inputs on both rebuilds, the live path applied twice), a late registration that makes shell effective with an active goal, the member's effective mode and a later creator switch, a running-turn request after a switch (the codemode test switches between turns), and a cache hit (the reprice test proves only the miss path). There is also no flow that creates a product-profile shell Session and asserts its request declares
execute,ask_userandrecallas the design's verification section requires; the only shell run is the minimal profile withexecute. ToolBinding::effective_modewas inserted under the existingbinddoc comment (crates/dim-agent-capabilities/src/tool_binding.rs:81-84), sobind(:93) now has no doc andeffective_modecarries a sentence about handler pinning. Move thebindsentence back abovebind; this is the same stacking the previous round found indefaults.rs.current_toolsreads the live mode throughvisible_definitions()(crates/dim-agent-capabilities/src/context_usage.rs:1059;crates/dim-agent-capabilities/src/tool_registry.rs:565-568), not the mode pinned by the turn atthrough. A usage read for a turn before a mode switch is repriced with the new mode. The applied record carriestool_mode; use the applied input at or beforethrough.- Optional, still open from the previous round: PromptSources follows the mode only on a source reload; the TUI does not re-read while the settings panel stays open after another client switches;
Owner::queuedgrows between shell settles;saved_tool_modevalidates the raw string against three literals instead of parsingToolModeat the boundary (crates/dim-cli/src/configure.rs:15-19,crates/dim-cli/src/lib.rs:592).
Merge, CI and verification
git merge-tree --write-treeatc8c98da9is clean with origin/mainc68dad5a, #21744f59f2fa, #220645c02dd4, #2210d99838e1, #2211ae694e9fand #2212cdba6df2. The only conflict is #1881ff9825d2indocs/design/plugins/Report.md; origin/main and #1881 conflict in that file independently, and this PR does not touch it.- CI at
c8c98da9:changes,static-checks,scripts,macos-native,webandwindows-clisucceeded. Oneverify (linux)run failed inRun compiled workspace tests:managed_oauth_flow::the_managed_grok_route_takes_only_the_native_xai_image_formatstimed out waiting for its device login (506 passed, 1 failed). That flow is away from this PR's paths, but the head is not green. The secondverify (linux)andverify (macos)were still running at review time, so there is no exact-head green.dependenciesandacp-registryare skipped in one suite. At6f78bbc4the verify runs were cancelled andci-okfailed on the cancelled suite. - Ran
cargo test --locked -p dim-goal --test goal_suite an_effective_shell_update_withdraws_a_queued_resume_trigger(1 passed) andcargo test --locked -p dim-app-server --test app_server_flow a_first_time_application_after_restore_takes_the_persisted_mode(1 passed) with HOME, TMPDIR and XDG under the review data directory andLC_ALL=en_US.UTF-8. To check the rebuild claim I instrumented both apply paths and reran the restore test; the probe edits are reverted and the worktree is clean. No residual processes. - Not run: the eval suite (the new commit claims 213 passed), the web suite, the transport tests, and
session_tool_mode_flow(its Home uses a literal/tmp, which my review constraints exclude). The/newpath and the client behavior were read statically.
Withdrawn
- Withdraw P2-1 and P2-2 as blocking findings; both are fixed. Withdraw P2-4 as a blocking finding; the eval no longer aborts, and the new commit is a test re-baseline only.
- Withdraw the P3s for the usage cache never hitting, the idle manual compaction defaulting to normal, the missing
Goal.mdandCodeMode.mdcontracts, and the untested trigger withdrawal. - Keep the P3s for
visible_definitionsusing the live mode, the remaining test gaps, the eval coverage loss forexecute, and the optional items above.
| ) -> Result<serde_json::Value> { | ||
| let mut params = session_create_params(options); | ||
| if client.offers("session.create.toolMode") | ||
| && let Some(mode) = crate::configure::saved_tool_mode(&options.home) |
There was a problem hiding this comment.
[P2] This block is the only place the saved mode reaches a creation, and only session_create_from_options runs it. Worker::start_session uses that function when initial is true (crates/dim-cli/src/session_host.rs:939-948); after any attached Session, home() (crates/dim-cli/src/session_host.rs:2847-2866) keeps model and model_session, so /new takes the else branch: session_create_params (crates/dim-cli/src/lib.rs:576-582, no mode) plus modelFromSession (crates/dim-cli/src/session_host.rs:977-980). Failure: choose shell in /settings, run a turn, /new, send the first message; the new Session is created without toolMode and starts normal, although the choice is saved (crates/dim-cli/src/ui/tui.rs:2792-2796). The design requires the remembered choice on the next creation (docs/design/agent-tool-modes.md:374-381). Fix: add the same offered saved-mode member in the else branch, or move the injection into session_create_params and gate it where the client is available; add a flow that updates a mode, runs /new, and reads the new Session's mode.
|
|
||
| `/settings` exposes the `Tool mode` row under Tools. It reads the shown | ||
| Session's mode with `session.tool_mode.get` when the panel first opens and | ||
| cycles the modes the daemon advertises with Enter — `normal` always, and |
There was a problem hiding this comment.
[P2] This text now matches the TUI: it cycles the advertised modes (crates/dim-cli/src/ui/tui.rs:9814-9820, available set from crates/dim-cli/src/session_host.rs:737-745). The feature design requires the picker to list all three modes and show an unavailable one as marked (docs/design/agent-tool-modes.md:398-402, :241-245). The web lists all three and marks them (web/src/features/chat/ComposerToolModeMenu.vue:12-18); the TUI omits them. Failure: on a daemon that advertises a subset, an operator cannot see that a mode exists but is unavailable, and the two contract pages promise different pickers. AGENTS.md makes the feature design authoritative until it is changed with maintainer agreement. Fix: cycle all three in the TUI and mark the unavailable ones like the web, or update agent-tool-modes.md sections 4 and 8 and keep both pages consistent. The row wording is now consistent, so only the picker remains.
| self.host.send(Command::ReadSuggestionSetting); | ||
| } | ||
| self.host.send(Command::ReadPromptSettings); | ||
| self.host.send(Command::ReadToolMode); |
There was a problem hiding this comment.
[P3] /settings is available at Home (crates/dim-cli/src/ui/commands.rs:173, Needs::Nothing). This send then calls session.tool_mode.get with an empty session id (crates/dim-cli/src/session_host.rs:748-766); the App Server requires a session id (crates/dim-app-server/src/connection.rs:560-585) and answers invalid, so opening /settings before the first Session shows a tool mode: ... notice. Enter on the row sends an update with the same empty id and fails again. Skip the read and the set when session_id is empty.
| /// before the run's own Sessions, which mount the name but do not declare or | ||
| /// call it, so their judged Timeline carries no source adoption. | ||
| /// Tools `RUN_TOOLS` mounts that a default (normal) probe never declares. | ||
| const NORMAL_HIDDEN: [&str; 2] = ["codemode", "execute"]; |
There was a problem hiding this comment.
[P3] The new commit only re-baselines the probe expectation. RUN_TOOLS still lists execute, and this filter removes it from the product expected set (xtask/src/scenario_eval.rs:3704-3708), the static pin (:17299) and the native probe test (:20514-20529). The product still hides execute in normal (crates/dim-agent-capabilities/src/tool_registry.rs:1025-1030), so filtering a normal probe is right and matches the design. The cost is coverage: every eval check for execute is now filtered, so a product that no longer registered execute would keep the eval green, and the only shell-surface run left is the minimal-execution profile. If the run list's guarantee that a listed tool the product stopped serving fails a check should cover execute, add a shell-mode probe or assert the mount list's registration. The native probe test's doc comment still calls the set the run list (:20495-20499).
| impl ToolBinding { | ||
| /// Fixes the handlers of `request_id` to the tools its prefix (through | ||
| /// `through`) adopted, then releases the pins no later prefix declares. | ||
| /// The mode in force for a step with no open turn. |
There was a problem hiding this comment.
[P3] The two doc lines above (crates/dim-agent-capabilities/src/tool_binding.rs:81-82) describe bind, and this added line stacks a second doc block on effective_mode; bind (:93) is left without a doc. Move the bind sentence back above bind. This is the same stacking the previous round found in defaults.rs and it was fixed there.
|
1. Pause before the first shell request. A 2. Withdrawal retry. The settle no longer drains the tracked ids: each successful withdrawal forgets its id, and the first failure returns an error with the remaining ids kept. A retry processes a paused branch (the pause is only written for an active goal) and withdraws its remaining inputs; a missing input queue fails the update rather than silently leaving work held. 3. 4. Usage for adopted tools. The adopted-configuration path now computes the visible fixed cost and adjusts the provider total; when it equals the configuration's cost the provider baseline is kept, so a mode-only switch reprices and an unchanged mode does not.
|
|
1. 2. TUI picker (P2). 3. P3. Open from the P3 list: usage uses the live mode rather than the turn's pin at |
zerob13
left a comment
There was a problem hiding this comment.
Reviewed 76a945c14f5e0976b19214634f166179a496758d. Ordinary /new, adopted-tool usage, and live-owner withdrawal retry now meet their criteria. The Normal probe assertion also matches the mode in source. Remaining criteria concern the same Shell transition:
- The first Shell request must consume the Goal pause. Registration still exposes the mode before settlement finishes; an input in that interval can pin Shell and select request inputs that omit the pause. Verify the first actual Shell request under concurrent registration/input includes the pause text and held Goal work does not start a turn. Registration · Request selection
- New failure path in the pause wait. A failed wait can leave the pause recorded but not confirmed applied. Retrying sees an already-paused Goal and skips the wait. Verify that retry cannot make Shell effective before the required pause is applied and remaining held work is settled. Pause wait · Retry
These are static findings. Exact Linux CI was still running at review.
|
Remaining open P3s: the eval no longer asserts |
|
Still unpinned: a late registration pausing an active goal, a running-turn switch, the usage cache hit, and the eval's |
The registration settle can run before the Goal branch owners load, so a restored or late-loaded shell branch pauses its active goal at activation, making the first request after it carry the pause. The Goal suite is 148 green. Refs #2135
- try_start is deferred while a registration is settling, so the turn's consumed inputs include the pause the settle writes; a settle failure keeps the mode's projection normal. - The activation task is removed; the design records that a restored shell Session's goal is paused by the reload rule, not the mode pause. - The usage pin query takes the earliest non-append applied input after the last turn end, matching the first pending input try_start pins. Refs #2135
- Remove the imports and binding the activation task left, and assert the settle result in the window test; workspace clippy is green. - Drop settle_failed: a failed registration fails the part's build, whose rollback removes the entry, so no live projection needs the flag. - The usage pin query is ascending (the earliest pending input). - The settle wait selects on the Loop lifecycle, and rebuild routes through start_when_settled. Refs #2135
- turn/start carries the turn's tool mode; usage reads it for an open turn, so a carryover input applied before the end cannot reprice the turn. - A failed registration settle marks the mode and the effective views, the request binding and usage project normal until a later settle succeeds. - The design records the turn/start pin. Refs #2135
Shell is a tool surface, not a reason to pause a goal: goal_update is one of the dialogue tools every non-normal mode keeps, so a goal can be completed or blocked in shell and a mode switch does not touch Goal state. - Remove the ModeTransition service, the Goal settle handler and its pause text, queued-trigger withdrawal, pause wait and shell refusals. - Remove the entry-registration settle and its turn-start wait; the repair recovery reads the adopting effective mode. - Remove the Goal shell tests and the design's Goals-in-shell section, flows and requirements. Refs #2135
The usage counter now reads the tools the last model request declared instead of projecting the registry's live mode, so a mode switch cannot reprice the wrong request. The turn pin stays in the Loop, taken from the live effective mode when the Dispatcher applies the input; a rebuild starts pending inputs under the effective mode then. - Remove mode_at and the usage's visible_for read. - Remove TurnStartData.toolMode and InputAppliedData.toolMode and their writers, readers and test fixtures; the InputQueue no longer injects the registry. Refs #2135
The mode is Session configuration, not a Timeline or per-turn fact: a request reads the live effective mode when it is prepared, a switch applies to the next request, and a request already being prepared keeps what it read. The Turn and Applied records carry no mode. - Bind a request against the tools it was adopted with, so an adopted surface never waits on a provider refresh. - Serialize an update's record write and live replacement under the registry's update gate, so overlapping updates cannot leave them disagreeing. - shell declares execute, ask_user, goal_update and recall in the design tables, section 10 flow, type doc, comment and projection unit test; section 6 and the Loop/ToolRegistry pages follow the live read. Refs #2135
- Revert the Goal timeline queries to their committed bound. - Remove the unused Goal fixture helper and stale comment. - Restore Goal.md's trailing newline. - Assert the applied record without the removed tool_mode member. Refs #2135
zerob13
left a comment
There was a problem hiding this comment.
Reviewed the delta at dd973c5599cb9dd2f7afb0b40a8d26e363e00cf2. The adopted binding no longer waits on live provider refresh, and the update gate now orders the persisted and live writes. Those two code findings are closed by inspection.
- Keep usage tied to the actual request, including schema-only changes. The new path reads declarations from the last request, but a usage lookup after source adoption can cache the previous request's cost under the new source version. The first new request can then reuse that cost if its tool name and description stay the same while its schema changes. Verify that usage follows the latest declaration in that sequence. Cache
- Resolve the mid-turn mode contract. A mode switch can now change the next model request inside a turn that already started, including the follow-up to an in-flight tool. The accepted design pins the mode through that turn. Keep the accepted behavior, or record an explicit decision to switch at request boundaries and align the design and PR description. Verify the chosen behavior for the tool follow-up and for recovery. Preparation · Current design
These are static findings. The PR currently conflicts with main in the Code Mode test fixture; there is no CI for an applicable merge of this head.
yyhhyyyyyy
left a comment
There was a problem hiding this comment.
Reviewed the full main...head diff at dd973c5599cb9dd2f7afb0b40a8d26e363e00cf2 (68 files, +1827/-253, merge base a22915de5). origin/main moved from 3a8113c9c to a8d84e93 while I reviewed, with #2229 and #2202 merged. Scope: the Session tool mode of #2135, namely the persisted choice and the two Session methods, the ToolRegistry visible and delegated projection, origin-based admission, the live mode read at request preparation, the product shell profile, the web and TUI controls, and usage pricing. The last two commits remove the turn's recorded mode, read the live effective mode when a request is prepared, add the update gate, and fix the shell doc, the projection test, the stale tool_mode assertion and the Goal leftovers.
Verdict: REQUEST_CHANGES. The functional path is coherent and the earlier failing test is fixed, but the design page still describes the removed recorded pin in three places, its shell tables and flow still omit goal_update, and the head no longer merges with current main.
Blocking
1. P2: the design page still requires the recorded per-input pin that the code removed
Problem: docs/design/agent-tool-modes.md:162-168 now says the Loop reads the live effective mode when it prepares a request, a switch applies to the next request prepared after it, and a request after a tool result reads again. docs/architecture/rust-agent/plugins/Loop.md:110-115 and docs/architecture/rust-agent/plugins/ToolRegistry.md:51-52 agree. The same design page still says:
- section 5,
:197-198: "The InputQueue records it when it applies an input"; - section 10,
:376-378: a turn deferred for compaction or recovered after a restart "uses the mode recorded at application; a switch after the application does not change it"; - section 12,
:436-438: the Loop should "Record the effective mode when the input is applied, at its serial position" and "its page gains the turn's mode pin", and:441says "the Loop holds the turn's mode pin".
The code records no mode on the input or the turn: InputAppliedData has no tool mode (crates/dim-agent-types/src/events.rs:277-288), the InputQueue writes the applied event without reading the registry (crates/dim-agent-capabilities/src/input_queue.rs:275-284, crates/dim-agent-capabilities/src/input_queue/recovery.rs:64-71), and start_preparation reads binding.effective_mode() when the request is prepared (crates/dim-agent-capabilities/src/agent_loop.rs:1213).
Failure: a test or implementation written from section 5 or the section 10 flow expects a pending input's mode to survive compaction or a restart and to ignore a later switch; the head instead reads the mode at preparation, so the same input declares the switched mode. The page contradicts itself about the feature's central ordering rule.
Fix: update section 5, the section 10 flow, section 12 and the closing ownership sentence to the live-read model. If the recorded pin is still intended, the code and Loop.md need to revert instead; the page and the code must agree.
2. P2: the shell tables and the section 10 flow still omit goal_update
Problem: the code declares execute, ask_user, goal_update and recall in shell (crates/dim-agent-capabilities/src/tool_registry.rs:918), the type doc and the projection unit test now include it (crates/dim-agent-types/src/tool_mode.rs:16-18, crates/dim-agent-capabilities/src/tool_registry.rs:1182), and the design prose includes it at docs/design/agent-tool-modes.md:108, :331 and :431. The design still lists three in the section 2 opening (:92-93), the section 2 table (:99), the section 4 table (:149) and the section 10 flow (:360).
Failure: the section 10 flow implemented literally asserts that shell declares only execute, ask_user and recall; the actual request also declares goal_update, so the acceptance test fails. A later change made against either table or the opening sentence removes goal_update from shell, and a goal can no longer be completed or blocked there, contradicting :331 and :431.
Fix: add goal_update to the section 2 opening, both tables and the section 10 flow.
Live semantics checked
The new live read is internally consistent for the cases the design names:
- Mid-turn switch: each request reads the live mode at preparation (
crates/dim-agent-capabilities/src/agent_loop.rs:1213); a request already in preparation keeps the read, and an admitted call finishes. This matches section 3:124and section 4:162-168; section 5 and section 10 are the stale pages. - Compaction: a request deferred for a compaction step is prepared after the step and reads the then-live mode. Section 4 matches; the section 10 flow at
:376-378does not. - Retries:
start_preparationreturns a recovered source request before binding (agent_loop.rs:1215-1222), so an in-process budget recovery keeps the tools it read, and a provider retry reuses the same request. Matches section 4:166-168. - Rebuild and process restart: restored pending inputs carry no mode; the next request reads the live mode, and an in-flight request is settled rather than reissued. Matches section 4; the section 10 flow and section 12 do not.
- Stale pending after a stop: the stale steer no longer selects a mode, because no mode is stored on the turn or the input; the next request reads the live mode. The stale input's text still joins the next request, which is the existing steer behavior, not a mode defect.
ToolBindingfallback:bindchecks the entry tool against the request's adopted tools (crates/dim-agent-capabilities/src/tool_binding.rs:106-112), andprojectapplies the same fallback again (crates/dim-agent-capabilities/src/tool_registry.rs:925-933), so the pre-check is redundant but consistent.bind_current(tool_binding.rs:131-142) andprepare(:144-155) still go throughproject, which falls back against their declared set;session.tool_mode.getkeeps reporting the registry's effective mode. No dead path and no different result.
Merge status
The head does not merge with current origin/main a8d84e93: crates/dim-codemode/tests/flow.rs conflicts, and GitHub reports MERGEABLE=false, mergeable_state=dirty. Rebase and resolve that file. Textual merges with #2174 c27898de, #2206 68ff0118, #2226 244d231b and #2227 e0281915 are clean.
Optional (P3)
- The PR body still describes the recorded mode,
ModeTransition, the registration settle, the Goal settle and their tests, all removed. Update it before merge. docs/design/plugins/ContextUsage.md:61still says the fixed tools come from the configuration or the registry's current declarations; usage now prefers the last model request's declarations and falls back to the live projection (crates/dim-agent-capabilities/src/context_usage.rs:1047-1094,:1108-1111). State the new source, and note that an open turn before its first request prices the live mode rather than the request it will build.- Test gaps: no case covers a switch between two requests of one turn, or a request after a tool result reading the live mode again. The
ToolBinding::bindfallback for a request whose adopted list lacks the entry tool has no test. The transportcodemodecase covers the idle switch to the next request (crates/dim-app-server/tests/transport_flow/codemode.rs:270-300). - Cross-PR: #2206
68ff0118removesexec_stop.rsandExecStop, while this head adds("execStop", "control")atcrates/dim-app-server/src/lib.rs:1692anddocs/architecture/rust-agent/plugins/ShellSession.md:6says the part providesdyn ExecStop. Whichever merges second must drop the face and update the page.
Fixed at this head
- The workspace test failure found at
a9c1059ais fixed:shell_input.rsno longer expectstool_mode. The exact test passes at this head. - The turn pin finding is fixed by removal: the turn carries no mode,
turn/starthas notool_mode, and every request reads the live effective mode at preparation. The stale pending input no longer selects a mode. - The
visible_undercomment, theToolMode::Shelldoc and the projection unit test now includegoal_update; section 6's contradictory opening is deleted; section 11 rule 7 names the update gate. Section 7.2 still reads "The mode gate is a update gate is a synchronization primitive" (:420-421), a one-word leftover. - The Goal test-support comment and the unused
new_session_with_modeare removed, andGoal.md's trailing line is dropped. - The settle,
settle_failed, update-path skip and Goal settle threads remain fixed by removal.
Verification
cargo test --locked --offline -p dim-app-server --test transport_flow a_recorded_run_is_one_append_input_for_the_next_requestat this head: 1 passed, 0 failed (it failed ata9c1059a).cargo test --locked --offline -p dim-agent-capabilities --lib the_mode_projects_the_callable_setat this head: 1 passed, 0 failed.- Findings 1 and 2 are static; every cited line was read at this head.
- Not run: the full workspace suite and a live mid-turn switch after a tool result.
CI
At this head GitHub reports no check runs for dd973c55 yet. The previous head c0223bad (45802422092) ended with verify (linux) failing on two tests: transport_flow::shell_input::a_recorded_run_is_one_append_input_for_the_next_request, whose stale tool_mode assertion this head removes, and transport_flow::web::web_search_is_declared_at_the_next_request_after_the_added_service_is_adopted. Both pass at this head in the isolated worktree, 1 passed each (the first was part of the review run, the second is a 1.22 s run). changes, macos-native, scripts, static-checks, web and windows-cli passed at the previous head. The PR is open, not a draft, and mergeable_state=dirty.
| restart, uses the mode recorded at application; a switch after the application does not change it. | ||
| A turn that pins `shell` waits for the committed pause text to be adopted before its first | ||
| request, and the Dispatcher keeps running while it waits. | ||
| restart, uses the mode recorded at application; a switch after the application does not change |
There was a problem hiding this comment.
[P2] This flow still requires the mode recorded at application, but this head removed it. The InputQueue writes input/applied without a mode (crates/dim-agent-capabilities/src/input_queue.rs:275-284, crates/dim-agent-capabilities/src/input_queue/recovery.rs:64-71), and start_preparation reads the live effective mode when the request is prepared (crates/dim-agent-capabilities/src/agent_loop.rs:1213). Section 4 above (:162-168), Loop.md:110-115 and ToolRegistry.md:51-52 describe that live read. A deferred or rebuilt request therefore uses the mode at preparation, not at application. Update this flow, section 5 :197-198, section 12 :436-438 and :441 to the same model, or restore the recorded pin in the code and the three pages.
| waits. | ||
| Its page gains the turn's mode pin. Its owner carries this into | ||
| [Loop](../architecture/rust-agent/plugins/Loop.md). | ||
| - **Loop.** Record the effective mode when the input is applied, at its serial position; a rebuild |
There was a problem hiding this comment.
[P2] Section 12 still tells the Loop to record the mode at the input's serial position and says the Loop page gains the turn's mode pin, but the Loop page now says a request declares the live effective mode at preparation (docs/architecture/rust-agent/plugins/Loop.md:110-115), and no code records a pin: Turn and Applied carry no tool mode, and start_preparation reads binding.effective_mode() (crates/dim-agent-capabilities/src/agent_loop.rs:1213). Rewrite this bullet and the closing the Loop holds the turn's mode pin at :441 to the live read.
dd973c5 to
44e1920
Compare
yyhhyyyyyy
left a comment
There was a problem hiding this comment.
Reviewed the full main...head diff at 44e192004161bc6da8a55d712fffc62a28307bd2 (68 files, +1827/-253, merge base a8d84e93). The head was rebased from dd973c55 onto current origin/main a8d84e93; the patch content is unchanged. Scope: the Session tool mode of #2135, namely the persisted choice and the two Session methods, the ToolRegistry visible and delegated projection, origin-based admission, the live mode read at request preparation, the product shell profile, the web and TUI controls, and usage pricing. The last two commits remove the turn's recorded mode, read the live effective mode when a request is prepared, add the update gate, and fix the shell doc, the projection test, the stale tool_mode assertion and the Goal leftovers.
Verdict: REQUEST_CHANGES. The functional path is coherent and the earlier failing tests are fixed, but the design page still describes the removed recorded pin and a stale switch timing, and its shell tables and flow still omit goal_update.
Blocking
1. P2: the design page still requires the recorded per-input pin that the code removed
Problem: docs/design/agent-tool-modes.md:162-168 now says the Loop reads the live effective mode when it prepares a request, a switch applies to the next request prepared after it, and a request after a tool result reads again. docs/architecture/rust-agent/plugins/Loop.md:110-115 and docs/architecture/rust-agent/plugins/ToolRegistry.md:51-52 agree. The same design page still says:
- section 5,
:197-198: "The InputQueue records it when it applies an input"; - section 8,
:329-330: "A switch takes effect from the next applied input"; - section 10,
:376-378: a turn deferred for compaction or recovered after a restart "uses the mode recorded at application; a switch after the application does not change it"; - section 12,
:436-438: the Loop should "Record the effective mode when the input is applied, at its serial position" and "its page gains the turn's mode pin", and:441says "the Loop holds the turn's mode pin".
The code records no tool mode on the input or the turn: InputAppliedData has no tool mode (crates/dim-agent-types/src/events.rs:277-288; its mode is the input mode, queue, steer or append, at :7-15), the InputQueue writes the applied event without reading the registry (crates/dim-agent-capabilities/src/input_queue.rs:275-284, crates/dim-agent-capabilities/src/input_queue/recovery.rs:64-71), and start_preparation reads binding.effective_mode() when the request is prepared (crates/dim-agent-capabilities/src/agent_loop.rs:1213).
Failure: a test or implementation written from section 5 or the section 10 flow expects a pending input's mode to survive compaction or a restart and to ignore a later switch; the head instead reads the mode at preparation, so the same input declares the switched mode. A test written from section 8 waits for an applied input before expecting the new mode; the head applies a switch to the next request prepared after it, which can happen mid-turn. The page contradicts itself about the feature's central ordering rule.
Fix: update section 5, section 8, the section 10 flow, section 12 and the closing ownership sentence to the live-read model. If the recorded pin is still intended, the code and Loop.md need to revert instead; the page and the code must agree.
2. P2: the shell tables and the section 10 flow still omit goal_update
Problem: the code declares execute, ask_user, goal_update and recall in shell (crates/dim-agent-capabilities/src/tool_registry.rs:918), the type doc and the projection unit test now include it (crates/dim-agent-types/src/tool_mode.rs:16-18, crates/dim-agent-capabilities/src/tool_registry.rs:1182), and the design prose includes it at docs/design/agent-tool-modes.md:108, :331 and :431. The design still lists three in the section 2 opening (:92-93), the section 2 table (:99), the section 4 table (:149) and the section 10 flow (:360).
Failure: the section 10 flow implemented literally asserts that shell declares only execute, ask_user and recall; the actual request also declares goal_update, so the acceptance test fails. A later change made against either table or the opening sentence removes goal_update from shell, and a goal can no longer be completed or blocked there, contradicting :331 and :431.
Fix: add goal_update to the section 2 opening, both tables and the section 10 flow.
Live semantics checked
The new live read is internally consistent for the cases the design names:
- Mid-turn switch: each request reads the live mode at preparation (
crates/dim-agent-capabilities/src/agent_loop.rs:1213); a request already in preparation keeps the read, and an admitted call finishes. This matches section 3:124and section 4:162-168; section 5 and section 10 are the stale pages. - Compaction: a request deferred for a compaction step is prepared after the step and reads the then-live mode. Section 4 matches; the section 10 flow at
:376-378does not. - Retries:
start_preparationreturns a recovered source request before binding (agent_loop.rs:1215-1222), so an in-process budget recovery keeps the tools it read, and a provider retry reuses the same request. Matches section 4:166-168. - Rebuild and process restart: restored pending inputs carry no mode; the next request reads the live mode, and an in-flight request is settled rather than reissued. Matches section 4; the section 10 flow and section 12 do not.
- Stale pending after a stop: the stale steer no longer selects a mode, because no mode is stored on the turn or the input; the next request reads the live mode. The stale input's text still joins the next request, which is the existing steer behavior, not a mode defect.
ToolBindingfallback:bindchecks the entry tool against the request's adopted tools (crates/dim-agent-capabilities/src/tool_binding.rs:109-113), andprojectapplies the same fallback again (crates/dim-agent-capabilities/src/tool_registry.rs:925-933), so the pre-check is redundant but consistent.bind_current(tool_binding.rs:131-142) andprepare(:144-155) still go throughproject, which falls back against their declared set;session.tool_mode.getkeeps reporting the registry's effective mode. No dead path and no different result.
Merge status
With current origin/main a8d84e93 the head merges cleanly: GitHub reports MERGEABLE=true, and mergeable_state=blocked is the review gate. The dd973c55 conflict in crates/dim-codemode/tests/flow.rs is gone with the rebase. At this head #2174 673342a0 and #2206 68ff0118 merge clean; #2226 244d231b conflicts in crates/dim-app-server/tests/transport_flow/branch_typescript.rs and #2227 e0281915 in crates/dim-app-server/src/agents.rs; those branches predate main a8d84e93 and its #2202 changes, so the conflicts are with main, not with this PR's edits.
Optional (P3)
- The PR body still describes the recorded mode,
ModeTransition, the registration settle, the Goal settle and their tests, all removed. Update it before merge. docs/design/plugins/ContextUsage.md:61still says the fixed tools come from the configuration or the registry's current declarations; usage now prefers the last model request's declarations and falls back to the live projection (crates/dim-agent-capabilities/src/context_usage.rs:1047-1094,:1108-1111). State the new source, and note that an open turn before its first request prices the live mode rather than the request it will build.- Test gaps: no case covers a switch between two requests of one turn, or a request after a tool result reading the live mode again. The
ToolBinding::bindfallback for a request whose adopted list lacks the entry tool has no test. The transportcodemodecase covers the idle switch to the next request (crates/dim-app-server/tests/transport_flow/codemode.rs:270-300). - Cross-PR: #2206
68ff0118removesexec_stop.rsandExecStop, while this head adds("execStop", "control")atcrates/dim-app-server/src/lib.rs:1692anddocs/architecture/rust-agent/plugins/ShellSession.md:6says the part providesdyn ExecStop. Whichever merges second must drop the face and update the page. - Agree with the two findings in the independent
dd973c55review: the usage cache key covers tool names and descriptions but not the tool schema (crates/dim-agent-capabilities/src/context_usage.rs:1112-1118), and the mid-turn mode contract; the contract half is finding 1 above.
Fixed at this head
- The two workspace test failures at the previous head's CI are fixed:
shell_input.rsno longer expectstool_mode, and the web search declaration test passes in the isolated worktree at this head (1 passed each). - The turn pin finding is fixed by removal: the turn carries no mode,
turn/starthas notool_mode, and every request reads the live effective mode at preparation. The stale pending input no longer selects a mode. - The
visible_undercomment, theToolMode::Shelldoc and the projection unit test now includegoal_update; section 6's contradictory opening is deleted; section 11 rule 7 names the update gate. Section 7.2 still reads "The mode gate is a update gate is a synchronization primitive" (:420-421), a one-word leftover. - The Goal test-support comment and the unused
new_session_with_modeare removed, andGoal.md's trailing line is dropped. - The settle,
settle_failed, update-path skip and Goal settle threads remain fixed by removal.
Verification
cargo test --locked --offline -p dim-app-server --test transport_flow a_recorded_run_is_one_append_input_for_the_next_requestat this head: 1 passed, 0 failed (it failed ata9c1059a).cargo test --locked --offline -p dim-agent-capabilities --lib the_mode_projects_the_callable_setat this head: 1 passed, 0 failed.- The web search declaration test from the previous head's verify failure also passes: 1 passed, 0.70 s.
- Findings 1 and 2 are static; every cited line was read at this head.
- Not run: the full workspace suite and a live mid-turn switch after a tool result.
CI
At this head changes, macos-native, scripts, static-checks, web and windows-cli pass; verify (linux) is in progress; dependencies and acp-registry skip. The previous head c0223bad (run 45802422092) ended with verify (linux) failing on transport_flow::shell_input::a_recorded_run_is_one_append_input_for_the_next_request, whose stale tool_mode assertion is removed, and transport_flow::web::web_search_is_declared_at_the_next_request_after_the_added_service_is_adopted; both pass in the isolated worktree at this head (1 passed each, the second in 0.70 s). The PR is open, not a draft, MERGEABLE=true and mergeable_state=blocked.
| restart, uses the mode recorded at application; a switch after the application does not change it. | ||
| A turn that pins `shell` waits for the committed pause text to be adopted before its first | ||
| request, and the Dispatcher keeps running while it waits. | ||
| restart, uses the mode recorded at application; a switch after the application does not change |
There was a problem hiding this comment.
[P2] This flow still requires the mode recorded at application, but this head removed it. The InputQueue writes input/applied without a tool mode (crates/dim-agent-capabilities/src/input_queue.rs:275-284, crates/dim-agent-capabilities/src/input_queue/recovery.rs:64-71); the event's mode is the input mode (crates/dim-agent-types/src/events.rs:7-15), not the tool mode. start_preparation reads the live effective mode when the request is prepared (crates/dim-agent-capabilities/src/agent_loop.rs:1213). Section 4 above (:162-168), Loop.md:110-115 and ToolRegistry.md:51-52 describe that live read. A deferred or rebuilt request therefore uses the mode at preparation, not at application. Either update this flow, section 5 :197-198, section 8 :329-330, section 12 :436-438 and :441 to the live-read model, or restore the recorded pin in the code and change section 4 (:162-168), Loop.md and ToolRegistry.md to match.
| waits. | ||
| Its page gains the turn's mode pin. Its owner carries this into | ||
| [Loop](../architecture/rust-agent/plugins/Loop.md). | ||
| - **Loop.** Record the effective mode when the input is applied, at its serial position; a rebuild |
There was a problem hiding this comment.
[P2] Section 12 still tells the Loop to record the mode at the input's serial position and says the Loop page gains the turn's mode pin, but the Loop page now says a request declares the live effective mode at preparation (docs/architecture/rust-agent/plugins/Loop.md:110-115), and no code records a pin: Turn and Applied carry no tool mode (crates/dim-agent-capabilities/src/agent_loop.rs:55-84; Applied.mode is the input mode), and start_preparation reads binding.effective_mode() (crates/dim-agent-capabilities/src/agent_loop.rs:1213). Rewrite this bullet and the closing the Loop holds the turn's mode pin at :441 to the live read.
- Section 5/8/10/12, the closing ownership sentence and the ADR D1 line describe the live read, not a recorded per-input pin. - shell's section 2 opening, both tables and the section 10 flow include goal_update. - ContextUsage gains the request-declaration source and its fallback. - The PR body drops the removed settle machinery. Refs #2135
yyhhyyyyyy
left a comment
There was a problem hiding this comment.
Reviewed the full main...head diff at 32b0d03303d7cc11878ecf337ec22f75e574bcee (69 files, 1840 insertions, 267 deletions, merge base a8d84e93), including the docs commit that aligns the design with the live mode read.
Verdict: APPROVE. Both P2 findings are fixed and the mode docs now match the code. No blocking issue remains; one ContextUsage design page note is P3 below.
Fixed at this head
- Shell
goal_update: the section 2 opening (docs/design/agent-tool-modes.md:91-93), the section 2 table (:99), the section 4 table (:149) and the section 10 flow (:360) now includegoal_update. They match the prose at:108,:331and:429,docs/architecture/rust-agent/plugins/ToolRegistry.md:43, and the code atcrates/dim-agent-capabilities/src/tool_registry.rs:918,crates/dim-agent-types/src/tool_mode.rs:16-18and the projection test atcrates/dim-agent-capabilities/src/tool_registry.rs:1182. - Live read: section 5 (
:197-198), section 8 (:329-330), the section 10 flow (:376-377), section 12 (:434-436) and the closing ownership sentence (:438-443) now read the live effective mode when a request is prepared. This matches section 4 (:162-168),docs/architecture/rust-agent/plugins/Loop.md:112-115,docs/architecture/rust-agent/plugins/ToolRegistry.md:51-52andcrates/dim-agent-capabilities/src/agent_loop.rs:1213. No recorded-pin or next-applied-input sentence remains. - Section 7.2 (
:418-420) no longer repeats the update-gate sentence, and ADR D1 (:421-422) now says the mode is read live at preparation. - The architecture page
docs/architecture/rust-agent/plugins/ContextUsage.mdnow says at:15and:40that the fixed cost is the last model request's declarations, with the registry's live projection as the fallback before the first request. This matchescrates/dim-agent-capabilities/src/context_usage.rs:1047-1093and:1108-1111. - The PR description now describes the live read,
goal_update, the update gate and the last-request usage source.
Live semantics checked
The live read is consistent for a mid-turn switch, a request deferred for compaction, retries, rebuild and process restart, and a stale pending input after a stop. ToolBinding::bind (crates/dim-agent-capabilities/src/tool_binding.rs:109-113) and project (crates/dim-agent-capabilities/src/tool_registry.rs:925-933) apply the same entry-tool fallback, so the pre-check is redundant but consistent; bind_current (:131-142) and prepare (:144-155) have no dead path.
Merge status
MERGEABLE=true; mergeable_state=blocked reflects the review and check gate. #2174 673342a0 and #2206 68ff0118 merge clean. #2226 244d231b conflicts in crates/dim-app-server/tests/transport_flow/branch_typescript.rs and #2227 e0281915 in crates/dim-app-server/src/agents.rs; both conflicts reproduce with main a8d84e93 alone, so they are not caused by this PR.
Optional (P3)
- Test gaps: no case covers a switch between two requests of one turn, or the live read for a compaction-deferred or post-restart request. The
ToolBinding::bindfallback for a request whose adopted list lacks the entry tool has no test. - Cross-PR: #2206
68ff0118removesexec_stop.rsandExecStop, while this head adds("execStop", "control")atcrates/dim-app-server/src/lib.rs:1692anddocs/architecture/rust-agent/plugins/ShellSession.md:6says the part providesdyn ExecStop. Whichever merges second must reconcile the face. docs/design/plugins/ContextUsage.md:61still says the fixed tools come from the configuration or the registry's current declarations. The code now uses the last model request's declarations, with the registry's live projection as the pre-first-request fallback; state the new source in that design page.- The earlier usage cache key note does not need action here: a changed registration gets a new source version (
crates/dim-agent-capabilities/src/tool_registry.rs:519-523), which invalidates the cache; the name and description fingerprint is secondary.
Verification
cargo test --locked --offline -p dim-app-server --test transport_flow a_recorded_run_is_one_append_input_for_the_next_request: 1 passed, 0.48 s.cargo test --locked --offline -p dim-app-server --test transport_flow web_search_is_declared_at_the_next_request_after_the_added_service_is_adopted: 1 passed, 0.66 s.cargo test --locked --offline -p dim-agent-capabilities --lib the_mode_projects_the_callable_set: 1 passed, 0.02 s.- The new commit changes only
docs/design/agent-tool-modes.mdanddocs/architecture/rust-agent/plugins/ContextUsage.md; every cited line was read at this head. - Not run: the full workspace suite and a live mid-turn switch.
CI
At this head changes, macos-native, scripts, static-checks, web and windows-cli pass; verify (linux) is in progress; dependencies and acp-registry skip. At 44e19200 the verify (linux) job was cancelled when this head pushed, ci-ok reports failure, and the other jobs passed or skipped. The two tests that failed at c0223bad pass at this head in the isolated worktree.
yyhhyyyyyy
left a comment
There was a problem hiding this comment.
Reviewed the full main...head diff at b29d2886fb9e97d1aaa57b1cf2eabfb0843cd079 (70 files, 1841 insertions, 268 deletions, merge base a8d84e93). The head is a child of 32b0d033; its new commit updates docs/design/plugins/ContextUsage.md only (+1/-1). The head merges cleanly with current origin/main 5591e807.
Verdict: APPROVE. Both earlier P2 findings remain fixed, the last usage-source P3 is fixed, and the docs now match the code. No blocking issue remains.
Fixed at this head
- Usage source:
docs/design/plugins/ContextUsage.md:61now says fixed tools take the set the most recent model request before the boundary actually declared, falling back to the registry's current declarations when there is no request. This matchesdocs/architecture/rust-agent/plugins/ContextUsage.md:40and the code:crates/dim-agent-capabilities/src/context_usage.rs:1047-1093reads the last model request'sdata.request.tools, and:1108-1111falls back toregistry.visible_definitions(). - Both earlier P2s remain fixed. Shell
goal_updateis in the section 2 opening, both tables and the section 10 flow (docs/design/agent-tool-modes.md:91-93,:99,:149,:360), matching:108,:331,:429,ToolRegistry.md:43andtool_registry.rs:918. The live read is in section 5, section 8, the section 10 flow, section 12 and the closing ownership sentence (:197-198,:329-330,:376-377,:434-436,:438-443), matching section 4:162-168,Loop.md:112-115,ToolRegistry.md:51-52andagent_loop.rs:1213. No recorded-pin or next-applied-input sentence remains. - Section 7.2 (
:418-420) and ADR D1 (:421-422) remain fixed. - The PR description describes the live read,
goal_update, the update gate and the last-request usage source.
Live semantics checked
The new commit changes only the usage design page; the mode and binding code is unchanged from 32b0d033. The live read is consistent for a mid-turn switch, a request deferred for compaction, retries, rebuild and process restart, and a stale pending input after a stop. ToolBinding::bind (crates/dim-agent-capabilities/src/tool_binding.rs:109-113) and project (crates/dim-agent-capabilities/src/tool_registry.rs:925-933) apply the same entry-tool fallback; bind_current (:131-142) and prepare (:144-155) have no dead path.
Merge status
git merge-tree --write-tree HEAD 5591e807 exits clean, so the head merges with current main. #2206 68ff0118 remains a semantic cross-PR note below.
Optional (P3)
- Test gaps: no case covers a switch between two requests of one turn, or the live read for a compaction-deferred or post-restart request. The
ToolBinding::bindfallback for a request whose adopted list lacks the entry tool has no test. - Cross-PR: #2206
68ff0118removesexec_stop.rsandExecStop, while this head adds("execStop", "control")atcrates/dim-app-server/src/lib.rs:1692anddocs/architecture/rust-agent/plugins/ShellSession.md:6says the part providesdyn ExecStop. Whichever merges second must reconcile the face.
Verification
cargo test --locked --offline -p dim-app-server --test transport_flow a_recorded_run_is_one_append_input_for_the_next_request: 1 passed, 0.20 s.cargo test --locked --offline -p dim-app-server --test transport_flow web_search_is_declared_at_the_next_request_after_the_added_service_is_adopted: 1 passed, 0.63 s.cargo test --locked --offline -p dim-agent-capabilities --lib the_mode_projects_the_callable_set: 1 passed, 0.00 s.- The new commit changes only
docs/design/plugins/ContextUsage.md(+1/-1); every cited line was read at this head. - Not run: the full workspace suite and a live mid-turn switch.
CI
At this head changes, macos-native, scripts, static-checks and web pass; verify (linux) and windows-cli are in progress; dependencies and acp-registry skip. The two tests that failed at c0223bad pass at this head in the isolated worktree.
|
@zerob13 current head |
Dismissed at the maintainer's request: the live-mode read and goal_update-in-shell direction are confirmed product decisions; the design pages are updated and #2135 will record them. The remaining notes are tracked.
- 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
Summary
Implementation of the tool modes design (#2135, design in #2141): the Session runs in one of
normal,codemodeandshell.ToolModeonSessionConfig;normalis omitted from the stored form, so an old record reads as normal.session.createacceptstoolMode;session.tool_mode.getreports{mode, effective};session.tool_mode.updatewrites the record and replaces the live value.ToolRegistryprojects the callable set intovisible(request declarations) anddelegated(Code Mode children) and falls back tonormalwhen the entry tool is absent. The mode is Session configuration, not a Timeline or per-turn fact: a request reads the live effective mode when it is prepared, a switch applies to the next request, and a turn carries no mode.visible.ToolBindingbindsvisible ∪ delegated, checks the caller's set beforeclaim, and binds against the tools the request was adopted with, so a pending refresh never delays an adopted surface; a Code Mode program sees onlydelegated.executeis registered withToolRegistry(no SessionToolHost); the product profile mountsShellSessionand the tool, the minimal profile binds an emptyToolHostand runsshell.session.exec.stopasks the branch's liveExecStopbeforeBackgroundExec.goal_updatebesideexecute,ask_userandrecall, so a goal can be completed or blocked in every mode and a mode switch does not touch Goal state. PromptSources omits the Windows file-encoding guidance while shell is in force./usagecounts the tools the last model request declared, falling back to the live projection before the first request./settingsTools row read/update the mode; the web remembers the last choice forsession.create.Known gaps
None against the design in #2141.
Design rule checklist
before: n/a.visiblereaches the model request; the request reads the live effective mode at preparation.session.tool_modejoins the Session method face;ExecStopandShellSessionare internal.goal_updatein shell), request surface, admission, codemode children, minimal shell, usage after a mode switch, member inheritance, web/TUI settings.Verification
cargo test --locked -p dim-app-server --test app_server_flow session_tool_mode_flowcargo test --locked -p dim-app-server --test transport_flow codemodecargo test --locked -p dim-agent-capabilities --libcargo test --locked -p dim-agent-types --libcargo test --locked -p dim-codemode --test flowcargo test --locked -p dim-agent-integration-tests --test integration_flow minimal_execution::cargo test --locked -p dim-goal --test goal_suitecargo test --locked -p dim-cli --libcargo clippy --workspace --all-targets --locked -- -D warningscargo run --locked -p xtask -- checknode scripts/adr-check.mjs --base mainweb:npm run typecheck,npm run build,npx vitest runRefs #2135.