Skip to content

apply the compaction effort cap to requests naming no effort - #151

Merged
raine merged 3 commits into
raine:mainfrom
rikbrown:rik/effort-cap
Sep 14, 2026
Merged

raine merged 3 commits into
raine:mainfrom
rikbrown:rik/effort-cap

Conversation

@rikbrown

Copy link
Copy Markdown
Contributor

Problem

src/providers/codex/translate/request.rs:

if apply_codex_config
    && is_compact
    && let Some(cap) = compact_effort_cap()
    && resolved_effort.as_ref().is_some_and(|e| *e > cap)
{
    resolved_effort = Some(cap);
}

is_some_and means the cap only ever lowers an effort that is already present. A compaction request naming no effort at all skips the cap entirely and runs at the upstream default — which is the effort level the cap exists to avoid.

That is also the case it is most needed for: Claude Code's own /compact request carries no effort of its own, so the fast path never applied to it.

Fix

apply_compact_effort_cap resolves the two inputs together:

resolved effort cap result
none Low Low
None Low None (explicit, below cap)
Low Low Low
High Low Low (lowered)
anything cap off unchanged

The existing invariant holds: the cap never raises effort, and an explicitly lower effort is preserved. The doc comment on compact_effort_cap is updated to state that a missing effort now takes the cap too.

Verification

  • New test compact_effort_cap_defaults_a_missing_effort covers every row above
  • Existing compact_request_downgrades_effort_to_cap and compact_effort_cap_parses_env_values unchanged and passing
  • cargo clippy --all-targets -- -D warnings clean, cargo fmt --check clean, full suite green

🤖 Generated with Claude Code

rikbrown and others added 3 commits September 13, 2026 16:02
The cap only lowered an effort that was already present: the guard read
`resolved_effort.as_ref().is_some_and(|e| *e > cap)`, so a compaction
request that named no effort at all skipped the cap and ran at the
upstream default. That default is the effort level the cap exists to
avoid, which is the case it was most needed for — Claude Code's own
/compact request carries no effort of its own.

`apply_compact_effort_cap` now resolves the two inputs together: a
missing effort takes the cap, an explicit effort at or below it is
preserved, anything above it is lowered, and a disabled cap leaves the
request exactly as it asked.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Compaction requests that name no effort now take the configured cap,
but `Effort::None` was still treated as reasoning enabled. A request
that resolved to `none` carried `reasoning.summary: "auto"` and
`include: ["reasoning.encrypted_content"]`, contradicting the
documented behavior that compact `none` removes reasoning and asking
upstream for a summary and encrypted continuation content it cannot
use.

Keep naming `effort: "none"` on the wire so the request still
overrides the upstream default, and gate the summary and encrypted
content on an effort other than `none`. This also stops a proxy-wide
`none` override from requesting reasoning artifacts, since it flows
through the same resolved effort.

Add full-translation regression tests for omitted-effort compact
requests under the default low cap, `none`, `off`, and effort override
precedence. The tests isolate the process environment through the
existing lock and guard pattern so they can mutate `CCP_COMPACT_EFFORT`
and `CCP_CODEX_EFFORT` safely.

PR: raine#151
Bring the branch onto current main (d27df1d)
so the combined tree carries the certificate-root handling and codex
transport test isolation from raine#143 alongside the compaction effort cap
and its reasoning-none correction.

The original PR head and the correction commit remain ancestors, so the
contributor branch still fast-forwards.
@raine
raine merged commit e7eed88 into raine:main Sep 14, 2026
2 checks passed
@raine

raine commented Sep 14, 2026

Copy link
Copy Markdown
Owner

Thanks for catching the missing-effort case! Merged.

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