Skip to content

refactor(codex): replace the SDK with a shared App Server runtime - #192

Open
Waishnav wants to merge 6 commits into
perf/subagent-runtime-poolfrom
refactor/codex-app-server-runtime
Open

refactor(codex): replace the SDK with a shared App Server runtime#192
Waishnav wants to merge 6 commits into
perf/subagent-runtime-poolfrom
refactor/codex-app-server-runtime

Conversation

@Waishnav

@Waishnav Waishnav commented Aug 12, 2026

Copy link
Copy Markdown
Owner

DevSpace currently depends on @openai/codex-sdk, which also makes DevSpace own a bundled Codex runtime and still starts Codex work per invocation. This switches the adapter to the user-installed codex app-server, adds a narrow JSONL transport, and lets one compatible App Server runtime host multiple DevSpace Codex threads. Existing thread IDs remain the durable continuation handle, so a discarded App Server can be recreated and resumed.\n\nCODEX_COMMAND can select a specific installation, default resolution avoids DevSpace-owned node_modules/.bin, and the SDK/bundled Codex dependency is removed. DevSpace intentionally does not commit generated App Server bindings; it only owns the small stable protocol surface it needs. Stacked on #191.

Summary by CodeRabbit

  • New Features

    • Codex subagent execution now uses the locally installed Codex CLI and App Server.
    • Existing Codex login, configuration, and CODEX_HOME settings are respected.
    • Supports session resumption, workspace sandbox settings, model selection, reasoning effort, and approval options.
    • Added automatic Codex command detection, with support for overriding it via CODEX_COMMAND.
    • Improved handling of streamed responses and clearer failures when Codex is unavailable.
  • Documentation

    • Updated Codex setup and configuration guidance to reflect CLI-based execution.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 08a865d5-cd51-4b99-aece-2bbaac91b4d2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Codex execution now uses the installed codex app-server CLI through a new JSON-RPC transport and harness runtime. Command resolution, availability checks, runtime pooling, adapter cleanup, tests, package dependencies, and documentation were updated.

Changes

Codex App Server integration

Layer / File(s) Summary
Command resolution and availability
src/local-agent-path.ts, src/local-agent-codex/command.ts, src/local-agent-availability.ts, src/local-agent-availability.test.ts
Codex commands resolve from CODEX_COMMAND or PATH. Availability checks run codex app-server --help and preserve failure reasons.
App Server process transport
src/local-agent-codex/app-server-transport.ts
A stdio JSON-RPC transport manages initialization, requests, notifications, errors, diagnostics, and graceful process shutdown.
Codex runtime and harness driver
src/local-agent-codex/runtime.ts, src/local-agent-codex/runtime.test.ts
The runtime manages threads, turns, notifications, sandbox settings, reasoning effort, response validation, final messages, and cleanup.
Shared runtime integration and documentation
src/local-agent-adapters.ts, src/local-agent-runtime-registry.ts, package.json, docs/agent-profile-schema.md, docs/configuration.md
Adapters and pooled runtime registration use the Codex harness driver. The Codex SDK dependency and old runtime test are removed. Documentation describes CLI configuration and App Server reasoning effort.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Adapter as CodexLocalAgentAdapter
  participant Runtime as CodexAppServerRuntime
  participant Transport as CodexAppServerTransport
  participant CLI as Codex CLI
  Adapter->>Runtime: Run input
  Runtime->>Transport: Start or resume thread
  Transport->>CLI: Send JSON-RPC request
  CLI-->>Transport: Return response and notifications
  Transport-->>Runtime: Deliver turn events
  Runtime-->>Adapter: Return final agent message
Loading

Possibly related PRs

Poem

A rabbit watched the Codex stream,
Through App Server pipes of JSON gleam.
Threads resumed and turns ran bright,
Sandboxes kept their bounds just right.
“No SDK!” it cheered, then hopped from sight.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes replacing the Codex SDK with a shared App Server runtime, which is the main change.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/codex-app-server-runtime

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 12, 2026

Copy link
Copy Markdown

Greptile Summary

Refactors the Codex integration from the bundled SDK to the user's installed Codex CLI and its App Server protocol.

  • Adds a pooled, stdio-based Codex App Server transport and runtime.
  • Resolves and validates the Codex executable using CODEX_COMMAND, PATH, and CODEX_HOME.
  • Preserves thread resumption, sandbox selection, model selection, and reasoning effort.
  • Removes the Codex SDK dependency and updates tests and documentation.

Confidence Score: 5/5

The PR appears safe to merge with no concrete blocking or independently actionable non-blocking issue identified.

The new Codex App Server path consistently resolves the CLI, pools runtime ownership, correlates thread notifications, closes child processes, and preserves the existing input and sandbox contracts.

Important Files Changed

Filename Overview
src/local-agent-codex/app-server-transport.ts Adds JSON-lines RPC transport, process lifecycle management, pending-request handling, and notification dispatch for the Codex App Server.
src/local-agent-codex/runtime.ts Implements pooled Codex thread and turn execution with sandbox mapping, resumption, event correlation, and final-response extraction.
src/local-agent-codex/command.ts Resolves the configured Codex executable and checks whether its App Server command is available.
src/local-agent-runtime-registry.ts Routes Codex runs through the shared harness runtime pool.
src/local-agent-path.ts Adds cross-platform executable resolution using PATH, PATHEXT, and platform-appropriate access checks.
src/local-agent-codex/runtime.test.ts Covers concurrent threads, thread resumption, sandbox modes, model selection, reasoning effort, and early notifications.
package.json Removes the bundled Codex SDK and updates the test command for the App Server runtime tests.

Sequence Diagram

sequenceDiagram
    participant Manager as LocalAgentManager
    participant Registry as RuntimeRegistry
    participant Pool as HarnessRuntimePool
    participant Runtime as CodexAppServerRuntime
    participant CLI as codex app-server
    Manager->>Registry: run("codex", input)
    Registry->>Pool: run(codexDriver, input)
    Pool->>Runtime: create or reuse runtime
    Runtime->>CLI: thread/start or thread/resume
    CLI-->>Runtime: thread id
    Runtime->>CLI: turn/start
    CLI-->>Runtime: item/completed notifications
    CLI-->>Runtime: turn/completed
    Runtime-->>Manager: session id, response, items
Loading

Reviews (1): Last reviewed commit: "build(codex): remove bundled sdk runtime" | Re-trigger Greptile

@Waishnav Waishnav changed the title refactor/codex app server runtime refactor(codex): replace the SDK with a shared App Server runtime Aug 12, 2026
@Waishnav
Waishnav force-pushed the refactor/codex-app-server-runtime branch 2 times, most recently from 00a287a to 0cc1046 Compare August 12, 2026 02:15
@Waishnav
Waishnav force-pushed the refactor/codex-app-server-runtime branch from 0cc1046 to 93fd551 Compare August 12, 2026 02:18

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/local-agent-codex/app-server-transport.ts`:
- Around line 53-61: Update the app-server launch logic in the transport
constructor and checkCodexAppServerAvailability to distinguish .CMD/.BAT shims
from native executables: spawn native executables without a shell, while
launching batch shims through a safely quoted and validated Windows shell
command. Reuse the same executable classification and argument strategy in both
paths, preserving existing non-Windows behavior.

In `@src/local-agent-codex/runtime.ts`:
- Around line 35-39: Update src/local-agent-codex/runtime.ts lines 35-39 in the
constructor to subscribe to CodexAppServerConnection’s new close hook and reject
every entry in pendingTurns when the App Server terminates. Update
src/local-agent-codex/runtime.test.ts lines 5-69 by adding the corresponding
close hook to FakeCodexConnection and a test that starts runtime.run, triggers
closure, and verifies the promise rejects instead of hanging.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2a721550-349f-4552-81cf-fee76894299b

📥 Commits

Reviewing files that changed from the base of the PR and between a72edee and 0cc1046.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (14)
  • docs/agent-profile-schema.md
  • docs/configuration.md
  • package.json
  • src/local-agent-adapters.ts
  • src/local-agent-availability.test.ts
  • src/local-agent-availability.ts
  • src/local-agent-codex/app-server-transport.ts
  • src/local-agent-codex/command.ts
  • src/local-agent-codex/runtime.test.ts
  • src/local-agent-codex/runtime.ts
  • src/local-agent-path.ts
  • src/local-agent-runtime-registry.ts
  • src/local-agent-runtime.test.ts
  • src/local-agent-runtime.ts
💤 Files with no reviewable changes (2)
  • src/local-agent-runtime.test.ts
  • src/local-agent-runtime.ts

Comment thread src/local-agent-codex/app-server-transport.ts
Comment thread src/local-agent-codex/runtime.ts
@Waishnav
Waishnav force-pushed the refactor/codex-app-server-runtime branch from 93fd551 to ea5f12f Compare August 12, 2026 02:30
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