Skip to content

Cannot continue from message role: assistant after compaction timeout in 2026.5.26 #87472

Closed

Description

@bnobrega

Version: 2026.5.26 (10ad3aa)
Provider: anthropic/claude-sonnet-4-6 (also seen with fallback chain)
Frequency: 42 occurrences in ~3 hours across 4 distinct sessions, on a host that ran 2026.5.18 cleanly for weeks.

Pattern

Each occurrence follows the same sequence in the master log:

[T+0]      embedded run auto-compaction start
[T+60s]    compaction retry aggregate timeout (60000ms): proceeding with pre-compaction state
[T+60s]    using pre-compaction snapshot: timed out during compaction
[T+60s]    embedded run failover decision
[T+60s]    lane task error: lane=main … error="Error: Cannot continue from message role: assistant"
[T+60s]    lane task error: lane=session:agent:<id>:whatsapp:direct:<num> error=same
[T+60s]    model fallback decision

The user-visible result is a generic "Auto-compaction could not recover this turn" delivered to the channel even though the assistant had produced content in the previous turn.

Apparent root cause

After the compaction timeout, the gateway falls back to the pre-compaction snapshot but then ships a prompt whose last message has role: assistant. The Anthropic API correctly rejects this. The fallback path that retries with a different provider hits the same shaped prompt and also fails.

What I tried

  • daemon restart — bug recurs on next message even in a fresh session.
  • Reducing system-prompt bloat (M365 MCP filtered from 125 → 31 tools, schema chars 673k → 116k) — does not fix the role error; only delays compaction triggers.
  • compaction.reserveTokensFloor: 20000 (per upgrade notes) — present, doesn't help.

Reproduces with

  • Long-running session that accumulates tool-call exchanges
  • Bootstrap > 100k tokens (pushes auto-compaction earlier)
  • Sonnet 4.6 primary; same error after fallback to gemini-2.5-flash

Happy to share full anonymized log slice if useful.

Activity

  1. clawsweeper commented on May 28, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed May 27, 2026, 9:19 PM ET / 01:19 UTC.

    Summary
    Keep open: current main still has a plausible source-level path where compaction-timeout recovery can reuse an assistant-tailed transcript and then hit the existing continuation guard, and there is no merged fix or canonical issue that fully owns this exact 2026.5.26 regression.

    Reproducibility: no. live current-main replay was run, but the source path is clear enough to reproduce with a long session whose compaction retry times out and whose selected snapshot ends in an assistant message. The reporter’s log sequence matches current logging and recovery text.

    Ways to help us reproduce this

    • Add a screenshot or short recording showing the behavior.
    • Add expected vs actual behavior.

    Next step
    A bounded repair looks possible in the compaction-timeout retry and session continuation path, but the worker must first add a focused source-level regression for the reported assistant-tail failure.

    Review details

    Best possible solution:

    Normalize the compaction-timeout recovery path so retries never continue or submit provider prompts from an assistant-tailed snapshot, while preserving already delivered assistant content and avoiding duplicate user-turn persistence.

    Do we have a high-confidence way to reproduce the issue?

    No live current-main replay was run, but the source path is clear enough to reproduce with a long session whose compaction retry times out and whose selected snapshot ends in an assistant message. The reporter’s log sequence matches current logging and recovery text.

    Is this the best way to solve the issue?

    Unclear as an implementation, because no patch is present yet. The maintainable fix should be in the compaction-timeout retry/snapshot boundary or continuation guard, not in provider-specific fallback wording.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • No full anonymized log slice or live replay was available, so the exact failing branch still needs a focused regression harness before landing a fix.

    Codex review notes: model gpt-5.5, reasoning high; reviewed against 5846878924b5.

    Label changes

    Label changes:

    • add P1: The report describes a latest-release regression that repeatedly breaks long-running channel sessions after auto-compaction timeout.
    • add impact:message-loss: The channel receives a recovery failure instead of the expected continued answer after the affected turn.
    • add impact:session-state: The failure is about compaction/retry state selecting or replaying the wrong transcript boundary.
    • add issue-rating: 🐚 platinum hermit: Current issue advisory state selects this label.
    • add clawsweeper:needs-live-repro: Current issue advisory state selects this label.

    Label justifications:

    • P1: The report describes a latest-release regression that repeatedly breaks long-running channel sessions after auto-compaction timeout.
    • impact:session-state: The failure is about compaction/retry state selecting or replaying the wrong transcript boundary.
    • impact:message-loss: The channel receives a recovery failure instead of the expected continued answer after the affected turn.
    Evidence reviewed

    Acceptance criteria:

    • node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run/compaction-timeout.test.ts src/agents/embedded-agent-runner/run.timeout-triggered-compaction.test.ts src/agents/embedded-agent-runner/run.incomplete-turn.test.ts
    • node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run/attempt.test.ts packages/agent-core/src/agent-loop.test.ts

    What I checked:

    Likely related people:

    • Kevin Lin: Blame on the current continuation guard, pre-prompt compaction continuation path, and compaction-timeout snapshot block points to the grafted current implementation commit. (role: current implementation provenance; confidence: medium; commits: bb752c2b4701; files: packages/agent-core/src/agent-loop.ts, src/agents/sessions/agent-session.ts, src/agents/embedded-agent-runner/run/attempt.ts)
    • Alix-007: Recently changed the embedded attempt prompt/runtime-context path in a large agents fix that sits next to the compaction-timeout prompt assembly surface. (role: recent adjacent contributor; confidence: medium; commits: 8b7a4826a1ff; files: src/agents/embedded-agent-runner/run/attempt.ts)
    • Chunyue Wang: Recently touched the embedded attempt timeout-abort path, which is adjacent to the compaction-timeout recovery sequence reported here. (role: recent timeout-path contributor; confidence: medium; commits: 65fb56513fb2; files: src/agents/embedded-agent-runner/run/attempt.ts)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  2. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.
    impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    on May 28, 2026
  3. self-assigned this
    on May 29, 2026
  4. locked as resolved and limited conversation to collaborators on Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions