Skip to content

Use Claude Code, Codex, VSCode, Pi, and OpenCode (and 6 other harnesses) for free (1.3B+ free tokens) from your terminal, app, IDE, or phone, and now from the browser with native browser sessions (multi-harness + multi-model) like OpenClaw (voice supported + ToS friendly)

Python

Isolate nested Codex launches from parent task context (#1055)

Ali Khokharb323b45434df
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md
index fce6dadb..4569a5ee 100644
--- a/ARCHITECTURE.md
+++ b/ARCHITECTURE.md
@@ -767,6 +767,8 @@ keeps product policy independent of provider IDs and transport implementation.
`fcc-codex` launcher:
- `fcc-codex` strips official OpenAI and Codex credential variables.
+- It strips parent-only Codex thread, shell, permission, and origin context so
+ each launched client owns an independent runtime identity.
- It creates an ephemeral `fcc` model provider with `wire_api = "responses"` and
a base URL pointing at the local proxy `/v1` path.
- After proxy health succeeds, it fetches `/v1/models`, writes a generated Codex
diff --git a/pyproject.toml b/pyproject.toml
index 7ee7bccb..30571387 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "free-claude-code"
-version = "3.5.2"
+version = "3.5.3"
description = "Middleware between Claude Code CLI (Anthropic API) and NVIDIA NIM"
readme = "README.md"
requires-python = ">=3.14.0"
diff --git a/src/free_claude_code/cli/launchers/codex.py b/src/free_claude_code/cli/launchers/codex.py
index 605ff3df..9914e855 100644
--- a/src/free_claude_code/cli/launchers/codex.py
+++ b/src/free_claude_code/cli/launchers/codex.py
@@ -22,6 +22,7 @@ _CODEX_AUTH_ENV_KEY = "FCC_CODEX_API_KEY"
_DISPLAY_NAME = "Codex CLI"
_DEFAULT_BINARY = "codex"
_INSTALL_HINT = "Install Codex with: npm install -g @openai/codex"
+# Preserve CODEX_HOME: it owns durable user configuration, not parent-task identity.
_STRIPPED_CODEX_ENV_KEYS = frozenset(
{
"OPENAI_API_KEY",
@@ -30,6 +31,10 @@ _STRIPPED_CODEX_ENV_KEYS = frozenset(
"OPENAI_ORG_ID",
"OPENAI_ORGANIZATION",
"CODEX_API_KEY",
+ "CODEX_INTERNAL_ORIGINATOR_OVERRIDE",
+ "CODEX_PERMISSION_PROFILE",
+ "CODEX_SHELL",
+ "CODEX_THREAD_ID",
_CODEX_AUTH_ENV_KEY,
}
)
diff --git a/tests/cli/test_codex_model_catalog.py b/tests/cli/test_codex_model_catalog.py
index e7a31efd..d23eaeb7 100644
--- a/tests/cli/test_codex_model_catalog.py
+++ b/tests/cli/test_codex_model_catalog.py
@@ -1,4 +1,5 @@
import json
+import os
import shutil
import subprocess
from collections.abc import Mapping
@@ -150,6 +151,17 @@ def test_generated_catalog_schema_is_accepted_by_installed_codex(
catalog_path,
build_codex_model_catalog(_models_payload("anthropic/nvidia_nim/test-model")),
)
+ codex_home = tmp_path / "codex-home"
+ codex_home.mkdir()
+ codex_env = os.environ.copy()
+ for key in (
+ "CODEX_THREAD_ID",
+ "CODEX_INTERNAL_ORIGINATOR_OVERRIDE",
+ "CODEX_SHELL",
+ "CODEX_PERMISSION_PROFILE",
+ ):
+ codex_env.pop(key, None)
+ codex_env["CODEX_HOME"] = str(codex_home)
result = subprocess.run(
[
@@ -161,6 +173,9 @@ def test_generated_catalog_schema_is_accepted_by_installed_codex(
],
capture_output=True,
check=False,
+ encoding="utf-8",
+ env=codex_env,
+ errors="replace",
text=True,
timeout=10,
)
diff --git a/tests/cli/test_entrypoints.py b/tests/cli/test_entrypoints.py
index 6aa502fe..50ef3d6f 100644
--- a/tests/cli/test_entrypoints.py
+++ b/tests/cli/test_entrypoints.py
@@ -493,6 +493,10 @@ def test_launch_codex_passes_responses_config_and_child_env(
monkeypatch.setenv("OPENAI_API_KEY", "official-key")
monkeypatch.setenv("OPENAI_BASE_URL", "https://api.openai.com/v1")
monkeypatch.setenv("CODEX_HOME", "keep-home")
+ monkeypatch.setenv("CODEX_INTERNAL_ORIGINATOR_OVERRIDE", "Codex Desktop")
+ monkeypatch.setenv("CODEX_PERMISSION_PROFILE", "danger-full-access")
+ monkeypatch.setenv("CODEX_SHELL", "1")
+ monkeypatch.setenv("CODEX_THREAD_ID", "parent-thread")
settings = _launcher_settings(port=9191, token="proxy-token")
catalog_path = tmp_path / "codex-model-catalog.json"
requests: list[Request] = []
@@ -565,6 +569,10 @@ def test_launch_codex_passes_responses_config_and_child_env(
child_env = popen.call_args.kwargs["env"]
assert child_env["FCC_CODEX_API_KEY"] == "proxy-token"
assert child_env["CODEX_HOME"] == "keep-home"
+ assert "CODEX_INTERNAL_ORIGINATOR_OVERRIDE" not in child_env
+ assert "CODEX_PERMISSION_PROFILE" not in child_env
+ assert "CODEX_SHELL" not in child_env
+ assert "CODEX_THREAD_ID" not in child_env
assert "OPENAI_API_KEY" not in child_env
assert "OPENAI_BASE_URL" not in child_env
register_pid.assert_called_once_with(12345)
diff --git a/uv.lock b/uv.lock
index 8ded56af..e275384b 100644
--- a/uv.lock
+++ b/uv.lock
@@ -561,7 +561,7 @@ wheels = [
[[package]]
name = "free-claude-code"
-version = "3.5.2"
+version = "3.5.3"
source = { editable = "." }
dependencies = [
{ name = "aiohttp" },