Repository navigation
fix(pi): honour an agent spec's zero-tool ban on pi sessions - #22808
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the pi ban reuses the existing refusal and reads Notes
[DESIGN-REVIEWED] c8e361a Description read[DESCRIPTION-READ] 36844f90034c3bb9c459d0e699824037a9f4976769bf544ffbe9af6e993fa84d That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing to check. What this change shipsInventory (7 items) — 6 justifiedIntent: a pi agent whose spec says
[FIRST-PRINCIPLES-REVIEWED] c8e361a Description read[DESCRIPTION-READ] b5331a815bebbe15579af49ce55c4895f8cd51c6084799f1582808a428c3cb5f That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
3f48b94 to
1e2299a
Compare
1e2299a to
d860564
Compare
d860564 to
d02ff5d
Compare
d02ff5d to
2a1ee76
Compare
pi has no mirror, so nothing computed SessionMcpProjection.zero_tools for it and a spec declaring "tools": [] still ran every pi tool the user approved. Read the answer beside pi's member mounts from the same spec parse (_mirrorless_member_mounts, for mirror-less ACP_BACKENDS_SESSION_MCP_ARRAY hosts) and add pi to ACP_BACKENDS_HONOR_ZERO_TOOL_BAN, so the existing AcpClient._deny_zero_tools refuses every request the gate extension raises. Backed by a live capture through AcpClient on pi-acp 0.0.34 over pi 1.2.0 (test/fixtures/acp_frames/pi/zero-tools-refused-live.jsonl), held to it by the x-capture gate.
…ad no spec kiro-cli reads kirocrew-knowledge's model from its spec; opencode, goose, deepseek and now pi read no spec of Crew's, so a pinned knowledge.extraction_model silently ran on the harness default. Extract the installer's rule into knowledge_agent_model() (exported through the kiro_crew.agent facade) and pass it as model= to every non-AGENT_SPEC pool client; the startup model application scopes it per backend. kiro-cli's construction is unchanged.
2a1ee76 to
c8e361a
Compare
#22808 gated _mirrorless_member_mounts on two new 'backend in ACP_BACKENDS_SESSION_MCP_ARRAY' tests, which #22489's set-gate ratchet (shrink-only, allowlist 2 for this file) counts, so main reds test_no_new_runtime_site_gates_a_field_backed_line_on_a_set. The question those sites ask is who reads this backend's spec, which registry.PROJECTIONS declares per backend: BROKER_ONLY (pi) means no projection is written and the harness reads no spec of Crew's. Read that record, as this file already does for per_tool_deny, so the file is back to its 2 allowed sites and the zero-tool ban is unchanged.
…2951) * test(pi): stand in for the Node probe's sync sandbox wrap in the real-adapter lane #22883's node-engine guard confines each 'node --version' probe through _pi_probe_wrap, which calls the sync pi_mod.wrap_argv. The lane (#22807) replaced only wrap_argv_async and the preflight, so on a runner without user namespaces every pi_session test errored at setup with SandboxUnavailableError. Replace the sync wrap by identity too, and say so in the module docstring. * fix(acp): decide pi's zero-tool record from its declared MCP projection #22808 gated _mirrorless_member_mounts on two new 'backend in ACP_BACKENDS_SESSION_MCP_ARRAY' tests, which #22489's set-gate ratchet (shrink-only, allowlist 2 for this file) counts, so main reds test_no_new_runtime_site_gates_a_field_backed_line_on_a_set. The question those sites ask is who reads this backend's spec, which registry.PROJECTIONS declares per backend: BROKER_ONLY (pi) means no projection is written and the harness reads no spec of Crew's. Read that record, as this file already does for per_tool_deny, so the file is back to its 2 allowed sites and the zero-tool ban is unchanged. --------- Co-authored-by: Kyle Seaman <kseam@dev-dsk-kseam-1b-55230d27.us-east-1.amazon.com>
Problem / Motivation
Goal: A pi session whose agent spec declares
"tools": []runs no tool at all: Crew refuses every call itself, without asking the user.Today pi has no mirror, so nothing computes
SessionMcpProjection.zero_toolsfor it,AcpClient._deny_zero_toolsnever fires, and a zero-tool spec on pi still runs everywrite,bashor MCP call the user approves.backends_mcp.pysaid so in as many words ("pi is NOT a member ... nothing computes zero_tools for it").Why it matters
"tools": []is how Crew declares a text-only agent, the knowledge/research worker being the main one. On pi that declaration was decorative: native tools stayed reachable behind an approval prompt, and pi was the one gate-enforced harness left out ofACP_BACKENDS_HONOR_ZERO_TOOL_BAN. That kept pi from being fully wired in as a harness.Not a goal
mcpServersfor pi.ACP_BACKENDS_MEMBER_CAPABILITIES). This design does not set_session_agent_spec. The parse it readszero_toolsfrom in_mirrorless_member_mountsis aSessionMcpProjection, which already carriesagent_spec. A follow-up can record it at that same point from the same parse, so mounts, the ban and the consumed spec would all come from one spec version.What changed (motivation → approach → change)
Symptom → root cause. The refusal (
_deny_zero_tools) already runs at both permission-answering sites, and pi's gate extension already routes every tool call throughsession/request_permission. The only missing piece was the fact "this spec bans all tools", because only mirrors computed it.Approach. Compute that fact for pi from the parse Crew already does, not by adding a mirror.
_mirrorless_member_mountsalready reads pi's spec for its member mounts. A pi mirror would change what a pi session mounts, overlap #22400, and add nothing to the refusal. No parallel refusal path is built.Changes:
acp/client_mcp_array.py: for a mirror-less host whose array Crew composes (ACP_BACKENDS_SESSION_MCP_ARRAY, today only pi),_mirrorless_member_mountsrecordszero_toolsfrom the same parse that builds the mounts. kiro-cli isn't in that set and returns before the parse, so its path is unchanged.agent_sdk/backends_mcp.py: pi joinsACP_BACKENDS_HONOR_ZERO_TOOL_BAN. The rule's third fact now reads "something computeszero_tools", which can be a mirror or this parse. The comment cites the live capture.scripts/check_harness_parity.py:X_FEATURE_SETSgainsACP_BACKENDS_HONOR_ZERO_TOOL_BAN: frozenset({"pi"}), so the x-capture gate (test(harness): require a replayed live capture for every X-feature set member #22102) holds pi's membership to a replayed live capture. Removing the citation fails the gate.knowledge.extraction_model. The same gap already existed for opencode, goose and deepseek, because only kiro-cli reads the spec's ownmodel. The installer's rule (knowledge.extraction_model→agent.model→"auto") is extracted toknowledge_agent_model()and exported through thekiro_crew.agentfacade.AcpWorker._spawn_clientpasses that pin asmodel=only on the non-AGENT_SPECbranch. The kiro-cliAcpClient(...)call stays byte-identical, with nomodel=kwarg (H13). The existing startup model application scopes it to the backend. kiro-cli's construction is unchanged.capabilities.py,spec_zero_toolsandllm_poolwere updated to match, along withknowledge.mdand the shippeddocs/agent-spec-fields.md, whose zero-tool paragraph now lists opencode, goose, deepseek and pi as closing the gap._mirrorless_member_mountskeeps its original member-set early return. The array-host clause is an added third condition. An unreadable spec recordszero_tools = False, including when the same client re-resolves.test/test_member_mount_pi.py: feat(pi): mount the crew member panel on pi member threads #22813 pinnedpi not in ACP_BACKENDS_HONOR_ZERO_TOOL_BANas one of three reasons pi stays out ofACP_BACKENDS_MEMBER_CAPABILITIES. That pin now asserts the new fact, and that pi is still outsideACP_BACKENDS_MEMBER_CAPABILITIES, because the other two reasons (no consumed spec, aBROKER_ONLYhandoff) still hold. The matching third bullet inbackends_members.py's comment is now stale. This PR deliberately leaves that file alone because another workstream owns it.Compatibility with neighbours: #21744 edits
harness/pi.py,permission_requests.pyandbackends.py. #22400 touchesclient_mcp_array.pyonly in_republish_pi_mcp_handoffand an import. #12344 touches neither file. None edit these hunks, so a rebase in either order should be mechanical.Backwards compatibility
Compatible: the change only adds refusals on pi sessions whose spec declares
"tools": [], and a model pin on non-kiro pool workers. Every other session and backend behaves as before.Removes nothing: no path, key, record, validator or public function is removed or narrowed.
_install_knowledge_agentwrites the same spec; its model rule moved intoknowledge_agent_model()unchanged.Tests
test/test_pi_zero_tool_ban.py(26). It replays the three live permission frames from the capture through both answering sites (_deny_zero_toolsbefore the consumer yield, and the auto-approve_handle_permission) and asserts the advertised reject option is sent with aspec_zero_toolsaudit record. Each case is listed below.edit,read, truncated args, and a foreign-nonce frame.toolskey, a populated list, or a non-list leaves the refusal off, and the same frames reach the consumer.client_mcp_array.pyfails 6 tests, and dropping pi from the set fails 19.test/test_agent_sdk_capabilities.py: the membership-rule recompute now reads "mirror OR Crew-composed array". The pool-safe pin includes pi, with its effort channel (thought_levelconfig option) asserted.test/test_llm_pool.py: pi passes the selection gate. A pi, opencode, goose or deepseek worker receivesmodel=<pin>. A kiro worker gets nomodelkwarg and never reads the pin. These tests fail without the pool fix._knowledge_spec_modeltreats"auto", a blank or an unreadable config as no pin.test/fixtures/acp_frames/pi/zero-tools-refused-live.jsonl+.expected.json: replayed bytest_acp_frame_replay, clean undercheck_acp_frame_host_data.py.Local runs:
HARNESS_BASE_REF=origin/main python3 scripts/check_harness_parity.py✓ and--test✓; black, isort and flake8 ✓; scoped mypy ✓.Manual verification
This is a live run of a real
AcpClient(acp_backend="pi"). It used pi-acp 0.0.34 over pi 1.2.0, installed into a scratch npm prefix, so the global pi was not used. The model was a scripted one on the loopback interface, plus one stdio MCP probe server, and the frames were recorded by Crew's in-product recorder. The consumer approved every permission event it was handed, and on the zero-tool spec it was handed none.toolskey (control)writefailed, file absentbash(touch)failed, file absentmcp__probe_server__echofailed; server loggedinitialize/tools/list, notools/calltools/callranfrobnicateTool frobnicate not found), no permission frame, nothing runsNot verifiable on this host: it refuses user namespaces, so no sandbox backend runs and a sandboxed gateway turn isn't reachable here. In that state the routing's refuse-then-mask preflight refuses pi. The capture driver replaced only that one preflight with "no mask". The gate-extension seal, its read-back, the envelope nonce and the permission path ran as shipped. The refusal happens after the spawn and doesn't read the sandbox. I have not observed a pi turn through a full sandboxed dashboard gateway.
Independent fresh-context review (read-only, given only the diff and the invariant) of the refusal path: SOUND.
PiLaunch.resolve_spawn→_prepare_session_mcpbefore session/new or session/load._reset_stateclears it only together with the process. A warm-pool claim must match the agent.approve_toolafter a reject fails. pi-acp offers no "always" option.Residuals it named (pre-existing mechanisms): the pi launcher still loads the operator's own pi extensions, and their
/commands orinputhandlers are not tool calls, so they never raise a permission request. pi-acp also forwards every extension dialog as a permission request, so a zero-tool pi session refuses unrelated dialogs too.Related Issues
None. Related open PRs: #21744, #22400, #12344.
Pattern harvest
Rule candidate: review-prompt
Pattern: "a capability set whose membership needs a per-backend computed fact (here
zero_tools) silently excludes a backend that computes it by a different channel; state the fact, not the channel (mirror), in the rule and its test."Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Sensitive change: none. No file in this diff matches
SENSITIVE_GLOBS(checked with fnmatch), and nothing is inherited.Contribution License Agreement
Contributed under the project's Apache-2.0 license.