Skip to content

engine: compaction summarizer can newly hit the anthropic enable-direction thinking hazard #127

Description

@andybons

Found during PR #125's review (issue #124 fix: the compaction summarizer inherits the session's current effort level via `Session.Effort()` — see `runCompactionSummary`, `engine/compact.go`).

AGENTS.md's "Reasoning effort" section documents a known limitation: turning thinking ON over a prior assistant turn whose `tool_use` lacks a thinking block can be rejected by the anthropic API ("thinking blocks expected before tool_use"). A live probe (2026-08-11) tolerated it, so this was previously theoretical rather than confirmed-reachable.

`runCompactionSummary` sends the folded range's real history messages verbatim, which can include assistant messages carrying `ToolCall` parts from turns that ran at unset/off effort (so anthropic emitted no thinking block on them). A session that later raises its effort level to a non-off value before its next auto-compaction now transcodes those exact historical messages with thinking enabled — a new, concrete way to reach the documented hazard, specifically at the overflow-prevention layer whose own failure runs to a hard context overflow that clears (never parks) an active goal.

Suggested action: confirm via a live probe whether this specific shape (folded ToolCall-bearing history + newly-enabled thinking) is rejected or tolerated, and either document it as an accepted residual in `runCompactionSummary`'s AGENTS.md coverage or add a guard.

See the round-1 review on PR #125 for the full analysis.

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