Repository navigation
fix(kas): key subagent auto-approve on the Crew tool name - #9050
chenmingwei23 wants to merge 1 commit into
Conversation
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS A dead-keyed map entry re-keyed to the namespace its consumer actually reads, with the deferred second cause correctly scoped out as a separate fail-closed-gate design change. The namespace claim verifies: [DESIGN-REVIEWED] c431d2f |
Opus 4.8 Review — ✅ no blocking findingsReviewed Review detailsThe change is a straightforward, correct re-keying validated against the actual No findings. [OPUS-REVIEWED] c431d2f Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of All counts verified. First-Principles-Verdict: PASS One-line data fix at the actual cause — the map key was in the wrong namespace — with every rider declared and itself a deletion. What this change shipsIntent: make sub-agent spawns usable on the KAS backend by granting the capability the allowlist actually names — a FIX.
Sibling count for the root cause (wrong-namespace map keys): 0 remaining — Subtractions
[FIRST-PRINCIPLES-REVIEWED] c431d2f |
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: |
CAPABILITY_BY_TOOL was keyed on KAS's internal toolId invoke_sub_agent, but allowed_tools_to_permissions is consulted against the allowlist Crew writes, which carries the Crew name use_subagent (see the pptx-maker specs, acp/liveness._MODEL_WRAPPING_TOOLS, and dashboard/chat_runner). The KAS-internal key never matched, so the subagent capability was never granted and the spawn fell through to a permission prompt -- auto-refused on a non-interactive backend. Re-key to use_subagent, matching the working web_fetch/web_search entries which already use their Crew names. Also drop the dead disclose_context entry: it was KAS's internal name too, no Crew allowedTools names a skill tool, so it never matched and deletion is behavior-identical (a never-matching key and an absent key both fall through to prompt). Add a capability-lookup test that the Crew-facing name grants the subagent capability, plus a regression guard that the KAS-internal name does not classify.
853b808 to
c431d2f
Compare
|
Superseded by #9053, which fixes both causes of #9024. This PR fixed cause A only (re-key We reviewed #9053 and confirmed its diagnosis matches ours on A and its B fix is sound (details on that PR). This one adds nothing beyond it and is being closed as a duplicate. |
What is the problem?
On the
kasACP backend, a sub-agent spawn is always auto-denied. The user isshown "claims to run a command, but its command could not be verified" and told
the request was rejected -- though no human rejected it. Reproduced 5/5 via
non-interactive
kirocrew chat -m.Why this matters to the user
Sub-agents are unusable on the
kasbackend, and the denial message isfactually false twice over: the sub-agent spawn is not a shell command, and no
human declined it. A user acting on that message would look for a command they
never issued and a rejection they never made.
How the fix solves it (symptom -> root cause)
There are two independent causes on two different code paths. This PR fixes the
one that lives here and is the reported repro's proximate cause; it documents
the second precisely, correcting a wrong file attribution from our own triage.
Root cause A (fixed here) -- the capability is never granted.
src/kiro_crew/acp/kas_permissions.pytranslates a Crew agent'sallowedToolsinto a KAS permissions policy via
CAPABILITY_BY_TOOL. That map was keyed onKAS's internal toolId
invoke_sub_agent, butallowed_tools_to_permissionsisconsulted against the allowlist Crew actually writes, which carries the CREW
name
use_subagent(seeapps/builtins/pptx_maker/agents/*.json,acp/liveness._MODEL_WRAPPING_TOOLS, anddashboard/chat_runner). The nameinvoke_sub_agentappears nowhere else in the tree, so the key never matchedand the
subagentcapability was never emitted. The workingweb_fetch/web_searchentries already use their Crew names -- the subagent entry was theodd one out. Re-keying to
use_subagentfollows the pattern the surroundingcode already implies (the map's own docstring: "the built-in tools Crew's specs
actually name"). With the capability granted, KAS auto-approves the spawn and no
permission request is raised, which is what clears the reported repro.
Root cause B (documented, NOT fixed here, and it IS in this repo).
Our own earlier triage placed B in
_dispatch.pyand hypothesized it lived inkiro-cli. Both are wrong. The exact reported string is emitted atsrc/kiro_crew/cli_chat.py:786, inside the_unverifiable_shellbranch of theCLI permission handler.
_unverifiable_shell(cli_chat.py:464) returns Truewhenever
not event.shell_classified-- i.e. whenever the precedingtool_callframe carried no resolvable string
kindto cache (_dispatch.py:979,shell_classified = cached_shell is not None; the cache is written only when_kind_resolved). A sub-agent spawn that KAS does not label with a shellkindis therefore treated as an unverifiable command and auto-refused with this exact
message -- but ONLY on the interactive-prompt path, i.e. for a sub-agent that is
NOT auto-approved. A auto-approves the reported case (spawn never reaches this
gate), so A alone clears the repro; B remains a latent false-denial for any
sub-agent that legitimately needs a prompt.
B is deliberately out of scope here:
_unverifiable_shellis a fail-closedauthorization gate whose contract is "an absent classification is not a negative
one." Making it distinguish "sub-agent tool, legitimately non-shell" from
"uncached shell call" must rely on a TRUSTED classification signal, not the
agent-authored
tool_kind(trusting that to WAIVE the check is the bypass thegate exists to prevent). That is a design change with real blast radius, not a
minimal fix, so it belongs in its own change. This PR does not claim the symptom
is fully resolved for the non-auto-approved case; it references #9024 with
Refs, not a closing keyword.What tests we did
test_the_crew_subagent_name_grants_the_subagent_capabilityandtest_the_kas_internal_subagent_name_is_not_the_keytotest/test_kas_permissions.py(capability-lookup level, as requested).pytest -n0 test/test_kas_permissions.py test/test_derived_agent_permissions_consumers.py-> 66 passed (run with
-n0explicitly; no full suite).black --check --target-version py310(clean),isort --check-only(clean),flake8(clean),mypy src/kiro_crew/acp/kas_permissions.py(clean).git grepfordef _unverifiable_shell|def _can_promptunderacp/_dispatch.pyreturnsnothing (rc=1), while the same probe form under
cli_chat.pyfires (rc=0,lines 464/318); and the literal deny string is at
cli_chat.py:786.Any other suggestions
disclose_context -> skillentry (KAS's internal name; no CrewallowedToolsnames a skill tool, so it never matched) was removed in thisPR at the First Principles reviewer's suggestion -- deletion is
behavior-identical (a never-matching key and an absent key both prompt) and
removes a false promise from a map documented as keyed on Crew tool names.
classification (or a known model-wrapping tool like
use_subagent) is not an"unverifiable command," so the false denial does not survive on the
interactive path.
Pattern harvest
Rule candidate: When a lookup table is "keyed on a tool name," verify which
NAMESPACE the key must be in by reading the call site that consumes it, not by
trusting the value's plausibility. Here the map is consulted against Crew's
allowedTools(Crew names), so a KAS-internal toolId key is dead on arrival --and the working sibling entries (
web_fetch) already showed the correctnamespace. A one-line data bug can hide behind a correct-looking value.
Refs #9024