Skip to content

chore(sdk): Codex: client-side initialize handshake, auth.json bootstrap, full-auto launch, send resilience#139

Open
ross-rl wants to merge 10 commits into
feat/codex-examples-docsfrom
feat/codex-init-auth-fixes
Open

chore(sdk): Codex: client-side initialize handshake, auth.json bootstrap, full-auto launch, send resilience#139
ross-rl wants to merge 10 commits into
feat/codex-examples-docsfrom
feat/codex-init-auth-fixes

Conversation

@ross-rl

@ross-rl ross-rl commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Stacked on #-/feat/codex-examples-docs. Fixes found while testing the codex path in the combined-app.

SDK

  • CodexAxonConnection.initialize() — the codex_json broker mount does not perform the app-server handshake, so all requests failed with -32600 "Not initialized". The connection now runs the initialize request + initialized notification itself, mirroring the Claude lifecycle (connect()initialize()), with isInitialized/initializeResponse getters, initializeParams overrides, and tolerance for a server-side "already initialized" rejection (live app-server reattach). Four new tests.

Examples

  • combined-app: fix AskUserQuestion permission responses (empty questions array failed the tool input schema — echo the original input and merge answers); write ~/.codex/auth.json at devbox launch from CODEX_AUTH_JSON (full file contents, ChatGPT-plan auth) or OPENAI_API_KEY (api-key mode), validated server-side; launch codex full-auto by default (-c approval_policy=never -c sandbox_mode=danger-full-access, the app-server equivalent of --dangerously-bypass-approvals-and-sandbox), skipped when interactive approvals are on; re-wire the connection before send if the SSE stream silently died (SDK retries a dropped stream once per connection lifetime), resuming from the last seen sequence; run the handshake once per devbox instead of on every subscribe/rewire.
  • feature-examples: bootstrap api-key-mode auth.json for codex devboxes; run initialize() after connect.

Docs

  • README/AGENTS.md/llms.txt updated for the connect()initialize() flow and the auth.json launch-command pattern.

Known follow-ups

  • The Claude/ACP managers share the silent stream-death issue; the SDK read loop's single-lifetime-retry policy is the root cause and deserves retry-with-backoff.

🤖 Generated with Claude Code

ross-rl and others added 10 commits July 14, 2026 11:03
The answer form replied with an empty questions array, which fails the
tool's input schema (questions requires >=1 items). Echo the model's
original input and merge answers into it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The codex_json broker mount does not perform the app-server initialize
handshake, so requests failed with -32600 "Not initialized". Add
CodexAxonConnection.initialize() (initialize request + initialized
notification) mirroring the Claude connection lifecycle, with
isInitialized/initializeResponse getters and initializeParams overrides.
A server-side already-initialized rejection is treated as success so
reconnecting to a live app-server still works. Docs updated to show the
connect() -> initialize() flow.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codex reads credentials from ~/.codex/auth.json rather than the
OPENAI_API_KEY env var, so codex devboxes now materialize an
api-key-mode auth file at launch (via python3 json.dumps for safe
quoting). Also run the new initialize() handshake after connect.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ends in combined-app

- Write ~/.codex/auth.json from CODEX_AUTH_JSON (full file contents,
  e.g. $(cat ~/.codex/auth.json) for ChatGPT-plan auth) or fall back
  to api-key mode from OPENAI_API_KEY; validated server-side.
- Launch codex app-server full-auto by default (-c approval_policy=never
  -c sandbox_mode=danger-full-access, the app-server equivalent of
  --dangerously-bypass-approvals-and-sandbox), skipped when interactive
  approvals are enabled; client launchArgs pass through.
- Re-wire the connection before send if the SSE stream silently died
  (the SDK retries a dropped stream once per connection lifetime),
  resuming from the last seen sequence to avoid duplicate history.
- Run the initialize handshake once per devbox instead of on every
  subscribe/rewire.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Intercept messages starting with "/" and map them onto app-server
JSON-RPC methods instead of starting a turn: /plan and /default toggle
sticky turn/start overrides (read-only sandbox + on-request approvals
vs. the configured default), /model and /effort set per-turn overrides,
/compact runs thread/compact/start, /review runs review/start
(uncommitted changes or custom instructions), /help lists commands.
Confirmations surface as system_note WS events rendered as system chat
items; unrecognized commands fall through as normal prompts.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
/plan and friends previously only broadcast a transient WS message, so
mode changes were invisible in the axon event log and lost on
resubscribe. Publish app/system_note EXTERNAL_EVENTs instead and render
them from the timeline, which covers live delivery and replay with one
path.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
/plan previously faked plan mode with sandbox/approval overrides. The
current app-server protocol supports it natively: turn/start accepts
collaborationMode { mode: "plan" | "default", settings } (newer than
the vendored protocol types, sent via conn.request). settings requires
a model, so the manager mirrors the thread's live model/effort from
thread/settings/updated notifications, with /model and /effort
overrides taking precedence and developer_instructions: null selecting
the mode's built-in instructions.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
turn/start.collaborationMode is gated behind the experimentalApi
initialize capability (#[experimental] in codex-rs); without the opt-in
the app-server rejects the request. Declare the capability when wiring
the combined-app codex connection.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
/plan depended on a thread/settings/updated notification to learn the
thread's model (required by collaborationMode.settings); when it never
fired the next turn silently went out without plan mode. Resolve the
model eagerly at /plan time (overrides -> live settings -> config/read)
and cache it, warn in-chat if a message ever goes out without the
requested mode, and log outgoing turn/start overrides server-side.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ross-rl ross-rl changed the title Codex: client-side initialize handshake, auth.json bootstrap, full-auto launch, send resilience chore: Codex: client-side initialize handshake, auth.json bootstrap, full-auto launch, send resilience Jul 14, 2026
@ross-rl ross-rl changed the title chore: Codex: client-side initialize handshake, auth.json bootstrap, full-auto launch, send resilience chore(sdk): Codex: client-side initialize handshake, auth.json bootstrap, full-auto launch, send resilience Jul 14, 2026
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.

1 participant