Skip to content
This repository was archived by the owner on Sep 23, 2026. It is now read-only.
This repository was archived by the owner on Sep 23, 2026. It is now read-only.

Subagent context usage is not tracked or visible in parent agent statistics #2024

Open

Description

@heykb

Problem Description

Currently, subagent context/token usage is completely isolated from the parent agent'''s statistics. This leads to:

  1. 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.
  2. No compaction trigger for subagents: Auto-compaction only considers the parent context, so subagents can grow unbounded without triggering compaction.
  3. 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 Context instance with a separate context.jsonl file (src/kimi_cli/subagents/core.py:59)
  • Each subagent gets its own KimiSoul instance (src/kimi_cli/subagents/core.py:85)
  • StatusUpdate wire 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'''s StatusSnapshot
  • The Vis API /subagents endpoint only returns raw file sizes (bytes), not token counts

Expected Behavior

Users should be able to:

  1. See subagent context usage aggregated in the parent agent'''s status, OR
  2. Have a way to inspect individual subagent context usage (e.g., a slash command or API endpoint)

Possible Solutions

  1. Aggregate in parent status: Sum active subagents''' token_count into the parent'''s StatusSnapshot.context_usage
  2. Expose subagent stats: Add token_count/context_usage fields to AgentInstanceRecord and expose via Vis API
  3. New slash command: Add /subagents command to list running subagents with their context usage
  4. Event propagation: Forward subagent StatusUpdate events 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.

Image

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions