Skip to content

Route Codex sessions to codex exec instead of billing Anthropic, and name which provider a SKIP came from - #462

Merged
fdaviddpt merged 2 commits into
mainfrom
fix/460
Aug 29, 2026
Merged

fdaviddpt merged 2 commits into
mainfrom
fix/460

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

Summary

Closes #460, closes #461.

  • A Codex session summarizes by shelling claude -p, so it needs an authenticated Claude CLI and bills Anthropic #460: a Codex session's memory save shelled claude -p unconditionally, requiring an authenticated Claude CLI and billing Anthropic to remember a session run entirely inside a different agent CLI, having asked for neither. pipeline/haiku.py now detects the hosting CLI (pipeline.host.detect_host(), already built for Read cwd and transcript_path from hook stdin instead of deriving them #407/extract.py cannot read a Codex rollout transcript, so a Codex session silently saves zero memory #443) and routes a detected Codex host through codex exec --sandbox read-only --ignore-user-config instead -- verified directly that --ignore-user-config is Codex's own equivalent of the Claude path's --setting-sources '' hook isolation (Hook-blocked prompt is stored as the consolidation result, corrupting recent.md recursively #202): without it, this plugin's own Codex hooks fire inside the nested call (hook: SessionStart / hook: UserPromptSubmit lines observed in real codex exec output); with it, they do not, and auth via CODEX_HOME is unaffected. Every other host -- Claude Code, an unrecognised host, no signature at all -- keeps exactly the behaviour it had before this change (regression-pinned in tests/test_summarizer_routing_460.py).

    REMEMBER_SUMMARIZER (claude/codex/auto, default auto) lets an operator override the detected default either way -- a Codex user may legitimately want Claude for summaries, and this makes that possible without making it unconditional. REMEMBER_SUMMARIZER_FALLBACK=claude is the explicit opt-in for what happens when the codex route cannot produce a result (binary missing, non-zero exit, timeout, empty output): unset, that raises loudly ("could not summarize") rather than silently falling back to claude -p, which would reproduce this issue's own billing complaint one layer down.

  • No Codex session has ever been observed writing a memory file: four probes, four SKIPs, cause unestablished #461: four real Codex probe sessions all returned a plain SKIP with no further detail, and it was unclear whether that was ordinary model judgment or a Codex-specific defect. Ran a real, non-mocked control experiment: identical thin (decision-only) content SKIPs via BOTH claude -p and the new codex exec route; identical richer (genuinely substantive) content SAVES via both, in the exact entry format the pipeline validates. This rules out a host-shaped cause -- the judgment threshold was never Codex-specific and is UNCHANGED by this PR. What changed is that pipeline/types.HaikuResult gained a provider field, threaded through pipeline/shell.py's emitted PROVIDER= var and into scripts/save-session.sh's SKIP/REJECTED/appended log lines, so a future "was this host-shaped?" question is answerable directly from .remember/logs/memory-*.log instead of needing this investigation repeated.

    The real codex exec run for the richer probe produced an actual saved-shaped entry (## 14:05 | fix/460 followed by Updated pipeline/haiku.py to use isolated codex exec...), which is the first observed instance of a Codex-native route producing a save-worthy result end to end.

Self-review

Two spawned reviewers (Explore, oss:auditor) ran against the initial commit. 3 findings from Explore (a misleading Anthropic-billing warning reused on a codex timeout; two stale docstrings) were all fixed in a follow-up commit. 1 finding from oss:auditor -- whether _is_cli_notice's Claude-specific hook-block regex would also catch a Codex hook-block notice, if --ignore-user-config were ever silently ignored by a future codex-cli -- is below-bar for a fix in this PR (needs a live blocking Codex hook to verify the exact wording, which this session did not reproduce) and is recorded for filing in the developer report.

Not in this PR

Test plan

  • New tests watched red against pre-fix code, green against the fix (tests/test_summarizer_routing_460.py, tests/test_provider_logging_461.py)
  • Full suite: 1864 passed, 43 skipped
  • Changelog fragments validated (.oss/assemble_changelog.py --check)
  • Real, non-mocked claude -p and codex exec invocations for the control experiment (see the developer report / session note)

🤖 Generated with Claude Code

fdaviddpt and others added 2 commits August 29, 2026 13:00
…460), and name which provider a SKIP came from (#461)

pipeline/haiku.py now detects the hosting CLI (pipeline.host.detect_host)
and routes a detected Codex session's summarization through `codex exec`
--sandbox read-only --ignore-user-config (the #202 hook-isolation
equivalent, verified this plugin's own Codex hooks otherwise fire inside
the nested call) instead of unconditionally shelling `claude -p`. Claude
Code and every other host keep exactly the behaviour they had.
REMEMBER_SUMMARIZER overrides the detected default either way;
REMEMBER_SUMMARIZER_FALLBACK=claude is the explicit opt-in for a codex
route that cannot produce a result -- unset, that raises loudly rather
than silently reproducing the billing complaint one layer down.

A control experiment (identical content through both routes) ruled out
a host-shaped cause for #461's four-for-four SKIP: the judgment
threshold is unchanged and was never Codex-specific. What changed is
that a SKIP/REJECTED/appended log line now names which provider
produced it, so this investigation does not need repeating.

Co-Authored-By: Claude Sonnet 5 (1M context) <[email protected]>
…-timeout warning

Three findings from the spawned Explore reviewer on the #460/#461 commit,
all fixed:

- `_call_codex`'s TimeoutExpired handler reused `_log_failed_spend`, the
  Anthropic-billing accounting helper written for the claude -p path. It
  always found no usage block in codex's stdout and warned about an
  unaccounted Anthropic cost for a call this same function documents
  elsewhere as never billed to Anthropic -- self-contradictory. Replaced
  with a plain warning that names codex's own (untracked) usage instead.
- `call_haiku()`'s docstring still claimed it unconditionally spawns
  `claude`, unchanged since before the provider dispatch was added at the
  top of the same function.
- `pipeline/host.py`'s module docstring said the summarizer "gets
  extracted from two real providers or not at all" as the reason no
  abstraction lived there -- #460 added exactly that second provider, so
  the docstring now explains why the bar was met and an abstraction still
  was not added (different auth models / output shapes per provider).

The oss:auditor's one finding (whether `_is_cli_notice`'s Claude-specific
hook-block regex would also catch a Codex hook block, if `--ignore-user-
config` were ever silently ignored by a future codex-cli) is reported in
this lane's report as report-for-filing rather than fixed here: verifying
the exact wording of Codex's own hook-block notice needs a live blocking
Codex hook, which this session did not reproduce.

Co-Authored-By: Claude Sonnet 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant