Skip to content

fix(kas): key subagent auto-approve on the Crew tool name - #9050

Closed
chenmingwei23 wants to merge 1 commit into
mainfrom
fix/kas-subagent-capability-9024
Closed

chenmingwei23 wants to merge 1 commit into
mainfrom
fix/kas-subagent-capability-9024

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

What is the problem?

On the kas ACP backend, a sub-agent spawn is always auto-denied. The user is
shown "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 kas backend, and the denial message is
factually 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.py translates a Crew agent's allowedTools
into a KAS permissions policy via CAPABILITY_BY_TOOL. That map was keyed on
KAS's internal toolId invoke_sub_agent, but allowed_tools_to_permissions is
consulted against the allowlist Crew actually writes, which carries the CREW
name use_subagent (see apps/builtins/pptx_maker/agents/*.json,
acp/liveness._MODEL_WRAPPING_TOOLS, and dashboard/chat_runner). The name
invoke_sub_agent appears nowhere else in the tree, so the key never matched
and the subagent capability was never emitted. The working web_fetch /
web_search entries already use their Crew names -- the subagent entry was the
odd one out. Re-keying to use_subagent follows the pattern the surrounding
code 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.py and hypothesized it lived in
kiro-cli. Both are wrong. The exact reported string is emitted at
src/kiro_crew/cli_chat.py:786, inside the _unverifiable_shell branch of the
CLI permission handler. _unverifiable_shell (cli_chat.py:464) returns True
whenever not event.shell_classified -- i.e. whenever the preceding tool_call
frame carried no resolvable string kind to 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 shell kind
is 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_shell is a fail-closed
authorization 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 the
gate 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

  • Added test_the_crew_subagent_name_grants_the_subagent_capability and
    test_the_kas_internal_subagent_name_is_not_the_key to
    test/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 -n0 explicitly; no full suite).
  • Lint on both touched files, run independently:
    black --check --target-version py310 (clean), isort --check-only (clean),
    flake8 (clean), mypy src/kiro_crew/acp/kas_permissions.py (clean).
  • B's location established by paired probe: git grep for
    def _unverifiable_shell|def _can_prompt under acp/_dispatch.py returns
    nothing (rc=1), while the same probe form under cli_chat.py fires (rc=0,
    lines 464/318); and the literal deny string is at cli_chat.py:786.

Any other suggestions

  • The dead disclose_context -> skill entry (KAS's internal name; no Crew
    allowedTools names a skill tool, so it never matched) was removed in this
    PR 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.
  • B deserves its own issue/PR: teach the CLI gate that a trusted non-shell
    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 correct
namespace. A one-line data bug can hide behind a correct-looking value.

Refs #9024

@chenmingwei23
chenmingwei23 requested review from a team and buluoray September 6, 2026 15:52
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 6, 2026
@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of c431d2f5dfa1b158c2e1fd28ea04cd1f5dd74f08 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

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: use_subagent is what Crew's allowedTools carries (pptx_maker/agents/*.json, liveness._MODEL_WRAPPING_TOOLS), and invoke_sub_agent now appears nowhere outside this map's comment and the regression tests. The boundary story holds — subagent auto-approval was the map's pre-existing intent, carries no resource scope worth the withheld-family treatment, and governance still runs at Crew's own PreToolUse gate. Deferring cause B is right: waiving _unverifiable_shell needs a trusted classification signal and doesn't belong in a one-key data fix.

[DESIGN-REVIEWED] c431d2f

@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

Reviewed c431d2f5dfa1b158c2e1fd28ea04cd1f5dd74f08 — this comment is updated in place on each push.

Review details

The change is a straightforward, correct re-keying validated against the actual allowedTools contents (confirmed use_subagent appears in the pptx_maker agent JSONs; invoke_sub_agent appears nowhere as a Crew tool name). The subagent capability is intentionally auto-approvable (not in WITHHELD_FROM_AUTO_APPROVE), so newly granting it via the correct key is the intended fix, not a widened blast radius. The removed disclose_context entry was dead. Tests assert both the positive grant and the negative. Nothing survives falsification, and I found no new grounded defect.

No findings.

[OPUS-REVIEWED] c431d2f

Verdict parsed from the review's SHA-scoped output markers for commit c431d2f5dfa1b158c2e1fd28ea04cd1f5dd74f08.

False positive or not applicable? A repository writer can comment:
/ai-review override fable c431d2f5dfa1b158c2e1fd28ea04cd1f5dd74f08: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of c431d2f5dfa1b158c2e1fd28ea04cd1f5dd74f08 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

All counts verified. invoke_sub_agent and disclose_context occur nowhere else in the tree (dead keys), use_subagent is the name real allowedTools lists carry (2 shipped agent specs plus liveness/chat_runner), the surviving web_fetch/web_search keys are genuine Crew names in shipped specs (mochi, pptx_maker, defaults.json — so zero unfixed wrong-namespace siblings), and allowed_tools_to_permissions has 2 real consumers (acp/kas_agents.py:511, agent_sdk/drivers/acp.py:90). No spec pins the map's entries, so no same-commit doc gap. Final review:

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 ships

Intent: make sub-agent spawns usable on the KAS backend by granting the capability the allowlist actually names — a FIX.

  1. Sub-agent spawns auto-approve on KAS when the agent spec allows use_subagent — justified, cause-level (invoke_sub_agent matches nothing: 0 other occurrences grepped).
  2. Dead disclose_context → skill entry deleted — declared rider, behavior-identical (0 occurrences elsewhere), and it is a subtraction.
  3. The remaining CLI-side false denial (root cause B) is documented, not fixed — declared, level stated, correctly deferred out of scope.
  4. Two regression tests pin the key's namespace; one existing test re-keyed to a valid name — justified.

Sibling count for the root cause (wrong-namespace map keys): 0 remaining — web_fetch/web_search are real Crew allowedTools names in shipped specs (mochi, pptx_maker, config/defaults.json).

Subtractions

  • Shrink the 9-line comment at kas_permissions.py:66-74 to the namespace constraint alone; the closing sentence narrating the removed disclose_context entry is history of the diff, not a constraint on the code — delete it.

[FIRST-PRINCIPLES-REVIEWED] c431d2f

@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of c431d2f5dfa1b158c2e1fd28ea04cd1f5dd74f08 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] c431d2f

False positive or not applicable? A repository writer can comment:
/ai-review override gpt c431d2f5dfa1b158c2e1fd28ea04cd1f5dd74f08: <one-sentence reason>

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.
@chenmingwei23
chenmingwei23 force-pushed the fix/kas-subagent-capability-9024 branch from 853b808 to c431d2f Compare September 6, 2026 16:05
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Sep 6, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Superseded by #9053, which fixes both causes of #9024.

This PR fixed cause A only (re-key CAPABILITY_BY_TOOL to the Crew name use_subagent) and documented cause B as out of scope. #9053 reaches cause A the same way and additionally fixes cause B correctly -- it reads the capability from the backend-stated _meta.kiro.consent.capability and relaxes the _unverifiable_shell refusal only through a fail-closed allowlist, so an allowlisted sub-agent spawn can reach the human instead of being falsely auto-denied.

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.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #9053, which fixes both root causes where this PR fixed only the capability-keying half. Detail and our independent review of #9053 are in the comments above. No objection to #9053 from our side.

@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 6, 2026
@bolichen97
bolichen97 deleted the fix/kas-subagent-capability-9024 branch September 20, 2026 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant