Repository navigation
Description
Summary
A fresh KiroCrew dashboard session with a custom agent uses ~95k tokens after the
user types "hi". Most of it is KiroCrew overhead, not the agent's own configuration.
Every turn pays that cost again (or at best gets it cache-discounted), and a large
block of irrelevant tool schemas and repeated instructions degrades tool selection
and instruction-following. Irrelevant context isn't free even with a large window.
Environment: kirocrew 0.7.0.8, kiro ACP backend, dashboard chat, a custom agent
that uses skill:// resources.
Where the startup tokens go (context breakdown after one "hi")
| Source | Tokens | Owner |
|---|---|---|
| kirocrew-core tool schemas (85 tools) | ~28,000 | KiroCrew |
| Per-turn prompt wrapper (reported as 4.1% of 1M) | ~41,000 (unconfirmed) | KiroCrew |
| Agent prompt injected a second time | ~1,000 | KiroCrew |
| Agent's own tools (built-in + its MCP servers) | ~19,000 | Agent author |
| Agent's steering/context files | ~7,000 | Agent author |
Contributors
1. kirocrew-core ships all 85 tool schemas (~28k tokens) to every session.
It's the single largest tool group, about 60% of all tool tokens. Most of it has
nothing to do with a coding agent: issue_radar_, ops_mission_control_api, pod_,
artifact_folder_, workflow_, Slack helpers. The largest schemas: spawn_run 1.7k,
send_message 1.5k, monitor_start 1.3k, issue_radar_crew_record 1.2k,
spawn_sub_agents 1.1k.
This happens even when the agent author opts out. The generated spec grants only
@kirocrew-core/skill_search, but acp/session_mcp.py::kiro_control_plane_servers()
checks the grant by server name, so the whole server is mounted through
session/new. Setting disabledTools to trim it makes
acp/runtime.py::_unpooled_control_planes() fail the session with
Cannot bind skill_search to this session without losing native MCP restrictions.
Users have no way to reduce this cost.
2. The custom agent prompt is injected twice.
context.py (around line 4480) prepends [AGENT SYSTEM PROMPT] ... [END AGENT SYSTEM PROMPT]
to the first user message. kiro-cli has already loaded that same prompt as the system
prompt through --agent. Observed verbatim in both places.
3. The per-turn wrapper is large and possibly miscounted.
Every message is wrapped in [SESSION CONTEXT], [CRITICAL RULES], [RESPONSE PREFERENCES],
[REPLY FORMAT RULES], the skills list, and so on. The breakdown reports yourPrompts
as 3,954 tokens but also as 4.10% of the window (~41k). Either the count or the
percentage is wrong. If ~41k is right, it's the biggest item on the list.
Suggested fixes
- Tier kirocrew-core's tools. Expose a small core set by default (skill_search,
send_message, spawn_run, wait) and gate everything else (issue radar, ops, pods,
artifacts, workflows) behind explicit grants or per-app enablement. Make per-tool refs
intoolsactually narrow whatmcp-coreadvertises. - Skip the
[AGENT SYSTEM PROMPT]injection on backends that already load the
agent prompt natively. - Slim the per-turn wrapper. Send static rules once (in the system prompt or the
first turn) instead of on every message, and fix theyourPromptsaccounting so
users can see what they're paying for. - Add a "lean" session mode that loads only the agent's declared tools plus the
minimal control plane.
Activity
github-actions commentedon Sep 24, 2026
Automated triage summary — generated from the issue text alone, before any maintainer has read it. Treat every line as a starting point, not a verdict.
A fresh dashboard chat session with a custom agent on the kiro ACP backend consumes ~95k tokens after a single "hi", most of it KiroCrew overhead: all 85 kirocrew-core tool schemas are mounted regardless of per-tool grants, the agent prompt appears twice, and a large per-turn wrapper whose reported token count and window percentage disagree.
Worth adding
Posted by
issue-summary.yml. The model had no access to the repository — it read only this issue and the titles of recent ones.chenmingwei23 commentedon Sep 24, 2026
🤖 Kiro Crew Auto-Pipeline [operator: chenmingwei23#de330d0c]: Routing to needs-human. This bundles several architecture decisions (tool tiering for kirocrew-core, dropping the duplicate agent-prompt injection, slimming the per-turn wrapper, a new lean session mode) that need a maintainer call on scope and rollout before any one part is mechanically fixable.
bolichen97 commentedon Sep 25, 2026
Here's where each of the three findings stands on current
main. The design asks (tiering the tools, a lean mode, slimming the wrapper) are still open for a maintainer to decide.1. The agent prompt injected twice: fixed for the default agent only, not for your custom agent.
#13257 (ab4132c), merged after this issue was filed, sets the managed
kirocrewspec'spromptto a short stub. The operating contract now arrives only once, through the[AGENT SYSTEM PROMPT]injection (agent-spec-fields.md L336-L363). The same doc says an agent whosepromptnames its own persona file is out of scope and still gets that prompt both ways.On
main,_load_agent_promptstill returns a custom agent's own prompt for injection (context.py L3445-L3467), and kiro-cli also loads it through--agent. So what you saw still happens for a custom agent. #13305 tracks the rest. It is written around app-generated agents, but a hand-written agent with its ownpromptgoes through the same code path.2. The wrapper is added once per session, not on every message.
The big blocks (
[AGENT SYSTEM PROMPT],[CRITICAL RULES], memory, the skills index, lessons,[RESPONSE PREFERENCES]) are built only whenis_new_sessionis true (context.py L4863-L5047; context-management.md L30-L36).On a follow-up turn of an ordinary dashboard chat, Kiro Crew adds only short blocks, such as
[RUNTIME],[PROJECT],[BOARD]and the[REPLY FORMAT RULES]paragraphs (context.py L5560-L5601; context-management.md L168-L187). After a compaction, the agent prompt, memory index, skills index and response preferences are added back once (context-management.md L221-L241). The first-turn payload stays in the conversation history, so later turns still pay for it as input. It just isn't appended again.On 41k vs 4k:
yourPromptsisn't something Kiro Crew computes, and the name appears nowhere in the repo. So this repo can't tell which of the two numbers is right./api/telemetry/context-trace). It records, per turn, the size in characters of every block Kiro Crew injected, and shows the session-start turn separately.3. Per-tool refs and
disabledToolsdon't narrowkirocrew-core, butmanagedToolPolicy.excludedoes.When Crew builds the
session/newmount, a@kirocrew-core/skill_searchref counts as a grant of the whole server.parse_tools_refsreduces@serverand@server/toolto the same server name (mcp_refs.py L94-L121), andkiro_control_plane_serverschecks the grant by that name (session_mcp.py L997-L999).A non-empty
disabledToolswithholds the whole server (session_mcp.py L1011-L1019). On a skill-search agent that becomes theCannot bind skill_search…error (runtime.py L5878-L5886). That failure is tracked separately in Disabling any kirocrew-core tool from the dashboard makes every skill-search (kirocrew) session un-startable on the kiro backend #13639.What does exist on
mainis a top-level deny list in the agent spec:For each session running that agent,
kirocrew-corereads this list from the gateway. It drops those tools from itstools/listanswer and refuses them intools/call(mcp_shared.py L1408-L1434; sessions.py L4124-L4133; documented in agent-spec-fields.md L384 and mcp.md L1061). It isn't a field on thekirocrew-coreserver entry, so it doesn't trigger the withhold above.Caveats:
tools/listonce per session, so a change only applies to new sessions.skill_searchoff the list for askill://agent.The broader overhead audit (Kiro Crew vs plain kiro-cli) is #4749.
This comment doesn't address the implementation requests: tiering the tools, a lean mode, moving static rules out of the first turn, and fixing the remaining double delivery. The issue stays open for a maintainer decision.
Triage pass against main @ c66f95b.
bolichen97 commentedon Oct 5, 2026
Re-checked the three questions here against
main@af1eb612da. The answers in the 2026-09-25 comment still hold. One thing has changed since then.1. Double prompt delivery. No change. #13257 (ab4132c) fixed this for the managed
kirocrewprompt only. For a custom agent whosepromptis its own text orfile://persona,_load_agent_promptstill returns it for the[AGENT SYSTEM PROMPT]injection (context.py L2301-L2345, injected at L3224), and kiro-cli also loads it natively. #13305 tracks this and is still open.2. Per-turn wrapper. No change. The large blocks are added only when
is_new_sessionis true (context.py L3190). This repo never computesyourPrompts, so it can't say whether 41k or 4k is right. The chat activity panel's Context tab shows the measured per-block sizes.3. Narrowing
kirocrew-core.@kirocrew-core/<tool>ref still grants the whole server (mcp_refs.py L84-L125; session_mcp.py L1598-L1604).disabledToolsonkirocrew-core, whether in the spec, the global~/.kiro/settings/mcp.jsonor the project's settings, still stops a skill-search session from starting. The error now names the file, the restriction and how to undo it, instead of the genericCannot bind skill_search…message (runtime.py L6879-L6887). Let a kirocrew session run with a kirocrew-core tool toggle expressed instead of refusing it (follow-up to #14078) #14125 (open) tracks letting the session start with that tool removed instead of refusing it.managedToolPolicy.exclude. The MCP server filters it out oftools/listand refuses it intools/call(mcp.md L1219-L1221; agent-spec-fields.md L392). Keepskill_searchoff that list.This issue is not a duplicate of #4749. That one is the broader audit of overhead against plain kiro-cli.
Out of scope here: tiering the tools, a lean session mode, moving static rules out of the first turn, and removing the custom-agent double delivery. Those are the coding/design requests and still need a maintainer decision, so the issue stays open.
Q&A triage pass against main @ af1eb61.
KiroCrewCaptain commentedon Oct 8, 2026
This changes behaviour users already rely on, so it needs a design sign-off from a maintainer before it can merge. A maintainer will post the decision here. To propose a design, follow the request-for-change process in CONTRIBUTING.md (docs/request-for-change/).
docs(tools): describe the include list in the MCP and policy specs
feat(tools): opt-in include list from per-tool @kirocrew-core refs (#…
cruisercohen commentedon Oct 13, 2026
#19375 added an opt-in tool include list; the rest stays open here. We keep this request open so that others can find it. It is not on the current plan. If you need it too, add a thumbs-up reaction to this issue; we look at the most requested items first. To propose a design, follow the request-for-change process in CONTRIBUTING.md (docs/request-for-change/).