Skip to content

[Bug] Resumed agent session uses 329k–340k input tokens per request across six consecutive edits to the same Markdown file #1193

Backlog

Description

@weiwei929

Summary

Description

I’m reporting a suspected context-management defect in the Command Code agent harness. After I resumed a documentation task the next day, six consecutive model calls edited the same AGENTS.md file. Studio reported roughly 330,000 input tokens for each call. I matched the six requests to six edit_file calls in the local session transcript by timestamp.

Environment

  • Windows, Command Code v1.93.6, agent mode
  • Model: moonshotai/Kimi-K3.1-Pro
  • Plan: GOAT
  • Observed on December 2, 2026. All times below are UTC+8.

What happened

  1. On December 1, I asked whether the baseline documentation needed updating after a version upgrade. During its initial checks, the agent read several large workspace records. Three of those tool results alone returned approximately 226,500 characters.
  2. On December 2 at 14:00, I resumed the same session and asked the agent to continue the existing task.
  3. From 14:01:45 to 14:03:51, the agent issued six consecutive edit_file calls against the same AGENTS.md. Studio showed these input counts in chronological order:
    329,682 → 336,607 → 337,496 → 338,132 → 338,943 → 339,929
  4. Those six requests totaled 2,020,789 input tokens and 7,892 output tokens. Immediately after the sixth edit, the session reported that the five-hour usage limit had been reached.
    Why this matters

I understand that resuming a session preserves context. The concern is that earlier bulk reads appear to have continued contributing to the input for every small follow-up edit. Even if Studio counted every token correctly, the same workflow could repeatedly consume users’ plan allowances during routine document maintenance.

Expected behavior

When a resumed task narrows to local edits, the harness should retain the context needed to make those edits reliably. If it needs to keep hundreds of thousands of input tokens across successive calls, the user should be able to see that before the next calls consume their allowance and have a practical way to reduce the context while preserving task progress.

Requested investigation

  • Can you reproduce this by resuming a session after large tool reads and making several small edits to one file? Please check which earlier tool results or summaries were retained and whether context compaction was eligible or triggered.
  • For the six traces, how much input was cached versus uncached, and how much did each call deduct from the five-hour allowance? This would establish the user impact separately from the raw token total.
  • If unnecessary context was retained, please add a regression test for this workflow and identify the release containing the fix. Please also explain how affected usage will be identified and credited where appropriate.

Related report: Issue #1003 documents a different observed failure involving compaction summaries growing across a long session. My evidence establishes repeated large inputs after resumption. I haven’t established whether the two cases share a root cause.

I’ve saved all six full trace IDs and can share them privately with a maintainer, along with a redacted session log excerpt.

The top six rows correspond to six consecutive edits to the same AGENTS.md file. The bottom row shows the preceding request, which already had 319,743 input tokens.

image

Expected Behavior

When I resume a session to make small edits to one file, I expect the harness to retain the instructions, decisions, and file content needed for those edits and to compact earlier tool output that is no longer relevant. If the next request still needs roughly 330,000 input tokens, I would like to see that estimate before it runs and have the option to compact the session without losing task progress.

Actual Behavior

After I resumed the session, the agent made six consecutive edits to the same AGENTS.md file between 14:01:45 and 14:03:51 on December 2, 2026 (UTC+8). I matched each edit in the local session log to a request in Studio by timestamp.

Studio reported 329,682 to 339,929 input tokens per request, totaling 2,020,789 input tokens and 7,892 output tokens. Immediately after the sixth edit, Command Code reported that the five-hour usage limit had been reached.

Steps to reproduce the issue

  1. Start a documentation maintenance task in Command Code agent mode. In my session, the agent read several large Markdown files while checking which baseline entries needed updating. Three tool results alone returned about 226,500 characters.
  2. The next day, reopen the same conversation and ask the agent to continue the unfinished update.
  3. In my session, Kimi K3.1 Pro then made six consecutive edit_file calls against the same AGENTS.md file.
  4. Open Studio → Usage and match those six requests to the edits by timestamp. Check the INPUT ALL column: each request showed 329,682–339,929 input tokens.

These steps describe the observed session. I have not tested whether a fresh session reproduces the same behavior.

Command Code Version

1.93.6

Operating System

Windows

Terminal/IDE

Command Code Desktop

Shell

No response

Session file (optional)

No response

Fix prompt (optional)

No response

Additional context

No response

Activity

  1. weiwei929 commented on Dec 2, 2026

    @weiwei929
    Author

    One more observation: I’ve used Command Code for similar baseline documentation updates before and rarely saw this level of usage. I noticed it after updating the CLI to v1.93.6. The large file reads had already happened before I verified the new CLI version. The six ~330k-input requests occurred the next day, after I resumed that same session in Command Code Desktop. Could you confirm which harness build Desktop used for those requests and compare how it handles resumed sessions against the previous build? I haven’t run a controlled comparison across versions.

  2. weiwei929 commented on Dec 3, 2026

    @weiwei929
    Author

    I matched two adjacent requests in Studio to the cacheReadTokens values recorded by Desktop. Both were edits to the same AGENTS.md file in the same resumed Kimi K3.1 Pro session on December 2, 2026 (UTC+8).

    Time Trace ID prefix Total input Cache-read tokens Studio cost
    14:01:45 a0dba8b7 329,682 319,744 (97.0%) $0.125
    14:02:09 8cf21006 336,607 0 (0%) $0.678

    The requests were 24 seconds apart. Total input grew by only 6,925 tokens, but cache reads fell from 319,744 to zero. Across all six edits, Desktop recorded 400,384 cache-read tokens out of 2,020,789 input tokens (19.8%).

    I also verified the Desktop version from its startup log. Desktop 0.1.64 started at 13:59:46 and handled all six edits. The turn ended at 14:03:52. Version 0.1.65 was downloaded during the turn, but installation began at 14:05:18 and its first launch was at 14:06:20.

    Could you compare the reusable prompt prefix and cache routing for these two traces? In particular, did the harness change content near the start of the second request, or did a matching prefix produce zero cache reads on the serving side? I have both full trace IDs available privately.

  3. ahmadawais commented on Dec 3, 2026

    @ahmadawais
    Member

    @asharirfan take a look.

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