Skip to content

[Bug]: Auto-compaction is recorded as a user-sent /compact and the message that triggered it is missing from the thread #40925

Closed

Description

@mchataigner

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Use a long thread with a Claude provider (claude-opus-5-5) whose context is near the auto-compaction threshold.
  2. Send a normal message from the web UI (here: "use webgpu" plus a follow-up sentence).
  3. Read the thread back, in the UI or with t3_thread_read (view: "activity").

Expected behavior

  • Auto-compaction appears as a system event, such as "Context compacted automatically", and is not attributed to the user.
  • The message I sent appears in the thread as a user_message, followed by the agent's reply.

Actual behavior

The single send became two runs created about 40 ms apart:

Run Requested at Stored items
2 15:20:46.022Z a user_message with text /compact, createdBy: "user", creationSource: "web"; then a compaction item and a SessionStart:compact system_notice
3 15:20:46.064Z no user_message: the run starts directly with agent reasoning
  • I never typed /compact, but the thread shows it as a message from me.
  • The agent did receive my message: in run 3 it acts on "use webgpu" and on another detail from my text. Neither appears anywhere in the thread, in the UI or via t3_thread_read.
  • So the history shows a command I didn't send and is missing the instruction I did send. Anyone reading the thread later can't tell why the agent changed direction.

Probable cause: auto-compaction goes through the user-message path as a synthetic /compact, and the triggering message is never stored as a user_message for the run that delivers it.

Impact

Minor bug or occasional failure

Version or commit

Not known

Environment

macOS web/desktop client, Linux server, Claude provider claude-opus-5-5

Logs or stack traces

recentRuns:
  ordinal:3  status=cancelled  requestedAt=15:20:46.064Z  startedAt=15:21:26.593Z   (later cancelled by a server shutdown, unrelated)
  ordinal:2  status=completed  requestedAt=15:20:46.022Z  startedAt=15:20:46.095Z  executedModel=null
items:
  338 user_message  run 2  createdBy=user creationSource=web  text="/compact"
  339 compaction    run 2  "Context compacted"
  340 system_notice run 2  "SessionStart:compact says: ..."
  341 checkpoint    run 2
  342 reasoning     run 3  "I'm switching the device to WebGPU ... Since the user says they're up to date ..."
  (no user_message for run 3)

Workaround

None. The lost message can only be inferred from what the agent did next.

🤖 Generated with Claude Code

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