Repository navigation
fix(kiro): refresh agent tools vocabulary and fail closed per agent - #3947
Conversation
Kiro agent `tools` validation now follows the current Kiro docs (https://kiro.dev/docs/custom-agents/configuration-reference/#tools-field, https://kiro.dev/docs/tools/): category tags, current built-in tool IDs, @server and @server/tool selectors, @Builtin, @mcp and *. CLI 2.x-only names such as grep and use_aws stay rejected. An agent with an unsupported tool is still never written (req-tg-009), but the diagnostic is now a warning, so conformant sibling agents in the same install deploy and are recorded in apm.lock.yaml instead of the whole install aborting. Refs #2671 Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The validator rejects valid subagent/<name> selectors and MCP tool selectors whose tool names begin with _, -, or ., causing otherwise valid agents to be skipped.
2 open issues
What changed in this PR
This PR refreshes APM’s Kiro agent tool validation and makes rejection non-fatal per agent, so conformant siblings can deploy and be recorded in the lockfile. Full Kiro configuration passthrough remains outside scope.
Changes:
- Expands accepted tool IDs and MCP selectors while retaining compatibility values.
- Changes rejected-agent diagnostics to warnings without allowing partial writes.
- Adds validation and sibling-install coverage, updates documentation, and regenerates conformance records.
| File | Description |
|---|---|
tests/unit/integration/test_kiro_target.py |
Adds selector acceptance/rejection cases and updates warning assertions. |
tests/spec_conformance/test_manifest_reqs.py |
Verifies rejected agents do not block sibling deployment or lockfile recording. |
src/apm_cli/integration/agent_integrator.py |
Expands tool validation and emits per-agent warnings. |
packages/apm-guide/.apm/skills/apm-usage/package-authoring.md |
Updates authoring guidance for selectors and skipped agents. |
docs/src/content/docs/reference/targets-matrix.md |
Describes updated Kiro tool support and failure isolation. |
docs/src/content/docs/producer/author-primitives/instructions-and-agents.md |
Explains selector validation and sibling deployment behavior. |
docs/src/content/docs/integrations/ide-tool-integration.md |
Updates the Kiro integration behavior summary. |
CONFORMANCE.md |
Updates the req-tg-009 test count. |
CONFORMANCE.json |
Records the additional req-tg-009 test. |
CHANGELOG.md |
Announces expanded tool support and per-agent warnings. |
Review effort: Balanced
req-tg-009 requires the diagnostic to identify the unsupported value and the approved set; the hint is now derived from the vocabulary constants so message and code cannot drift. Adds unit coverage for scalar and non-list tools forms. Addresses panel follow-ups (supply-chain-security-expert, test-coverage-expert). Co-authored-by: Copilot <[email protected]>
The per-agent skip lets reinstall complete, so a previously deployed agent whose tools become unsupported must be removed and dropped from the lockfile while siblings stay byte-identical (req-tg-009). Addresses panel follow-up (test-coverage-expert, supply-chain-security-expert). Co-authored-by: Copilot <[email protected]>
Addresses panel follow-up (supply-chain-security-expert). Co-authored-by: Copilot <[email protected]>
Kiro's tools field restricts sub-agent dispatch with subagent/<name> (kiro.dev/docs/custom-agents/subagents), and MCP tool names may start with _, - or . (SEP-986). Both were rejected, skipping valid agents. Addresses Copilot inline on src/apm_cli/integration/agent_integrator.py lines 80 and 97. Co-authored-by: Copilot <[email protected]>
Addresses delta panel follow-up (supply-chain-security-expert): the security model now states that unsupported Kiro tools skip only that agent, write nothing, are not locked, and exit 0. Co-authored-by: Copilot <[email protected]>
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Supply Chain Security Expert | 0 | 1 | 0 | The approved-set and reinstall findings are resolved. The widened selectors stay inside a safe ASCII boundary. Only the deferred strict switch and its security.md disclosure remain, and the disclosure is now folded. |
| Test Coverage Expert | 0 | 0 | 0 | Both earlier gaps are resolved: the reinstall-invalidation case is tested through the real CLI, and the scalar and non-list branches are covered. No gaps remain. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 1 follow-up
- [Supply Chain Security Expert] Track separately, not in this PR: a strict or policy option that makes unsupported-capability rejections fatal after siblings deploy and lock. -- This would bring back CI gating for pipelines that relied on exit 1, but it is a new governance surface beyond [FEATURE] Preserve full Kiro custom-agent config when compiling to the kiro target #2671's approved scope.
Recommendation
Ship once CI on the head is green; it is now green at 21704e0. All in-scope folds are done: the full approved set in the diagnostic, the reinstall end-to-end test, the scalar and non-list tests, the CHANGELOG exit-code wording, the security.md disclosure, and both Copilot vocabulary fixes. The one thing to track is the out-of-scope strict or policy switch, as a separate issue.
Folded in this run
- (supply-chain-security-expert) The rejection warning lists the full approved set, built from the constants (req-tg-009). Resolved in 40354b3.
- (test-coverage-expert) Unit tests for the scalar and non-list forms of
tools. Resolved in 40354b3. - (test-coverage-expert, supply-chain-security-expert) The req-tg-009 end-to-end test now covers an agent that becomes invalid on reinstall. Resolved in 54d15e0.
- (supply-chain-security-expert) The CHANGELOG states the exit-code change. Resolved in 4e6d696.
- (Copilot) SEP-986 MCP tool names and
subagent/<agent>are accepted. Resolved in 65d5a04. - (supply-chain-security-expert, delta pass)
enterprise/security.mddocuments the non-fatal gate. Resolved in 21704e0.
Copilot signals reviewed
src/apm_cli/integration/agent_integrator.py:80-- LEGIT: SEP-986 allows_,-and.at the start of a tool name (resolved in 65d5a04).src/apm_cli/integration/agent_integrator.py:97-- LEGIT: Kiro documentssubagent/<name>intools(kiro.dev/docs/custom-agents/subagents) (resolved in 65d5a04).
Deferred (out-of-scope follow-ups)
- (supply-chain-security-expert) A strict or policy switch that makes the Kiro capability gate fatal after siblings deploy and lock. -- Scope boundary: this adds a new governance surface beyond [FEATURE] Preserve full Kiro custom-agent config when compiling to the kiro target #2671's approved scope. Suggested follow-up: a separate issue with its own scope record.
Regression-trap evidence (mutation-break gate)
Each guard below was removed, the test failed as expected, and the guard was restored.
| Test | Guard removed |
|---|---|
test_kiro_agent_tools_gate_skips_one_agent_and_locks_siblings |
The warning reverted to an error |
test_kiro_agent_tools_gate_skips_one_agent_and_locks_siblings (reinstall step) |
A rejected agent's deployed record was retained |
test_kiro_agents_current_kiro_tool_identifiers_deploy |
The @server selector regex was dropped, or the pre-Copilot regex was restored |
test_kiro_agents_scalar_and_non_list_tools_forms |
The scalar branch reverted to an allow-list lookup, or the non-list branch reverted to an error |
test_kiro_agents_rejection_names_the_full_approved_set |
The hint reverted to examples only |
Lint contract
ruff checkandruff format --check(pinned at 0.15.12, CI paths): both silent.- pylint R0801,
lint-auth-signals.shandlint-architecture-boundaries.sh: all clean.
CI
All workflows are green on 21704e0: CI, Merge Gate, Spec conformance, CodeQL, NOTICE Drift, and Deploy Docs. It took 1 CI fix iteration. Build & Test Shard 1 hit a flake, tests/red_team/http/test_resource_exhaustion.py::TestDispatchThreadCap, which is unrelated to this PR and passed 3 of 3 locally. A failed-job rerun turned it green.
Mergeability status
| PR | head SHA | CEO stance | iters | folds | defers | Copilot rounds | CI | mergeable | mergeStateStatus | notes |
|---|---|---|---|---|---|---|---|---|---|---|
| #3947 | 21704e0 | ship_with_followups | 2 | 6 | 1 | 1 | green | MERGEABLE | BLOCKED | pending required review |
Full per-persona findings
Supply Chain Security Expert
- [recommended] The gate is still non-fatal, there is no strict opt-in, and
enterprise/security.mddid not document it. Atdocs/src/content/docs/enterprise/security.md.- The CHANGELOG now discloses that a rejected agent means exit 0. The CI-gating trade-off remains, and deferring the switch is acceptable because it is out of scope. The persona contract says the security model doc must match behavior.
- Suggested: add one sentence to
security.md, and file a follow-up issue for the strict switch. Thesecurity.mdsentence is folded in 21704e0.
Test Coverage Expert
No findings.
This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.
Generated by autopilot-pr-merge-worker. This comment is AI-generated and may contain errors.
Resolve package-authoring.md Kiro conflict: keep main's per-agent fail-closed wording (#3947) with this PR's targets: [kiro] spelling. Co-authored-by: Copilot <[email protected]>

Description
TL;DR
Kiro agent
toolsvalidation now follows the current Kiro docs: category tags, current built-in tool IDs,@server/@server/toolselectors (MCP SEP-986 tool names),subagent/<agent>,@builtin,@mcp,*. An agent with an unsupported tool is still never written (req-tg-009), but its diagnostic is now a warning. Sibling agents in the same install still deploy and are recorded inapm.lock.yaml, and the install no longer aborts.Problem (WHY)
KIRO_AGENT_ALLOWED_TOOLSset (from 2026-08). It rejected current Kiro tool IDs (web_fetch,grep_search,read_file,execute_bash, …) and every@serverselector.diagnostics.error, andfinalize_install_resultfails any install with an error diagnostic.main, a package withgatherer.agent.md(tools: [read, web_fetch, grep]) andcontrol.agent.md(tools: [read, web]) exits 1.control.mdis left on disk, untracked byapm.lock.yaml.Why this matters: req-tg-009 requires "failure for one agent MUST NOT prevent deployment of other, vocabulary-conformant agent primitives from the same dependency or install operation".
Approach (WHAT)
@server[/tool]/subagent/<agent>regex. Each part comes from kiro.dev/docs/tools and the tools-field reference.diagnostics.warninstead ofdiagnostics.error, so the install proceeds for siblings. The warning lists the full approved set, built from the constants (req-tg-009).contextandtodo_listfor compatibility. CLI 2.x-only names (grep,glob,use_aws) and@builtin/x/@mcp/xstay rejected.Implementation (HOW)
src/apm_cli/integration/agent_integrator.pyKIRO_AGENT_TOOL_TAGS,KIRO_AGENT_TOOL_SPECIAL_VALUES,KIRO_AGENT_TOOL_IDSandKIRO_AGENT_TOOL_COMPAT_VALUES.KIRO_AGENT_ALLOWED_TOOLSis now their union._KIRO_SELECTOR_REfor@server,@server/tool(SEP-986 characters) andsubagent/<agent>, each segment bounded at 128 characters, and addsis_kiro_agent_tool()._preflight_render_kiro_agentnow warn, with one shared hint that lists the approved set.description/model/toolsonly) is unchanged.tests/unit/integration/test_kiro_target.pysubagent/selectors) and reject cases (legacy and malformed selectors).toolsforms, and a test that the warning names the full approved set.tests/spec_conformance/test_manifest_reqs.py@pytest.mark.req("req-tg-009")end-to-end CLI test: one rejected agent, conformant siblings, exit 0, siblings locked. On reinstall, an agent that turned invalid is removed and unlocked, and its sibling stays byte-identical.CONFORMANCE.{json,md}are regenerated: req-tg-009 goes from 1 test to 2.instructions-and-agents.md,ide-tool-integration.mdandtargets-matrix.mdnow describe the new vocabulary and the per-agent skip.apm-usage/package-authoring.mdresource is updated the same way.enterprise/security.mdgets an "Agent tool capability gate (Kiro)" section on the non-fatal gate.Diagrams
Legend: what happens to each Kiro agent during install after this PR. The key change is the right-hand branch, which no longer fails the install.
flowchart LR A["agent tools value"] --> B{"is_kiro_agent_tool"} B -->|"tag, tool ID, @server, @server/tool, special"| C["render and write .kiro/agents/name.md"] C --> D["recorded in apm.lock.yaml deployed_files"] B -->|"anything else"| E["skip this agent, zero bytes"] E --> F["diagnostics.warn names the value"] F --> G["sibling agents keep deploying, install exits 0"]Trade-offs
enterprise/security.md. A strict or policy switch to make it fatal is deferred as out of scope.mcpServers,permissions,hooks) stays out of scope (needs-design).contextandtodo_listare no longer in the Kiro docs. They stay accepted so agents that deploy today keep deploying, and removing them is a separate breaking decision.grep,globanduse_awsas CLI 2.x only. The Markdown agents APM emits are a V3/IDE 1.0 format.Benefits
subagent/selectors deploy. 14 parametrized cases that were red onmainare now green.deployed_files.Validation
Real CLI on this branch:
gathererusesread, web_fetch, grep_search, @github/get_issue, andlegacyusesread, grep.Test and lint commands
main(17993ab)pytest tests/unit/integration/test_kiro_target.py tests/unit/integration/test_agent_integrator.py tests/spec_conformance/test_manifest_reqs.pypytest tests/unit/integration tests/spec_conformance tests/unit/installAPM_E2E_TESTS=1 APM_BINARY_PATH=.venv/bin/apm pytest tests/integration/test_kiro_agent_lifecycle.pydiagnostics.error@serverregexuvx [email protected] check+format --check(CI paths)lint-auth-signals.sh,lint-architecture-boundaries.shgen_statementScenario evidence
@serverselectors deploystests/unit/integration/test_kiro_target.py::test_kiro_agents_current_kiro_tool_identifiers_deploy.kiro/agents/tests/unit/integration/test_kiro_target.py::test_kiro_agents_reject_legacy_and_malformed_selectorstests/spec_conformance/test_manifest_reqs.py::test_kiro_agent_tools_gate_skips_one_agent_and_locks_siblingstests/spec_conformance/test_manifest_reqs.py::test_kiro_agent_tools_gate_fails_closed_before_adoptHow to test
.apm/agents/*.agent.mdfiles: one withtools: [read, web_fetch, "@git"], one withtools: [read, grep].targets: [kiro]and a.kiro/dir, runapm install ../pkg.[!]warning naminggrep, and only the first agent in.kiro/agents/and inapm.lock.yaml.Issue and approved scope
Issue: Fixes #2671
Human scope-approval comment: #2671 (comment)
This completes the approved scope. Full Kiro field passthrough is explicitly out of scope, stays needs-design, and is not part of this PR.
Type of change
Testing
Changelog
## [Unreleased]inCHANGELOG.md:user-visible effect first, 25 words or fewer, ending with
(#PR);breaking changes only under upgrade notes; no Highlights; see
.github/instructions/changelog.instructions.md.Spec conformance (OpenAPM v0.1)
@pytest.mark.req("req-tg-009")test undertests/spec_conformance/added or extended.CONFORMANCE.{md,json}regenerated viauv run --extra dev python -m tests.spec_conformance.gen_statementand committed.
Co-authored-by: Copilot [email protected]