Skip to content

perf(codex): cap reasoning effort on compaction requests - #67

Merged
raine merged 1 commit into
raine:mainfrom
kevinsslin:upstream/perf-compact-effort-cap
Jul 20, 2026
Merged

perf(codex): cap reasoning effort on compaction requests#67
raine merged 1 commit into
raine:mainfrom
kevinsslin:upstream/perf-compact-effort-cap

Conversation

@kevinsslin

Copy link
Copy Markdown
Contributor

Problem

Claude Code's /compact (and auto-compact) sends the entire context window through the normal /v1/messages path. When the session runs a reasoning model with effort enabled, the summarization request inherits that effort, so the model burns a large hidden reasoning pass before writing the summary. On a near-full context this reasoning dominates compaction latency, and it buys nothing: summarization is extraction, not problem solving, and native Claude Code compacts without extended thinking at all.

Change

  • Detect compaction requests by the stable marker Claude Code puts in the system prompt of every compaction request (both manual /compact and auto-compact): "You are a helpful AI assistant tasked with summarizing conversations".
  • Cap the resolved reasoning effort at low for those requests. The cap only ever lowers effort; a request already at or below it is untouched.
  • CCP_COMPACT_EFFORT overrides the cap (none|low|medium|high|xhigh|max), and off disables the fast path entirely.

Verification

  • 7 new unit tests: marker detection, env parsing, downgrade, never-raise, non-compact untouched, effort ordering.
  • Live check against Codex upstream: a reasoning-heavy prompt at effort: high completed in 2.9s / 38 output tokens with the compact marker vs 5.3s / 95 output tokens without it (reasoning suppressed as intended). effort: none is accepted by the upstream for gpt-5.6 class models.
  • cargo test fully green, cargo fmt --check clean, no new clippy warnings.

Claude Code's /compact and auto-compact send the full context window
through the normal messages path, so a reasoning model burns medium or
high effort thinking about a summary that native Claude Code produces
without extended thinking at all. On a 200k-token context that hidden
reasoning dominates compaction latency.

Detect compaction by the stable marker Claude Code puts in the system
prompt of every compaction request and cap reasoning effort at low.
The cap only ever lowers effort, and CCP_COMPACT_EFFORT overrides it
(none|low|medium|high|xhigh|max, or off to disable the fast path).
@raine
raine merged commit 80acd81 into raine:main Jul 20, 2026
@raine

raine commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Thank you

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