Repository navigation
fix: let a bot take an agent with many hooks and sub-agent or skill allows - #31241
Conversation
|
Hi maintainers, this is a fork PR, so its workflow runs are waiting for approval ( The two red rows so far, Fork PR Description and PR Readiness, did not fail on content. Both hit |
a109dba to
16c6eb7
Compare
Crew fires an agent spec's own hooks itself on KAS and the other harnesses that carry no hooks field, and read only the first 20 of them. An installed agent with 26 hooks lost six in a plain chat, and a Bot whose merged worker spec passed 20 was refused when abilities were added from that agent. Raise the per-spec bound to 64. It still stops a runaway spec from spawning without limit on every turn, and an installed agent's ordinary set now runs whole, as kiro-cli runs it.
Adding an agent's abilities to a Bot carries its permission rules onto the Bot's worker exactly, or refuses. With an allowedTools list present, KAS's projection drops a built-in allow the list could express, so a bare allow on subagent or skill was refused as uncarried, and the whole add failed. Carry such an allow as the one allowedTools name KAS derives it back from (use_subagent for subagent, disclose_context for skill), the way an mcp allow is carried as its refs. Only an unscoped allow on a capability exactly one tool name stands for is carried; a name-scoped allow is never widened to the whole tool. An excluded tool is not written back, and the governance ceiling still filters the merged list. The Add-abilities preview lists that tool name as an approval row and says the add lets it run unasked, so it shows every grant the add writes.
16c6eb7 to
3d01799
Compare
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks: both causes are fixed where they start (the bound and the carry rule), issue #31218 is the provenance, and the preview change follows the base rule that a preview lists every grant the file will hold. Notes
What this change shipsInventory (6 items) — 4 justifiedIntent: let an installed agent with many hooks and bare sub-agent/skill allows be added to a Bot and run whole. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 3d01799 Description read[DESCRIPTION-READ] 8c46bd4ec1dae6a03b712002d32da553eed0f5d087994ba24a8cc79bb99c015b That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns. Both changes stay within the 2026-11-02 "carry exactly or refuse" decision: the carry only fires after Notes
[DESIGN-REVIEWED] 3d01799 Description read[DESCRIPTION-READ] 2f27e0f6b0c7eceadf6f5736128b5a4078ceacda9a610d28b0247c45323fe31f 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 |
GPT 6.1 Review (fork) — ✅ no blocking findings (all downgraded on adjudication)Reviewed Opus 5.5 adjudication downgraded every blocking finding. Downgraded: the remedy each one needs is disproportionate to the harm it prevents. Adjudication downgraded all 1 blocking finding(s): the remedy each one requires is disproportionate to the harm it prevents. Review detailsBLOCKING -- src/kiro_crew/mate_worker_kit.py:221 -- Excluded built-ins are falsely previewed as new auto-approvals
Adjudication (Opus 5.5) — is blocking on each finding proportionate?F1: LOW. The defect only overstates the preview, and it errs toward caution. The diff ( Fixing it means copying the merge's exclusion model into the preview predicates: the file's |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
Code change approver recommendation: ApproveWhy: the decider estimates a 12% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes. Approve. The hook cap goes from 20 to 64 and every consumer reads the constant; it is still a bound and is shared with the ~/.kiro/hooks files. The new carry of bare built-in allows (subagent→use_subagent, skill→disclose_context) only fires on an exact unscoped allow, is proved by allow_granted_by_spec before it is written, never writes an excluded tool, and still passes through the governance ceiling. Revocations are stripped after the merge, so a revoked approval stays revoked. The preview lists the new row and sets runs_unasked, and apply's re-grant only touches approvals the file adds. Tests cover the new behaviour, and prove.py shows the hook test fails with the production change reverted. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
bolichen97
left a comment
There was a problem hiding this comment.
Approving head 3d01799bfd.
builtin_allow_toolmaps only an unscoped allow (capability+effectalone) whose capability exactly one Crew tool name stands for. A name-scopedsubagentallow stays a permission rule, so nothing is widened past the rule._carry_builtin_allowwrites that one name only afterallow_granted_by_specproves it grants the same rule, and it respectsexcludedTools. The governance ceiling still runs over the merged spec.- Raising
_MAX_SPEC_HOOKSfrom 20 to 64 keeps a bound, and the docs now say hooks past it are named in a warning.
On this head, test_crew_fired_spec_hooks.py + test_kas_user_hook_files.py + test_mate_spec_policy.py gave 198 passed. CI and every review lane pass. I'll merge it now.
AI-assisted, sent by CommunityCrew
Problem / Motivation
Goal: An installed agent with more than 20 hooks, or with bare sub-agent and skill allows, can be added to a Bot, and its worker runs all of it.
Adding such an agent's abilities to a Bot is refused with
template_restrictions_uncarried: hooks, permissions rule 5 (allow subagent), permissions rule 6 (allow skill), so the Bot's worker gets none of the agent's hooks or rules. The same agent run directly in a KAS chat also loses every hook past the 20th, with a warning.Why it matters
An agent installed and kept up to date by an external package manager commonly ships more than 20 hooks (setup, guards, sync). Today that agent can't be given to a Bot at all, and a plain KAS chat on it silently skips part of its own guards and sync steps.
Not a goal
subagentlimited to named agents). It has no exactallowedToolsspelling and is kept as a permission rule, as before.kiro_hooks._MAX_USER_HOOKS_PER_EVENT,_MAX_TOTAL_USER_HOOKS).What changed (motivation → approach → change)
Two causes, one commit each.
agent_sdk/spec_hooks._MAX_SPEC_HOOKSwas 20.spec_script_hooksread no more than that per spec, andmate_spec_policy._layer_hooksrefused a merged worker spec past it. The bound exists so a runaway spec cannot spawn without limit on every turn. It is now 64: still a bound, high enough that an installed agent's ordinary set runs whole, as kiro-cli runs it. The standalone~/.kiro/hooksfiles share the same bound and move with it.allowedToolslist present, KAS's projection drops a built-in allow the list could express, so_layer_permissionsrefused it as uncarried. fix(mate): carry template mcp allows for base-declared servers to workers #29893 carries anmcpallow as itsallowedToolsrefs; this does the same for an unscoped built-in allow.kas_tool_view.builtin_allow_toolreturns the oneallowedToolsname KAS derives the rule back from (kas_permissions.CAPABILITY_BY_TOOL:use_subagentforsubagent,disclose_contextforskill).mate_spec_policy._carry_builtin_allowadds it only whenallow_granted_by_specthen proves the rule granted, never writes a tool the worker excludes, and leaves a rule withmatchorexcludealone, so nothing wider than the rule is written. The governance ceiling still filters the merged list.The Add-abilities preview counts that grant too. #33033 made it count a carried
mcpallow;mate_worker_kit._permission_refsnow also lists a carried built-in name (use_subagent,disclose_context) as anallowedToolsrow, and_runs_unaskedreports that the add lets it run without a prompt, so the preview shows every grant the merge writes. Tested bytest_mate_spec_policy.py::test_a_builtin_allow_previews_as_the_tool_name_the_worker_gains.This applies the 2026-11-02 decision (
docs/decisions/2026-11-02-a-crewmates-worker-carries-its-template-policy.md, carry exactly or refuse) to rules it refused although they could be carried exactly.docs/system-specs/modules/crew-mode.md,src/kiro_crew/docs/crew-members.mdandsrc/kiro_crew/docs/steering-and-hooks.mddescribe both.Backwards compatibility
Compatible: every worker and chat that started before starts with the same grants and hooks. A spec with 21 to 64 hooks now runs all of them instead of the first 20, and an add that was refused for these rules now succeeds.
Removes nothing: the change only raises a bound and carries rules that were refused; no field, key, route or record is removed or narrowed.
Tests
test/test_crew_fired_spec_hooks.py: an agent spec with 26 hooks across three events runs all 26; the over-cap audit tests keep reading the cap from the constant.test/test_kas_user_hook_files.py: the over-cap file fixture is built from the cap instead of a fixed 30.test/test_mate_spec_policy.py:subagent,skillorweb_fetchallow lands asuse_subagent,disclose_contextorweb_fetch, andallow_granted_by_specproves itsubagentallow is never widened touse_subagentuse_subagentgets no auto-approval back, and the worker startsProof: PROVEN test/test_crew_fired_spec_hooks.py::test_an_installed_agents_twenty_six_hooks_all_run (head 3d01799)
Run on head 3d01799: the line above is
prove.py's output, which reverts the production hunks in a throwaway worktree. 458 tests pass acrosstest_crew_fired_spec_hooks.py,test_kas_user_hook_files.py,test_mate_spec_policy.pyand the ten Bot-worker test files.black,isort,flake8,mypyon the four changed modules,check_brand_name.py,check_comment_history.py,check_decisions_history.py,check_changelog_history.py,check_feature_map.py,check_testpaths_coverage.py,check_file_line_cap.py,check_subprocess_encoding.py,check_harness_parity.pyanddocs-lint.shpass.Of the other test files that import the worker kit, 304 tests pass and one fails:
test_harness_parity.py::test_is_kiro_cli_is_positive. It fails the same way on plainmain, because the test host has a Copilot CLI config file in its home directory. This change does not cause it.Manual verification
On a real install, the add preview for an agent with 26 hooks and both allows was refused with the error above before this change. The fix is covered end to end by the unit test that previews and applies that shape; I have not re-run the live add on this branch.
Related Issues
Closes #31218
Sibling sweep
Swept: git grep -n "_MAX_SPEC_HOOKS|permission_allow_derivable|_carry_mcp_allow" -- src/
Sibling: src/kiro_crew/agent_sdk/spec_hooks.py -- changed here
Sibling: src/kiro_crew/mate_spec_policy.py -- changed here
Sibling: src/kiro_crew/agent_materialization/kiro_hooks.py -- not affected -- caps the Hooks page's own hooks merged into specs Crew renders, not a spec's own hooks
Pattern harvest
Not generalizable: two bounds and one carry table that predated agents of this size; no wider shape to lint for.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.