Skip to main content

deepseek-harness-studio/packages/subagent/subagent-codex

403Stars43Forks2Issues2Watchers

Have DSH automatically launch the official Codex sub-agent in delegated sessions: hand off a plain text task to Codex via the app-server protocol and return the final answer according to strict success criteria.

Evidence5/5methodologySourceInstallMaintenanceDSH versionSecurity scan
Machine-auditedInstall commandRepo verifieddsh-plugin topicLicenseREADMEAI wiki

ⓘ This plugin is a sub-package of the fufankeji/deepseek-harness-studio monorepo — stars and activity count the whole repository.

Language
TypeScript
License
MIT
Branch
main
ai-agentdeepseekdeepseek-harnessdeepseek-harness-studiodesktop-appdeveloper-toolsdshdsh-plugin

Install

cmdweb profile
$ dsh plugin --profile web add github:fufankeji/deepseek-harness-studio#path:packages/subagent/subagent-codex

Run the command above in your terminal to install this plugin via the dsh CLI. You can switch Profile in the top-right corner. New to dsh? Read the beginner tutorial

Install via your agent

Install the DeepSeek Harness plugin fufankeji/deepseek-harness-studio/packages/subagent/subagent-codex for me: review the repository at https://github.com/fufankeji/deepseek-harness-studio first, then run the install command and verify the plugin loads successfully.

Paste this instruction to the DSH Web GUI assistant — it will install and verify for you.

One-Line Positioning

subagent-codex enables DSH sessions to temporarily spawn an independent Codex subprocess for pure text tasks when needed: each time spawning a fresh app-server, no human approval required, and delivering the final answer or failure diagnosis back to the upstream; it doesn't modify your Codex account or settings, just bridges the official app-server protocol to DSH's subagent service.

Core Capabilities

  • Spawns the official Codex app-server --stdio subprocess within the delegated Session's working directory, with the process managed by dsh-subprocess's process tree (src/run.ts:236-249 / src/run.ts:185-217)
  • One-shot text tasks: accepts only non-empty plain text blocks; Codex must return an agentMessage with phase: "final_answer"; when no explicit final phase exists, falls back to the last message with phase: null; empty responses are treated as errors (README.md:11 / src/run.ts:162-177)
  • Unattended approval: command/file approval flows through Codex's thread/start configuration; none of the three permissionMode values trigger DSH interaction; unknown server requests fail directly and close (src/wire.ts:25-36, 86-94 / README.md:13)
  • Failure with diagnostics: composes a failure summary from lifecycle stages (initialize / thread-start / turn-start / turn / process / teardown), Codex error classification, HTTP status codes, subprocess exit codes/signals, and writes to SubagentResult.diagnostic (src/run.ts:84-114 / src/run.ts:358-365)
  • Does not inherit parent session: explicitly sets inheritsParentContext: false; parent session's conversation, roles, tool filtering, and depth strategy are not passed to child Codex (src/index.ts:62 / README.md:21)
  • Install/uninstall via Profile Bundle: installation adds a dormant provider to the host; uninstallation removes it along with its private runtime on next startup (README.md:44 / cordis.patch.yml:1-5)

Technical Implementation

  • Language: TypeScript (ESM, published artifacts lib/index.js and lib/types/*.d.ts, see package.json:13-27).
  • Key Dependencies: @openai/[email protected] (official SDK, includes six platform sub-packages carrying app-server 2.1.220 JavaScript wrapper and native codex binary), @deepseek-ai/dsh-subagent (shared task seam and result settlement), @deepseek-ai/dsh-subprocess (responsible for real CLI process tree hosting), @deepseek-ai/dsh-timeout (MAX_TIMER_DELAY_MS upper bound validation) (package.json:49-53 / src/run.ts:9-29 / src/index.ts:11).
  • Architecture Pattern: Function plugin + Profile Bundle—src/index.ts named exports name/inject/Config/apply; apply(ctx, config) registers a CodexProvider to ctx.subagents, injected into dsh-base above via cordis.patch.yml. At runtime, resolves @openai/codex/package.json's bin.codex via createRequire, spawning the wrapper using the current Node executable; JSON-RPC framing layer is provided by dsh-sdk-protocol, with wire.ts handling product methods, current thread/turn association, unattended approval responses, and final answer selection (src/index.ts:30-32, 113-135 / cordis.patch.yml:1-5 / src/run.ts:43-52, 132-134 / src/wire.ts:9-14).
  • Entry Files: src/index.ts (Cordis registration entry), src/run.ts (one-shot task lifecycle and run spec), src/wire.ts (Codex app-server 0.147.0 protocol adapter).

Use Cases

Delegate independent tasks where you "don't want to lift a finger, just let Codex handle it" to a subagent. A common approach is for the DSH main conversation model to trigger subagent_codex from its tool whitelist as needed—for example, generating long documents in one go, batch modifying files, or having Codex pull a status summary and bring it back to the main conversation. This package is not suitable for scenarios requiring continuous dialogue, watching intermediate steps, or requiring Codex to prompt for interactive confirmations throughout—these needs inherently conflict with the "one-shot, unattended, final answer only" positioning.

Prerequisites and Compatibility

DependencyMinimum VersionDescription
DSH (launcher)0.1.0-rc.8This package and other packages in the same repository share the same version (package.json:4), injected as a Profile Bundle on top of dsh-base (cordis.patch.yml:1-5).
Node.js^22.19.0 || >=24.0.0Repository root engines.node constraint; subagent-codex doesn't declare its own independent range (repository root package.json:8-10).
PlatformCross-platform (macOS / Windows / Linux)Actual executable app-server comes from @openai/[email protected]'s six platform sub-packages auto-selected by system/CPU; omitting optional dependencies, unsupported systems, or missing payload files will allow provider registration to succeed but fail at the first delegation at the app-server launch boundary (README.md:97-101).
Codex app-server0.147.0 (bundled with @openai/codex)Locked by 0.147.0, doesn't depend on host codex; this package also doesn't check PATH, do platform selection, or fall back to host binary (README.md:42 / src/run.ts:43-52).
Native Modulescodex / codex-code-mode-host / rg / zsh (included in darwin-arm64 platform package)Carried by Codex platform packages after installation; DSH doesn't introduce new native modules; payload for other platforms may differ (README.md:97).
disposeGraceMs Upper Bound≤ MAX_TIMER_DELAY_MS (2,147,483,647)Validated at apply() startup; must be a positive finite value not exceeding repository's shared dsh-timeout upper bound (src/index.ts:120-129 / packages/util/timeout/src/index.ts:25).

Installation

dsh plugin --profile web add github:fufankeji/deepseek-harness-studio/packages/subagent/subagent-codex

Configuration Options

OptionTypeDescriptionDefault
providerNameString (non-empty)Registration name on ctx.subagents, also referenced by the provider field in dsh-tool-subagent tool rows; must be unique when multiple instances are attached to the same Profile (src/index.ts:38, 51 / README.md:27).codex
envObject (Record<string, string>)Explicitly passed environment variables to the Codex app-server subprocess, layered on top of the subset of parent environment after credentials are cleared by the sharing mechanism; must explicitly declare OPENAI_API_KEY here to have the subprocess receive it (src/index.ts:43, 52 / src/run.ts:241 / README.md:42).{}
permissionModeEnum: never / approve-for-me / dangerously-bypass-approvals-and-sandboxSelects the Codex native non-interactive permission and sandbox mode for this provider instance; never means no approval requests are sent, approve-for-me uses Codex's automatic review, dangerously-bypass-approvals-and-sandbox disables both approval and sandbox (src/run.ts:55-68 / README.md:32-36).never
disposeGraceMsNumber (milliseconds, positive finite)Wait duration between termination tiers for the shared process tree owner; the entire process tree must exit before cleanup is considered complete (src/index.ts:47, 55, 120-129 / src/run.ts:240).3000

FAQ

Q: What's the difference from directly connecting to the Codex API? Is this an easier integration?

A: It's different. This package plays the "subagent provider" role for dsh, handling one-shot requests from dsh-tool-subagent—each time spawning a fresh Codex app-server process that runs to completion; it doesn't choose models for Codex, doesn't persist Codex sessions, and doesn't replicate Codex settings. The default deepseek entry in dsh-base is the main conversation model, and this provider is completely independent at the process level (README.md:42, 135).

Q: Does env only need to contain OPENAI_API_KEY? How do I pass other variables?

A: Not limited to just the key, but please put the key here. Any environment variables in the parent process identified as credentials are stripped by dsh-subprocess before being passed to the subprocess. Non-credential variables like HOME and CODEX_HOME are naturally inherited; they can also be explicitly overridden in env. DSH doesn't create accounts, doesn't log into Codex, and doesn't modify settings files; login state and valid keys must be ensured by the Codex side itself (README.md:42 / src/run.ts:241).

Q: After installation, how does the model know about the subagent_codex tool?

A: It doesn't—it's up to your Agent Preset. Full Preset has the corresponding tool row set to disabled: true by default; you need to duplicate the Preset and remove this field. When starting a new Session based on the duplicate, the model will see that static tool name. Each dsh-tool-subagent row needs an independent toolName exposed to the model, so when multiple providers are attached under the same Profile, each tool also needs a unique name (README.md:52).

Q: How do Codex's configuration files in the subprocess take effect?

A: They use relative paths from native Codex configuration—this package neither specifies CODEX_HOME nor copies/filters settings files. So it searches for configuration and login state in the parent session's working directory following Codex's own project/user three-layer hierarchy. This means you can place a .codex/settings.json in your project to affect this provider, and uninstalling this package won't touch these files (README.md:42).

Q: How do I tell from failures whether it's a Codex error or the subprocess didn't start?

A: Look at the stage segment in SubagentResult.diagnostic: initialize / thread-start are mostly startup issues (e.g., platform package not found, payload missing), turn-start / turn are Codex protocol layer errors, process means CLI exited but didn't produce results normally, teardown is subprocess exit failure during cleanup. Co-occurring exit code / signal lines are the actual process layer exit reasons; HTTP status codes only appear in diagnostics when Codex provides them. Raw product layer or Host errors always remain in the Error's cause chain and don't directly enter this diagnostic (src/run.ts:84-114, 358-365 / src/wire.ts).

Q: How do I choose among the three permissionMode values?

A: Use the default never if you don't want any approval dialogs—Codex will directly reject operations without pre-authorization. If you want Codex to modify files but still not ask humans, change permissionMode to approve-for-me—Codex will then use automatic review instead of DSH popups. dangerously-bypass-approvals-and-sandbox disables both native approval and sandbox, letting Codex run wild and do anything in any path—use this only in controlled/sandboxed environments. None of the three modes create interaction channels on the DSH side; all approvals flow through Codex's own settings (README.md:34-40 / src/wire.ts:25-36).

Q: Can I have one tool instance support both foreground and background execution?

A: Yes, but you need two tool rows. When dsh-tool-subagent's backgroundMode is one-shot, omitting run_in_background or passing false runs in foreground (synchronous blocking); passing true immediately returns a Job id owned by the parent Agent, which can be followed up with dsh-tool-jobs' job_output / job_kill. This requires your Profile to have the local job service installed (@deepseek-ai/dsh-jobs-local / dsh-tool-jobs) (README.md:52).

Q: Does uninstalling this package leave any side effects?

A: No persistent side effects. After uninstall, the next Profile startup deregisters this provider; this package has no independent disk writes or account creation; login state, Codex settings files, and cache remain independently on the Codex side (README.md:44 / README.md:144).

Difficulty Level

Advanced — requires understanding DSH's Profile Bundle model, cordis patch injection order, the seam between dsh-tool-subagent and jobs, and the ability to configure Codex's settings and keys to get the subprocess running; if you're looking for "plug and play," the entire chain may feel somewhat lengthy.

Known Issues and Limitations

  • Each run creates a new app-server, Codex thread, and turn: no continuation, resume, pooling, progress streaming, or product session persistence (README.md:135)
  • Instance selection is static: Profile rows fix provider name and tool binding; models cannot select providers at call time; each exposed tool must have a unique toolName (README.md:136)
  • Host Codex settings are always authoritative: this package doesn't provide a "filtered or isolated from host environment" production mode; project and user layer settings can modify models, providers, MCP, hooks, skills, etc. (README.md:42, 137)
  • Authentication and account state managed by native Codex side: this package doesn't create accounts, log in, or modify settings; configuration or authentication failures are reported with lifecycle stage + unknown fallback (README.md:137)
  • Must have Codex platform payload at delegation time: optional dependencies skipped, platform unsupported, platform payload missing or corrupted will fail at first initialize; no "host CLI fallback" path exists (README.md:138 / src/run.ts:243-248)
  • Compatibility locked to 0.147.0 protocol baseline: upgrading Codex requires regenerating upstream schema evidence and re-running handshake / answer selection / approval / cancellation / real product testing (README.md:139)
  • No human approval path exists: unattended approval requests are known to be rejected; unknown server requests cause failure with default rejection; none of the three permissionMode values create DSH interaction channels or per-call allow strategies (README.md:140 / src/wire.ts:38-51)
  • Assistant payload only contains final text: reasoning, process explanations, intermediate messages, tool calls, usage, process stderr, and workspace diffs don't enter parent session; failures carry an independent safety diagnosis when needed (README.md:141)
  • Optional sharing capabilities not supported: shared subagent service rejects this provider's output schema, sub-roles, tool filtering, and harness depth enforcement (README.md:142)
  • No time-based timeout or side-effect rollback: only caller-initiated abort stops it; any state written/modified/called to external interfaces by the subprocess before stopping is not automatically reverted (README.md:143)

Read the usage guide →

Install steps, key points, FAQ and compatibility for this plugin — auto-derived from indexed fields.

Listing badge

Listed on deepseek-plugin.org
[![Listed on deepseek-plugin.org](https://img.shields.io/badge/listed_on-deepseek--plugin.org-007EC6)](https://deepseek-plugin.org/plugins/fufankeji/deepseek-harness-studio/packages/subagent/subagent-codex)

Paste this markdown into your GitHub README to link back to this listing. The badge only states the listing — not a security endorsement.

← Back to plugin directory