Repository navigation
Conversation
…dex (#463, #459) #460's Codex routing keyed detect_host() to CODEX_HOME/PLUGIN_ROOT, neither of which Codex ever exports to a child process -- CODEX_HOME is a config path it reads, not a signature. detect_host() now keys on CODEX_SESSION_ID/CODEX_THREAD_ID, pinned against a fixture captured from a live codex exec session rather than one a test could construct to agree with itself. Nested Codex-inside-Claude-Code (both signatures present at once) keeps registry precedence, argued in the REGISTRY comment in pipeline/host.py. scripts/post-tool-hook.sh's per-tool-call save path derived a session directory by slugging PROJECT_DIR under ~/.claude/projects/ -- Claude Code's own layout, never Codex's ~/.codex/sessions/. It now reads transcript_path off the hook's own stdin payload (present on every hook event, every host) and uses it directly when valid, falling back to the historical SESSION_DIR/slug lookup exactly as before when stdin offers nothing usable. Adds three README rows (REMEMBER_SUMMARIZER, REMEMBER_SUMMARIZER_FALLBACK, REMEMBER_CODEX_BIN) that #460 never documented. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This was referenced Aug 29, 2026
fdaviddpt
added a commit
that referenced
this pull request
Aug 29, 2026
…t its environment (#465) (#466) * fix: Codex summarizer routing reads the transcript the host wrote, not its environment (#465) Under REMEMBER_SUMMARIZER=auto, a default-configured Codex session still routed to `claude -p` -- #464's CODEX_SESSION_ID/CODEX_THREAD_ID fixture was captured from a Codex tool shell, not the SessionEnd hook process that actually spawns the summarizer, and a live capture from inside that hook (env dumped, CLAUDE_CODE_* stripped, codex-cli 0.150.1) shows neither variable survives into it. pipeline.haiku._choose_summarizer_provider() now reads REMEMBER_TRANSCRIPT_PATH and sniffs the transcript's own first line (pipeline.extract.sniff_file_envelope(), #443) instead -- what the host wrote, not what it exported. Verified against a live, default- configured `codex exec` session: SessionEnd now logs `provider: codex`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix: address self-review findings on #465 -- stale docstring + unlogged sniff failure Explore (reviewer) found pipeline/host.py's module docstring still described the summarizer as "chosen by detect_host()", directly contradicting the AMBIGUOUS-comment update three commits' worth of prose below it -- both now describe the real #465 mechanism. oss:auditor found _choose_summarizer_provider() silently collapsed "the transcript is genuinely Claude Code" and "the transcript could not be sniffed" (unreadable, deleted mid-race, or an unrecognised shape) into the same unlogged "claude" result -- indistinguishable to an operator debugging a wrongly-billed session. It now warns (via the existing _warn()) only on the "could not sniff" branch, never on the ordinary "no transcript at all" path, with positive/negative tests for both. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
#460 shipped Codex-native summarizer routing, but it was unreachable:
pipeline/host.pykeyed Codex detection onCODEX_HOME/PLUGIN_ROOT, neither of which a realcodex execprocess ever exports to a child (CODEX_HOMEis a configuration path Codex reads, not a signature it exports). Every test in #460's own suite passed because a hand-built test environment set both variables happily -- only a live process could show the defect.Closes #463
detect_host()now keys Codex'ssignature_varsonCODEX_SESSION_ID/CODEX_THREAD_ID, which a real Codex process (codex-cli 0.150.1, verified against a livecodex execrun from inside this worktree) does export. Pinned againsttests/fixtures/codex-env-463.txt, a fixture captured from that live session rather than one constructed in the test -- a constructed fixture would have acceptedCODEX_HOMEjust as readily as the code it replaced.A second, distinct defect from the same investigation: a Codex session launched from inside a Claude Code session (nested agents) carries both hosts' native signatures in its environment at once.
detect_host()keeps registry precedence (Claude Code wins) in that case. TheREGISTRYcomment inpipeline/host.pyargues this at length: there is no ancestry marker in flat environment variables, so "prefer the innermost host" cannot be implemented honestly -- it would guess a direction, and would guess wrong for the (rarer, but real) reverse nesting of Claude Code launched inside a Codex sandbox. A thirdAMBIGUOUShost state was considered and rejected:detect_host()has exactly one consumer, and that consumer's own contract is already binary (codexvs. everything else isclaude), soAMBIGUOUSwould collapse into the same branch asUNKNOWNwith no behavioural difference -- a label nothing reads.Closes #459
Separately:
scripts/post-tool-hook.sh's per-tool-call save path derived a session directory by sluggingPROJECT_DIRunder~/.claude/projects/-- Claude Code's own transcript layout. Codex writes to~/.codex/sessions/<yyyy>/<mm>/<dd>/rollout-*.jsonlinstead, so the slug never matched and every Codex tool call logged a loud, correctWARNING: no session dirwhose suggested remedy (make a directory under~/.claude/projects/) was advice for the wrong host. The hook now readstranscript_pathoff its own stdin payload -- present on every hook event, on every host, the same fieldsession-start-hook.sh/session-end-hook.shalready trust (#407/#424) -- and uses it directly when it names a real file, falling back to the exact priorSESSION_DIR/slug behaviour when stdin offers nothing usable (an older CLI, a test harness, an unrecognised host).Also adds three
README.mdrows (REMEMBER_SUMMARIZER,REMEMBER_SUMMARIZER_FALLBACK,REMEMBER_CODEX_BIN) that #460 shipped without documenting.A reviewer finding, argued down
A spawned reviewer flagged that the Claude-Code-wins tie-break above means a Codex-nested-in-Claude-Code session resolves
REMEMBER_SUMMARIZER=autotoclaude, notcodex-- reproducing the shape of #460's original complaint in that one nested scenario, and possibly failing outright in a network-disabled Codex sandbox. This is real and is the exact edge case theREGISTRYcomment above already discusses and decides: BELOW-BAR, not fixed here. The reviewer's own proposed fix (prefer Codex on tie) is not strictly better -- it fails the reverse nesting direction (Claude Code launched inside a Codex sandbox) the same way, for the same underlying reason: flat environment variables carry no ancestry information, so any fixed tie-break direction is wrong for one of the two nesting orders. Solving this in general needs a real ancestry signal neither host publishes, which is a bigger and separately-scoped fix than this issue asked for. Filed as an open question, not a bug this diff introduces.Test plan
tests/test_codex_signature_463.py(new):detect_host()against a captured real Codex environment;CODEX_HOME/PLUGIN_ROOTalone no longer signal Codex (must-not-fire pair); the nested-signature tie-break is pinned.tests/test_codex_transcript_path_459.py(new): a Codex-shapedPostToolUsepayload with a transcript outside~/.claude/projects/is captured; theno session dirWARNING is absent in that case; an unusabletranscript_pathdegrades to the historicalSESSION_DIR/slug lookup rather than disabling capture.tests/test_summarizer_routing_460.pyupdated (CODEX_HOMEsetenv swapped forCODEX_SESSION_ID, the only valid signature now) and still green.tests/test_non_ascii_paths.py,tests/test_claude_config_dir.py,tests/test_post_tool_session_id.py) unchanged and green.python3 .oss/assemble_changelog.py --checkpasses.