Skip to content

Fix #1128: strip CLAUDE_CODE_EFFORT_LEVEL from the nested claude -p environment - #1130

Merged
fdaviddpt merged 2 commits into
mainfrom
fix/1128
Nov 13, 2026
Merged

fdaviddpt merged 2 commits into
mainfrom
fix/1128

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

Closes #1128.

The summarizer's nested claude -p inherited CLAUDE_CODE_EFFORT_LEVEL from the parent session's environment. At max effort the small save calls still finished but cost roughly 5x the output tokens, and the two larger calls (NDC compression, staging consolidation) never finished inside their 180s timeouts -- so now.md stopped rotating, grew past session_start_max_bytes, and SessionStart stopped injecting it.

_without_session_env() in pipeline/summarizer.py now pops/restores CLAUDE_CODE_EFFORT_LEVEL the same way it already pops/restores the other ten Claude Code session variables stripped before the single nested claude -p spawn site (call_haiku/_run, which save, NDC compression and staging consolidation all route through). CLAUDE_EFFORT is deliberately NOT stripped -- the issue reporter measured that unsetting only CLAUDE_CODE_EFFORT_LEVEL fixed the timeouts, and CLAUDE_EFFORT is not a Claude Code session variable the child would otherwise look like a resumable part of.

tests/test_summarizer_env_898.py gained CLAUDE_CODE_EFFORT_LEVEL in its EXPECTED_SESSION_NAMES tuple, which several existing AST-based and behavioral tests already iterate over -- this alone turned 5 existing tests red before the fix and green after -- plus one new explicit test with a positive control (asserts CLAUDE_EFFORT survives in the child's env while CLAUDE_CODE_EFFORT_LEVEL does not, and that the parent's own environment is restored afterward).

A second commit fixes two stale-prose findings a spawned reviewer caught on the diff: docs/configuration.md's enumeration of the ten stripped variables (now eleven, with a sentence on why CLAUDE_EFFORT is not also listed), and the test file's module comment claiming the tuple matches round 16's shipped list verbatim (now notes the #1128 addition and its different provenance).

Test evidence

RED (before the pipeline/summarizer.py fix, only the test-tuple edit applied): python3 -m pytest tests/test_summarizer_env_898.py -q -> 5 failed, 45 passed.

GREEN (after the fix): same command -> 50 passed, then 51 passed once the dedicated positive-control test was added. The one non-zero exit code seen on these runs is the repo's own coverage-threshold gate on a single-file targeted subset (fail-under=80) -- expected and unrelated to this change.

Also ran clean: tests/test_haiku.py, tests/test_literal_env_reads_898.py (the repo-wide AST scanner for non-literal env-var names), tests/test_arith_base_lint_332.py, tests/test_pep604_floor_guard.py.

Full pytest (the repository's whole test_command) was deliberately not run locally -- targeted only; CI is the full-suite gate across 3 OSes and 4 interpreters.

Review

Two spawns reviewed the fix commit: oss:auditor (classes A/B/C plus platform, all clean) and Explore (2 findings, both fixed in the follow-up commit, described above). No correctness issues found in the pop/restore logic itself; the Codex child-env route was confirmed never to have carried this variable, so the fix's single-spawn-site scope matches the bug.

Docs

README.md (this repo's configured docs target) never documented the env-stripping mechanism, so nothing in it needed updating. docs/configuration.md, which does document it in detail, was updated in the second commit even though it isn't in the configured docs_targets, because it was stale on the diff itself.

Not implemented here, flagged as an optional follow-up the issue itself marks as a "could also": having the repo's doctor command warn when CLAUDE_CODE_EFFORT_LEVEL is set in the environment the summarizer will inherit.

[AI-generated]

fdaviddpt and others added 2 commits November 13, 2026 22:59
…nvironment

The summarizer's nested `claude -p` call (save, NDC compression, staging
consolidation all route through the one `call_haiku`/`_run` spawn site)
inherited CLAUDE_CODE_EFFORT_LEVEL from the parent process. A parent session
that pins it to "max" -- the only way to keep max effort across sessions,
since the effortLevel setting stops at xhigh -- sent Haiku into max-effort
thinking on a summarization task: small saves still finished but at roughly
five times the output tokens, and NDC/consolidation never finished inside
their 180s timeout at all, so now.md stopped rotating and SessionStart
silently stopped injecting it.

CLAUDE_CODE_EFFORT_LEVEL is now popped and restored in _without_session_env,
the same literal-name pop/restore mechanism already used for the ten other
Claude Code session variables the nested call must not inherit, and the
existing EXPECTED_SESSION_NAMES-driven tests (including the per-name
parametrized removal test and its positive "an arbitrary variable survives"
control) now exercise it automatically through the real call_haiku() path.
CLAUDE_EFFORT is deliberately left alone, with a dedicated test pinning it:
the reporter measured that unsetting only CLAUDE_CODE_EFFORT_LEVEL fixed the
timeouts, and CLAUDE_EFFORT is not a Claude Code session variable the child
would otherwise look like a resumable part of.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…_CODE_EFFORT_LEVEL

docs/configuration.md's "put back afterwards" enumeration and the
EXPECTED_SESSION_NAMES provenance comment both named the list of Claude Code
session variables the nested claude -p strips, by literal name and by
history, and neither mentioned the eleventh entry the previous commit added.
Self-review (Explore) caught both as stale prose adjacent to the diff;
fixed rather than filed, since both are one sentence of blast radius in the
same two files the fix already touched.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@fdaviddpt
fdaviddpt merged commit 699718f into main Nov 13, 2026
19 checks passed
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.

Nested claude -p inherits CLAUDE_CODE_EFFORT_LEVEL: at max, NDC and consolidation never finish inside their timeouts

1 participant