MoonshotAI / MoonshotAI/kimi-cli
Subagent context usage is not tracked or visible in parent agent statistics
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 11.4k
- Forks
- 1.3k
- Avg merge
- 9h 47m
- Merged PRs (30d)
- 2
Description
Problem Description
Currently, subagent context/token usage is completely isolated from the parent agent'''s statistics. This leads to:
- Invisible subagent context consumption: The parent agent'''s status bar shows only its own context usage, giving users no visibility into how much context their subagents are consuming.
- No compaction trigger for subagents: Auto-compaction only considers the parent context, so subagents can grow unbounded without triggering compaction.
- No inspection mechanism: There is no command, API, or UI feature to check a subagent'''s current token count or context usage percentage.
Current Behavior
- Each subagent gets its own
Contextinstance with a separatecontext.jsonlfile (src/kimi_cli/subagents/core.py:59) - Each subagent gets its own
KimiSoulinstance (src/kimi_cli/subagents/core.py:85) StatusUpdatewire messages only contain the current soul'''s context metrics (src/kimi_cli/soul/kimisoul.py:951-961)- The UI status bar (
src/kimi_cli/ui/shell/prompt.py) only renders the parent soul'''sStatusSnapshot - The Vis API
/subagentsendpoint only returns raw file sizes (bytes), not token counts
Expected Behavior
Users should be able to:
- See subagent context usage aggregated in the parent agent'''s status, OR
- Have a way to inspect individual subagent context usage (e.g., a slash command or API endpoint)
Possible Solutions
- Aggregate in parent status: Sum active subagents'''
token_countinto the parent'''sStatusSnapshot.context_usage - Expose subagent stats: Add
token_count/context_usagefields toAgentInstanceRecordand expose via Vis API - New slash command: Add
/subagentscommand to list running subagents with their context usage - Event propagation: Forward subagent
StatusUpdateevents to the parent wire stream
Additional Context
The Context class already tracks _token_count internally, so the data exists — it'''s just never read or exposed for subagents.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with subagent lifecycle and context handling in src/kimi_cli/subagents/core.py, then trace StatusUpdate and StatusSnapshot in src/kimi_cli/soul/kimisoul.py and rendering in src/kimi_cli/ui/shell/prompt.py. Review the Vis API /subagents endpoint and choose a defined exposure or aggregation path; done means subagent context usage is observable and compaction behavior is addressed without regressing parent statistics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100