Skip to content

fix(kimi-code): show last-request token count for running subagents#86

Merged
kermanx merged 5 commits into
mainfrom
fix/subagent-token-display
May 26, 2026
Merged

fix(kimi-code): show last-request token count for running subagents#86
kermanx merged 5 commits into
mainfrom
fix/subagent-token-display

Conversation

@kermanx
Copy link
Copy Markdown
Collaborator

@kermanx kermanx commented May 26, 2026

Summary

  • Route agent.status.updated for subagents into the parent ToolCallComponent via a new updateSubagentMetrics method, so the token count refreshes while the subagent is still working (single-subagent view and grouped multi-subagent view).
  • Prefer the live contextTokens (= context size after the last request) over the cumulative usage sum when rendering the chip, both during work and on completion.
  • Carry contextTokens through subagent.completed (event + SDK + host emit) so the final chip matches what was shown mid-flight.

Test plan

  • pnpm -r typecheck
  • pnpm --filter @moonshot-ai/agent-core test test/session/init.test.ts
  • pnpm --filter @moonshot-ai/kimi-code test (877 passed)
  • Manual: run a turn with 2 parallel foreground subagents and verify the · N.Nk tok chip appears under each running agent and matches the final chip when they complete.

Route `agent.status.updated` for subagents to a new `updateSubagentMetrics`
on the ToolCallComponent so context-token counts refresh while the agent
is still working. Carry `contextTokens` through `subagent.completed` so
the final chip reflects the same number.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 26, 2026

🦋 Changeset detected

Latest commit: c9932cd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@moonshot-ai/agent-core Patch
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kermanx kermanx merged commit 5e354d0 into main May 26, 2026
4 checks passed
@kermanx kermanx deleted the fix/subagent-token-display branch May 26, 2026 14:07
@github-actions github-actions Bot mentioned this pull request May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants