Skip to content

KiroCrew adds ~50–90k tokens before the first message, which raises cost and degrades agent performance #13232

Open

Description

@zhihonl

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

  1. 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
    in tools actually narrow what mcp-core advertises.
  2. Skip the [AGENT SYSTEM PROMPT] injection on backends that already load the
    agent prompt natively.
  3. Slim the per-turn wrapper. Send static rules once (in the system prompt or the
    first turn) instead of on every message, and fix the yourPrompts accounting so
    users can see what they're paying for.
  4. Add a "lean" session mode that loads only the agent's declared tools plus the
    minimal control plane.

Activity

  1. added
    area: agentsACP runtime, sub-agents, session lifecycle
    area: coreCore runtime utilities, config/paths, process singletons
    enhancementNew feature or request
    on Sep 24, 2026
  2. github-actions commented on Sep 24, 2026

    @github-actions
    Contributor

    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

    • confirmation of how the per-source token numbers were measured (which breakdown view or export)
    • the custom agent spec and its tools/disabledTools entries that reproduce the mount and the bind error
    • whether the double prompt injection and the full tool list also occur on other backends

    Posted by issue-summary.yml. The model had no access to the repository — it read only this issue and the titles of recent ones.

  3. added
    needs-humanTriage: requires a human or product decision
    and removed
    needs-triageAwaiting automated triage
    on Sep 24, 2026
  4. chenmingwei23 commented on Sep 24, 2026

    @chenmingwei23
    Contributor

    🤖 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.

  5. bolichen97 commented on Sep 25, 2026

    @bolichen97
    Contributor

    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 kirocrew spec's prompt to 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 whose prompt names its own persona file is out of scope and still gets that prompt both ways.

    On main, _load_agent_prompt still 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 own prompt goes 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 when is_new_session is 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:

    • yourPrompts isn'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.
    • A code comment in the session-start branch estimates a full session-start injection at ~40K tokens (context.py L4865-L4872). That's an estimate, not a measurement of your session.
    • For an exact figure, open the Context tab in the chat activity panel (/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 disabledTools don't narrow kirocrew-core, but managedToolPolicy.exclude does.

    • When Crew builds the session/new mount, a @kirocrew-core/skill_search ref counts as a grant of the whole server. parse_tools_refs reduces @server and @server/tool to the same server name (mcp_refs.py L94-L121), and kiro_control_plane_servers checks the grant by that name (session_mcp.py L997-L999).

    • A non-empty disabledTools withholds the whole server (session_mcp.py L1011-L1019). On a skill-search agent that becomes the Cannot 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 main is a top-level deny list in the agent spec:

      "managedToolPolicy": { "exclude": ["issue_radar_crew_record", "ops_mission_control_api"] }

      For each session running that agent, kirocrew-core reads this list from the gateway. It drops those tools from its tools/list answer and refuses them in tools/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 the kirocrew-core server entry, so it doesn't trigger the withhold above.

      Caveats:

      • It's a list of tools to hide, not an allowlist.
      • kiro-cli fetches tools/list once per session, so a change only applies to new sessions.
      • If the policy can't be read when the list is requested, the list goes out unfiltered. Calls to excluded tools are still refused.
      • Keep skill_search off the list for a skill:// agent.
      • I haven't measured the token savings in a live session.

    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.

  6. added
    tier:T3Changes an existing user experience; needs a one-pager
    on Oct 3, 2026
  7. bolichen97 commented on Oct 5, 2026

    @bolichen97
    Contributor

    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 kirocrew prompt only. For a custom agent whose prompt is its own text or file:// persona, _load_agent_prompt still 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_session is true (context.py L3190). This repo never computes yourPrompts, 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.

    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.

  8. KiroCrewCaptain commented on Oct 8, 2026

    @KiroCrewCaptain
    Collaborator

    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/).

  9. cruisercohen commented on Oct 13, 2026

    @cruisercohen
    Contributor

    #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/).

  10. added
    parkedKept open as a request; not on the current plan
    on Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: agentsACP runtime, sub-agents, session lifecyclearea: coreCore runtime utilities, config/paths, process singletonsbugSomething is not workingenhancementNew feature or requestneeds-humanTriage: requires a human or product decisionparkedKept open as a request; not on the current plantier:T3Changes an existing user experience; needs a one-pager

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions