Skip to content

sdk: launch packaged Codex runtimes#23786

Merged
bolinfest merged 1 commit into
mainfrom
pr23786
May 21, 2026
Merged

sdk: launch packaged Codex runtimes#23786
bolinfest merged 1 commit into
mainfrom
pr23786

Conversation

@bolinfest
Copy link
Copy Markdown
Collaborator

@bolinfest bolinfest commented May 21, 2026

Why

The Python and TypeScript SDKs launch the native Codex runtime directly, so they need to consume the same package artifact shape that release jobs now produce. The runtime wheel should be built from the canonical Codex package archive rather than reconstructing a parallel layout from loose binaries.

What Changed

  • Stage openai-codex-cli-bin by extracting codex-package-<target>.tar.gz into src/codex_cli_bin and validating the expected package layout.
  • Update release workflows to pass the generated package archive into stage-runtime instead of the temporary package directory.
  • Update Python runtime setup to download codex-package-*.tar.gz release assets directly.
  • Expose Python runtime helpers for the bundled package directory and codex-path, and prepend that path when openai_codex launches the installed runtime without duplicating Windows Path/PATH keys.
  • Teach the TypeScript SDK to resolve package-layout optional dependencies while keeping the existing npm fallback layout, and preserve the existing Windows path variable casing when prepending codex-path.

Test Plan

  • python3 -m py_compile sdk/python/scripts/update_sdk_artifacts.py sdk/python/_runtime_setup.py sdk/python/src/openai_codex/client.py sdk/python-runtime/src/codex_cli_bin/__init__.py
  • uv run --frozen --project sdk/python --extra dev ruff check sdk/python/scripts/update_sdk_artifacts.py sdk/python/_runtime_setup.py sdk/python/src/openai_codex/client.py sdk/python/tests/test_artifact_workflow_and_binaries.py sdk/python-runtime/src/codex_cli_bin/__init__.py
  • uv run --frozen --project sdk/python --extra dev pytest sdk/python/tests/test_artifact_workflow_and_binaries.py
  • pnpm eslint src/exec.ts tests/exec.test.ts
  • pnpm test --runInBand tests/exec.test.ts

Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e8ef8bb5a2

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sdk/typescript/src/exec.ts Outdated
env.CODEX_API_KEY = args.apiKey;
}
if (this.pathDirs.length > 0) {
env.PATH = prependPathDirs(env.PATH, this.pathDirs);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Badge Preserve Windows Path when prepending package PATH entries

When pathDirs is present this unconditionally writes env.PATH, but on Windows the inherited key is often Path (different casing). That creates both PATH and Path in the env object; Node's child_process passes only the first case-insensitive match, so the newly written PATH can win and drop the original system search path. In that case child Codex processes run with a truncated PATH (often just codex-path), which can break command/tool discovery at runtime on Windows.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Addressed in the latest push. prependPathDirs() now preserves the existing Windows Path key and removes duplicate case-insensitive PATH keys before prepending codex-path; covered by a new TypeScript test.

Comment thread sdk/python/src/openai_codex/client.py Outdated
Comment on lines +119 to +124
existing_path = env.get("PATH", "")
path_dir_values = [str(path_dir) for path_dir in path_dirs]
existing_entries = [
entry for entry in existing_path.split(path_sep) if entry and entry not in path_dir_values
]
env["PATH"] = path_sep.join([*path_dir_values, *existing_entries])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Update existing Windows Path key instead of forcing PATH

This helper always reads/writes the uppercase PATH key, which can create duplicate case-insensitive path variables (Path + PATH) in the subprocess environment on Windows when callers provide config.env with Path. Python's Windows subprocess environment handling is sensitive to duplicate keys, so the child may receive an unexpected path value and lose entries the caller intended to preserve.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Addressed in the latest push. _prepend_path_dirs() now preserves an existing Windows Path key, removes duplicate case-insensitive PATH keys, and prepends codex-path to that preserved key; covered by a new Python test.

## Why

The Python and TypeScript SDKs launch the native Codex runtime directly, so they need to consume the same package artifact shape that release jobs now produce. The runtime wheel should be built from the canonical Codex package archive rather than reconstructing a parallel layout from loose binaries.

## What Changed

- Stage `openai-codex-cli-bin` by extracting `codex-package-<target>.tar.gz` into `src/codex_cli_bin` and validating the expected package layout.
- Update release workflows to pass the generated package archive into `stage-runtime` instead of the temporary package directory.
- Update Python runtime setup to download `codex-package-*.tar.gz` release assets directly.
- Expose Python runtime helpers for the bundled package directory and `codex-path`, and prepend that path when `openai_codex` launches the installed runtime without duplicating Windows `Path`/`PATH` keys.
- Teach the TypeScript SDK to resolve package-layout optional dependencies while keeping the existing npm fallback layout, and preserve the existing Windows path variable casing when prepending `codex-path`.

## Test Plan

- `python3 -m py_compile sdk/python/scripts/update_sdk_artifacts.py sdk/python/_runtime_setup.py sdk/python/src/openai_codex/client.py sdk/python-runtime/src/codex_cli_bin/__init__.py`
- `uv run --frozen --project sdk/python --extra dev ruff check sdk/python/scripts/update_sdk_artifacts.py sdk/python/_runtime_setup.py sdk/python/src/openai_codex/client.py sdk/python/tests/test_artifact_workflow_and_binaries.py sdk/python-runtime/src/codex_cli_bin/__init__.py`
- `uv run --frozen --project sdk/python --extra dev pytest sdk/python/tests/test_artifact_workflow_and_binaries.py`
- `pnpm eslint src/exec.ts tests/exec.test.ts`
- `pnpm test --runInBand tests/exec.test.ts`
@bolinfest bolinfest merged commit 0b4f860 into main May 21, 2026
46 checks passed
@bolinfest bolinfest deleted the pr23786 branch May 21, 2026 01:01
@github-actions github-actions Bot locked and limited conversation to collaborators May 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants