Skip to content

fix(codex): look up session files under CODEX_HOME - #364

Merged
zpzjzj merged 1 commit into
alibaba:mainfrom
karanb192:fix/codex-home-session-lookup
Nov 3, 2026
Merged

zpzjzj merged 1 commit into
alibaba:mainfrom
karanb192:fix/codex-home-session-lookup

Conversation

@karanb192

Copy link
Copy Markdown
Contributor

Summary

Codex writes its session files under $CODEX_HOME, which defaults to $HOME/.codex. skill-up always looked in $HOME/.codex/sessions. A run with CODEX_HOME set, for example through environment.env to keep skill-up's MCP servers out of the user's global Codex config (#360), never found its session file and fell back to the stream transcript.

Related issues

Refs #360. This is the small part. The design for the rest of #360 is proposed on the issue.

Changes

  • internal/agent/codex.go: the lookup script uses $CODEX_HOME/sessions when CODEX_HOME is set, and $HOME/.codex/sessions otherwise. The script moved into a constant so a test can run it.
  • internal/agent/codex_test.go: a test runs the script in sh against temporary folders: without CODEX_HOME it finds the file under HOME, with it it finds the file under CODEX_HOME, and with a CODEX_HOME that has no sessions it finds nothing. Skipped on Windows.
  • CHANGELOG.md: one line under Unreleased, Fixed.

Test plan

  • make test passes
  • make verify: fmt and vet pass. Lint reports 4 staticcheck SA5011 findings in internal/agent/custom_test.go, a file this PR does not touch; on my machine clean main reports the same 4.
  • With the old lookup script in the constant, the new test fails on its CODEX_HOME case; with this change it passes.

Notes for reviewers

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T16:41:24.166755Z 369d637 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@zpzjzj zpzjzj left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CODEX_HOME lookup change looks correct. Checked environment propagation and the default/custom/missing-session cases, including paths containing spaces; CI, Extended CI, and CodeQL are green. Local shell checks passed; full local Go validation was unavailable because this environment has no usable Go toolchain.

Merge sequencing: please merge #361 first (or include its parser fix before merging this PR). #361 is still open: without it, discovering the session under CODEX_HOME can switch selection from the stream to a session transcript that drops code-tool MCP/command calls. Holding queue entry until that dependency is satisfied.

@karanb192

Copy link
Copy Markdown
Contributor Author

Thanks. Agreed on the order. Once #361 is merged I'll rebase this onto main; the conflict is just the CHANGELOG line and one import block.

Codex writes its session files under $CODEX_HOME, which defaults to
$HOME/.codex. The lookup always searched $HOME/.codex/sessions, so a run
with CODEX_HOME set (for example through environment.env, to keep
skill-up's MCP servers out of the user's global Codex config) never found
the session file and fell back to the stream transcript.

Refs alibaba#360
@karanb192
karanb192 force-pushed the fix/codex-home-session-lookup branch from 369d637 to e411034 Compare November 2, 2026 10:07
@zpzjzj
zpzjzj added this pull request to the merge queue Nov 3, 2026
Merged via the queue into alibaba:main with commit f2d726e Nov 3, 2026
14 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.

2 participants