zarvis: run read-only shell calls concurrently via explicit read_only flag (#331)#334
Merged
Merged
Conversation
… flag Shell is Risky, and the agent loop only fans out Safe calls — Risky calls serialize through the approval gate. So batched read-only shell inspections (reading several files in one turn) could never run concurrently, even in unsafe_auto. Add a `read_only` boolean arg to the shell tool. effective_risk() downgrades a non-interactive shell call flagged read_only:true to Safe, so such calls fan out via join_all and skip the gate — mirroring the dedicated read-only inspection tools (agentd_context, agentd_get_diff, …) that are already Safe. This is the model-trusting design (option 2 of #331): the harness honors the flag rather than parsing the command line. Scoped conservatively — only shell, only an explicit true, never interactive. The read-only-only contract lives in the arg description and the system prompt. Adds a spec (0017) and tests covering classification and a concurrency duration check. Closes #331
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #331 (execution-side enabler, option 2).
What
Adds a
read_only: booleanargument to theshelltool. A non-interactiveshellcall flaggedread_only: trueis downgraded toSafeineffective_risk(), which is what lets the agent loop fan it out concurrently (join_all) instead of serializing it through the approval gate. So several read-only shell inspections issued in one turn now run in parallel — mirroring the dedicated read-only inspection tools (agentd_context,agentd_get_diff, …) that are alreadySafe.Why option 2
Per the issue, this is the model-trusting approach: the harness honors the model's
read_onlydeclaration rather than parsing the command line (which command substitution / redirects / chaining can defeat). It's scoped conservatively:shelltool,true,interactive: true(a long-lived process is not a bounded read).The read-only-only contract ("provably side-effect-free: no writes, redirects,
$(...), or chaining into a mutator") lives in the tool's arg description and the system prompt.Behavior change to note
A read-only shell call no longer prompts for approval — including in
manualmode — exactly like otherSaferead tools. This is intended (you don't want to approve everycat), but it does rely on the model labeling honestly. A mutating command the model mislabels would bypass the gate; that's the documented tradeoff of option 2. Option 1's command-line allowlist can be layered on later as defense-in-depth (the issue notes the options aren't mutually exclusive) — I left a Non-Goal in the spec for it.Changes
tools/shell.rs—read_onlyschema arg + description; updated tool description.tools/mod.rs—effective_risk()downgrade +shell_read_only_optin()helper; unit tests.agent.rs— system-prompt nudge to mark parallel readsread_only: true.specs/0017-read-only-shell-runs-concurrently.md— records the new approval-semantics decision (relates to 0015-approval-modes).Tests
effective_risk_downgrades_read_only_shell— classification:read_only:true→ Safe; absent/false → Risky;interactiveoverrides; opt-in doesn't leak to other tools.read_only_shell_calls_are_safe_and_run_concurrently— duration test (twosleep 1reads finish in ~1s, not ~2s).Where the code lives
Only touches
crates/adapter-zarvis→ relevant binary isagentd-adapter-zarvis. All workspace binaries built (debug) in the worktree; the rest are unchanged frommain.No recording — harness execution/approval logic with no user-visible TUI render to demo.
🤖 Generated with Claude Code