Repository navigation
fix(kas): let a sub-agent spawn reach approval - #14063
Conversation
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify KAS stamps [DESIGN-REVIEWED] d8f5f1b |
First Principles Review (Fable 5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The classification rests on a hand-written "KAS 2.24" frame and "KAS sets Not justified as shipped
What this change shipsInventory (10 items) — 7 justifiedIntent: let a KAS agent's sub-agent spawn reach approval instead of being auto-denied as an unverifiable shell command — a FIX.
[FIRST-PRINCIPLES-REVIEWED] d8f5f1b |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 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: |
Opus 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: |
0e3231b to
cdc3545
Compare
Security Scope Review -- 🟡 CONCERNSWhich legitimate operations does Verdict basis: the reviewer's own judgement; no confirmed regression. Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. Scope-Verdict: CONCERNS TIGHTENING: The permission gate now judges a backend-stated sub-agent spawn against ADJUDICATED: 15 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: Rows were written as UNADJUDICATED: The tightening itself lives in the governance/permission plane, which the classifier cannot reach -- it settles a shell command line through the tool-call deny composite, and every one of the three strictures here is off that path:
[SCOPE-REVIEWED] d8f5f1b |
cdc3545 to
d4e26b5
Compare
d4e26b5 to
65b8386
Compare
65b8386 to
a4d75c5
Compare
On KAS a sub-agent spawn was always auto-denied as an unverifiable command. Two independent defects, both fixed, plus the spawn policy the fix must not bypass: - kas_permissions.CAPABILITY_BY_TOOL keyed the sub-agent grant on KAS's internal toolId `invoke_sub_agent`, but allowedTools carries Crew's name `use_subagent`, so no `subagent` allow rule was ever projected. Key it on `use_subagent` only; a second spelling would be a ref the governance ceiling is never asked about under the Crew name. - KAS's spawn tool_call frame is taken for the sub-agent roster and its toolCallId is synthetic, so every cache missed and the request arrived unclassified, which `_unverifiable_shell` refuses. On KAS only, build_permission_event resolves that miss from the request's engine-written `_meta.kiro` block when the toolId is `invoke_sub_agent`, the consent capability is `subagent`, a target is named and no command rides along. It sets tool_name `use_subagent` and `spawn_target`, never is_shell True, never overrides a cache hit, and grants no params or identity provenance. - HookManager.on_tool_call judges `spawn_target` against `capabilities.spawn` (gate on, target in the `agents` scope) inside `_governance_denial`, on the ceiling and calling agent's profile it already resolved, before any grant or prompt; an evaluation error refuses the spawn. governance.may_skip_gate withholds `use_subagent` from every allowedTools writer, on both backends, while the ceiling or any configured profile restricts `capabilities.spawn`. Both the per-spawn vet and the shared-predicate withhold follow the approach in #9053 by karraghu. The CLI notice for an unclassified request no longer says it "claims to run a command" when nothing claimed one. Closes #9024
|
Disposition of the GPT 5.6 finding on The finding is real. It is also pre-existing and class-wide: every auto-approve grant, on both backends, is decided when a session starts, and nothing narrows a session already negotiated ( What this PR does close on the next head: the grant is no longer emitted at all while a policy restricts spawning, on any backend or channel (Opus finding, same head), because the check now lives in the shared |
a4d75c5 to
d8f5f1b
Compare
Problem / Motivation
On the KAS backend, an agent can never spawn a sub-agent. The spawn is refused with
Denied automatically: Sub-agent: <name> claims to run a command, but its command could not be verified., and the model is told the user rejected it. No command was involved and no human was asked.Why it matters
Every KAS agent that delegates is broken, including the bundled
pptx-makerspecs. NeitherallowedToolsnorapproval_modegets past it, so there is no workaround.What changed (motivation → approach → change)
Two independent defects. Either one alone still leaves the spawn refused.
A.
allowedToolsnever granted thesubagentcapability.acp/kas_permissions.pyCAPABILITY_BY_TOOLkeyed the grant on KAS's internal toolIdinvoke_sub_agent.allowedToolscarries Crew's (kiro-cli's) name,use_subagent, so no{"capability": "subagent", "effect": "allow"}rule was ever projected. The key is nowuse_subagent, and only that. A second spelling would be a ref the governance ceiling is never asked about under the Crew name: the ceiling filtersallowedToolsby ref before this table reads it, so an alias could obtain the grant the ceiling withholds. The other keys were checked the same way:web_fetchandweb_searchare the same name on both sides;disclose_contextis KAS's skill tool and Crew has no name of its own for it, so it stays.B. The permission request was refused as an unverifiable shell call. KAS's spawn
tool_callframe (_meta.kiro.kind: "agent-subtask") is intercepted byAcpSessionHandle._handle_kas_subagentfor the sub-agent roster and never reaches the shared parser, and its toolCallId is synthetic (invoke_subagent_<id>). So every toolCallId-keyed cache misses, the request arrives withshell_classified=False, andcli_chat._unverifiable_shellrefuses it before_can_prompt. The classification is on the request itself, in the engine-written_meta.kiroblock:_dispatch.build_permission_eventgainskas_consent_meta, set only by the two transports when the backend is KAS. On a shell-cache miss,kas_consent_classificationkas_consent_toolresolves the request to "not a shell call" when every field agrees: the toolId isinvoke_sub_agent, the consent capability issubagent,consent.resourcenames the target agent, and nocommandrides along (KAS sets that field only for a shell call). It also setstool_nameto the Crew nameuse_subagent, so the deny floor,auto_deny_toolsand thetoolsceiling are asked about the tool, not only its title, and carries the target asAcpEvent.spawn_target. It never setsis_shellTrue, never overrides a cache hit, and grants no params or identity provenance (raw_params_trustedandmcp_identity_trustedstay False). Anything else stays unclassified and keeps the refusal. The deny-by-default gate inHookManager.on_tool_callis unchanged. A classified spawn then reaches the normal path: a prompt when a human can answer, the honest "needs approval, and this invocation cannot ask" when not.C. The spawn policy holds on both paths. A
capabilities.spawnpolicy is not atoolsrule, so neither the projection nor the gate could see it:HookManager.on_tool_calljudgesspawn_target(threaded once, throughhook_gate_kwargs) againstcapabilities.spawn: the gate on and the target in itsagentsscope, the same two questionssubagent._vet_spawn_governanceasks on Crew's own spawn path. It is judged inside_governance_denialon the ceiling and profile that call already resolved for thetoolsquestion, so no second profile resolution runs on the event loop, and the profile is the calling agent's (a profile bound to the spawning agent's name applies). An evaluation error refuses the spawn. It runs before any grant or prompt, on every surface that uses the gate. An event with nospawn_target(every other backend) is not spawn-vetted, so their gate is unchanged.governance.may_skip_gatenow withholdsuse_subagentwhile the ceiling or any configured profile restrictscapabilities.spawn(off, or any scope), through a newBUILTIN_TOOL_CAPABILITIESmap. EveryallowedToolswriter asks that predicate, so the grant is withheld on every backend and channel: kiro-cli's own spec, the KAS wire projection, and thepermissionsblock written to disk. Those spawns are asked about instead. With no such policy, nothing changes on either backend. Placing the check in the shared predicate is the approach fix: let a KAS sub-agent spawn be approved #9053 took (BUILTIN_TOOL_SCOPES).Notice.
_unverifiable_shell's CLI notice said "claims to run a command" for any refusal. It now says that only when the request's kind reads as a command; an unclassified request reads "could not be identified as a known tool call". The model-facing "The user rejected this tool call." is KAS's own text for any rejection (acp-server.js), so Crew cannot reword it; with both fixes the spawn is no longer rejected.src/kiro_crew/acp/kas_permissions.pyuse_subagentreplacesinvoke_sub_agentas the sub-agent keysrc/kiro_crew/acp/_dispatch.pykas_consent_tool;kas_consent_metaonbuild_permission_eventdocs/system-specs/modules/acp-client.mdsrc/kiro_crew/acp/session_handle.py,client.pykas_consent_metawhen the backend is KASsrc/kiro_crew/acp/types.py,providers/acp.pyspawn_targeton the event, forwarded by the providersrc/kiro_crew/hooks.pyspawn_targetinhook_gate_kwargs; the gate vets it againstcapabilities.spawnsrc/kiro_crew/platform/governance.pyBUILTIN_TOOL_CAPABILITIES;may_skip_gatewithholdsuse_subagentunder a restricting spawn policydocs/system-specs/modules/governance.mdsrc/kiro_crew/cli_chat.pyBackwards compatibility
Breaking, narrowly: a spec listing the KAS toolId
invoke_sub_agentinallowedToolsno longer projects thesubagentrule. Such a spec now logs a WARNING at projection naming the entry and the fix (list 'use_subagent' instead); its spawns prompt until then. Writer sweep on origin/main @ 5bbc6f7: no spec, fixture or doc in the repository lists it; the only occurrence was the table line itself. Every non-KAS backend reads permission frames exactly as before: the new classification is off unless the backend is KAS. On a host whose ceiling or a profile restrictscapabilities.spawn(off, or scoped),use_subagentis now withheld from auto-approve on both backends: those spawns prompt, and on KAS are vetted against the spawn policy. With no such policy, kiro-cli is unchanged.Tests
test/test_kas_permissions.pyTestTheSubagentToolIsKeyedOnTheCrewName:use_subagentproduces thesubagentrule;invoke_sub_agentproduces none and warns with the fix;use_subagentwarns about nothing; the ceiling is asked aboutuse_subagent.test/test_kas_subagent_permission.py: the real KAS 2.24 spawn frame classifies as non-shell, carriestool_name="use_subagent"and passes_unverifiable_shell; anauto_deny_tools: ["use_subagent"]rule denies it (fails with the name removed); it earns no params or identity provenance; onlyinvoke_sub_agentis known; eight disagreeing shapes (shell toolId, shell or wrong capability, missing consent, unknown or missing toolId, acommandpresent) and four malformed_metablocks stay unclassified; the same frame on a non-KAS backend is refused as before; a cached shell verdict is never overridden and its missing command is still denied; a real shell with no command is still denied;AcpClientsets the flag only for KAS.test/test_governance_chokepoints.py: a KAS spawn is denied when spawning is off, judged on its stated target under anagentsscope, not denied on an ungoverned host, and an event with no target is not spawn-vetted;use_subagentis withheld when spawning is off, scoped, or restricted by a profile, on both kiro-cli (agent._may_auto_approve) and the KAS projection, and kept when spawning is enabled unscoped; with no policy both backends keep it. Disabling either check fails its deny cases.test/test_hooks.py:hook_gate_kwargsemitsspawn_target.test/test_governance_chokepoints.pyTestKasSpawnHonoursTheCallersTaskProfile: a task profile bound to the spawning agent that switches spawning off denies the spawn, and does not deny it for another agent (fails withcaller_agentdropped).test/test_cli.py: an unclassified request's notice does not say "claims to run a command".Run:
test_kas_permissions.py,test_kas_subagent_permission.py,test_cli.py::TestChatPermissionRequest,test_tool_call_classification.py, and thepermission or kasselection oftest_kas_agents.py,test_kas_subagent_progress.py,test_acp_client.py. flake8, isort, black and mypy clean on the touched files.Manual verification
Live against KAS 2.24.0 via kiro-cli's relay, with Crew's own projection (
build_kas_custom_agents) and parser, asking the agent to spawn one sub-agent:allowedTools["use_subagent"]subagent: allowPONG[]classified=True,unverifiable=False; unfixed:unverifiable=TruePONGRelated Issues
Closes #9024
Compared with #9053
#9053 by karraghu fixes the same issue. What each covers:
use_subagentkeyinvoke_sub_agentas an aliasallowedToolsby ref, so an alias is a spelling it is never asked aboutspawn_attestedfromconsent.capabilityalone, read on every backendconsent.capabilityANDtoolIdAND a named target AND nocommand, read only on KAS; resolves the miss to non-shell and names the tooluse_subagentfor deny/toolsrules_vet_spawn_governancebefore the prompt, hand-wired incli_chat.pyandchat_runner.pyhook_gate_kwargs, so every surface that uses the gate gets ituse_subagent->capabilities.spawninBUILTIN_TOOL_SCOPES, so any declared spawn capability withholds itBUILTIN_TOOL_CAPABILITIESentry read bymay_skip_gate, withholding only when the capability restricts (off or scoped); both backends_vet_spawn_governancedenies an unnamed target under anagentsscope;governance_scope_constrainedspawn_auto_approve_granted,spawn_invocation_observedAdopted from #9053, credited in the commit: vetting the spawn against
capabilities.spawnon the backend-stated target before the prompt, and withholding the grant in the sharedmay_skip_gate. Not adopted: the alias, reading consent on non-KAS backends, and the audit records, which are additions beyond #9024.Found while probing, not fixed here: on KAS a spec's
tools: ["use_subagent"]mounts no sub-agent tool, becausetoolsis relayed verbatim and KAS's tool vocabulary does not know that name. kiro-cli's ownuse_subagentprompt is not spawn-vetted (its events carry nospawn_target); its auto-approve grant now is.Accepted and deferred to #14112: a grant cannot be revoked from a live session when policy tightens mid-session (GPT lane on
a4d75c5120). It is real, and pre-existing for every auto-approve grant on both backends, so it is tracked as one class there rather than patched for this grant alone.Pattern harvest
Rule candidate: review-prompt
Pattern: a name table read against a list the user writes must be keyed on the list's vocabulary, not on the vocabulary of the system the table translates into.
Checklist
acp-client.md