Repository navigation
fix(session): bind handoff/current to the active Codex session - #180
Merged
Merged
Conversation
`anvil session handoff`/`current` resolved the session id solely from CLAUDE_CODE_SESSION_ID, erroring under Codex (which exports no such env var, openai/codex#8923) and making cross-session context handoff impossible. resolveCurrentSession now falls back to the active Codex session, read from the newest rollout file under $CODEX_HOME/sessions (default ~/.codex/sessions); the rollout filename's trailing id is the binding key. Since Codex has no SessionStart hook to pre-create the session file, the first handoff creates it lazily (source=codex). The CLAUDE_CODE_SESSION_ID path stays first and unchanged. Extracts writeSessionFile (shared by create + handoff lazy-create) and adds "codex" to the session source enum. Closes anvil.0037. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
… source enum - handing-off-session SKILL.md: document the Codex session-binding fallback (newest $CODEX_HOME rollout + lazy file creation) so an agent under Codex knows handoff is supported. - vault-schemas.md: add `codex` to the session source enum reference, matching schemas/session.schema.json and validSessionSources. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Owner
Author
|
Addressed 3 findings from independent review (report ac968cb485cab1364) as of 0ad828f: 2 fixes, 1 skip-with-reason.
|
…gth gate) The Codex-binding additions pushed session.go past the CI 500-line cap for non-test Go files. Move the cohesive session-id resolution unit (envSessionID, resolveCurrentSession, codexSessionID, codexRolloutID) into session_resolve.go in the same package. No behaviour change. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
When $CODEX_HOME/sessions holds rollout-*.jsonl files but none match the expected rollout-<YYYY-MM-DDThh-mm-ss>-<id>.jsonl shape, say so and name the shape — rather than reporting the generic "no active session" miss. This makes a future Codex naming-format change diagnosable instead of silent. The no-rollout-at-all path keeps its own message. Co-Authored-By: Claude Opus 4.8 (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
anvil session handoffandanvil session currentresolved "the current session" solely fromCLAUDE_CODE_SESSION_ID(resolveCurrentSession), erroring under Codex — which exports no session-id env var (openai/codex#8923) and has noSessionStarthook to pre-create the session file. The result: context could not be carried across Codex sessions.This makes the write side work under Codex (
resume/listalready worked — they mtime-scan10-sessions/):resolveCurrentSessionfalls back to the active Codex session whenCLAUDE_CODE_SESSION_IDis unset, reading the newest rollout transcript under$CODEX_HOME/sessions(default~/.codex/sessions). The rollout filename's trailing id (after the fixed timestamp prefix) is the binding key — no JSONL parsing, agnostic to the id's internal shape.session handofflazily creates the session file (source=codex) on first call, since Codex has no SessionStart hook to do it.CLAUDE_CODE_SESSION_IDpath stays first and unchanged;sourcenow flows out ofresolveCurrentSessionso each CLI gets the right missing-file behaviour.Refactor: extracts
writeSessionFile(shared bysession createand the handoff lazy-create) +shortID; addscodexto the sessionsourceenum.Scope / non-goals
Newest-rollout-wins mirrors the existing single-active-session assumption (no concurrent-Codex-session disambiguation). No Codex SessionStart-equivalent hook (none exists; lazy-create covers it). Closes the milestone AC "the Codex session-binding gap is resolved."
Verification
go test ./internal/cli/ -run TestSessionCodexBinding—currentresolves the rollout id;handofflazily creates the file withsource=codexand the written body.$CODEX_HOMErollout +env -u CLAUDE_CODE_SESSION_ID ./bin/anvil session handoffcreates10-sessions/<id>.md,session currentresolves the id, andsession resume --jsonreads the handoff back. Full suite 907 green; lint clean.Closes anvil.0037.
🤖 Generated with Claude Code