dsh-codex-bridge: Delegate Heavy Tasks to Codex CLI Using ChatGPT Plan Quota

Preface

When running agents in DeepSeek Harness (DSH), complex reasoning often requires external models or CLIs. If OpenAI Codex CLI is already installed and logged in on the local machine, and quotas are distributed across two ChatGPT plan windows—a 5-hour window and a weekly window—manually checking allowances, selecting models, and then running codex exec interrupts the agent workflow and risks mistakenly using high-tier models when quota is tight.

Below we introduce the community plugin dsh-codex-bridge (maintainer: AK-blank, category: model inference): it reads local Codex quotas on the DSH host side and delegates tasks non-interactively to codex exec according to policy. This plugin is an unofficial community work and has no affiliation with or endorsement from OpenAI, Codex, or DeepSeek.

What Is This

dsh-codex-bridge is a bundle that runs only on the DSH host side: it provides two tools, with no browser half, no build step, and no npm dependencies. It reads allowances and the model tier ladder through Codex CLI’s codex app-server, consuming model usage only when the delegation tool is called.

Tool Purpose Consumes Codex Usage
codex_status Reads 5-hour/weekly windows, reset times, allowances, model ladder, and quota-aware recommendations No
codex_delegate Runs a single non-interactive codex exec in a specified directory, returning the answer, token usage, thread id, and remaining quota Yes

codex_status uses account/rateLimits/read and model/list; the only path that actually spends quota is codex_delegate.

Quota and Model Policies

The deployed default policy is deliberately conservative, avoiding the use of high-tier models when quota is nearly exhausted:

  1. Normal state: defaults to gpt-6.1-sol, reasoning effort high.
  2. Reserve state: when any window’s remaining quota is ≤10%, automatically switches to gpt-5.6-sol, medium.
  3. gpt-6-astra: never selected automatically; the caller must explicitly pass model: "gpt-6-astra" and allow_expensive_model: true, because it drains shared quota faster.
  4. Floor: models no lower than gpt-5.6-sol, reasoning effort no lower than medium.
  5. Blocking: when usage reaches 95%, or the backend prohibits normal use, execution is refused unless allow_low_quota: true.

When model=auto and reasoning_effort=auto, recommendations are made based on task complexity (simple / standard / hard / critical): in the normal state, both are gpt-6.1-sol / high; in the reserve state, gpt-5.6-sol is used, with critical at high and the rest at medium. If the caller explicitly specifies a model or effort, it will be validated rather than silently downgraded; on rejection, the message will state the available models or the missing opt-in.

Note: the installed Codex CLI may not list gpt-6.1-sol in model/list, but the backend may still accept it; codex_status will mark it as configured and note that codex exec may produce a missing-model-metadata warning. If the account’s model ids differ, you can change defaultModel / minModel in the configuration.

Installation and Enablement

Environment requirements: DSH 0.2.0-rc.2 (the tested version documented in the README), Node.js 20+, and a logged-in Codex CLI (codex login).

In the DSH Web GUI’s Plugins, you can add a package directory or install the bundle via the plugin manager:

{ "action": "install_bundle", "target": "/path/to/dsh-codex-bridge" }

Install from GitHub (when the repository is published):

dsh plugin --profile web add github:AK-blank/dsh-codex-bridge#v1.1.1

Install from a local directory and confirm the configuration takes effect:

dsh plugin --profile web add /path/to/dsh-codex-bridge
dsh --profile web --dump-config | grep -A2 codex-bridge

If the host process has already cached old modules, you need to restart dsh web. New bundle lines can take effect hot, but after modifying lib/*.js the process must be restarted.

You can override the plugin line in the profile’s cordis.patch.yml, for example:

- id: codex-bridge
  name: dsh-codex-bridge
  config:
    minModel: gpt-5.6-sol
    defaultModel: gpt-6.1-sol
    expensiveModel: gpt-6-astra
    minEffort: medium
    defaultEffort: high
    reservePercent: 10
    stopPercent: 95
    statusCacheSeconds: 30
    defaultSandbox: read-only
    ephemeral: true
    maxTimeoutSeconds: 1800
    maxOutputChars: 16000
    codexCommand: codex
    codexHome: ''

Meanings of commonly used options: reservePercent / stopPercent correspond to the 10% reserve switch and 95% blocking threshold; defaultSandbox defaults to read-only; ephemeral: true means each delegation is not persisted to ~/.codex/sessions; maxTimeoutSeconds caps a single delegation’s wall clock at 1800 seconds; maxOutputChars caps the answer characters returned to the agent at 16000.

Typical Usage

A natural-language example for the agent (original intent from the README):

Check the Codex quota, then delegate this hard problem to Codex with the right model and effort.

In practice: first call codex_status, then invoke codex_delegate based on complexity or explicit model / reasoning_effort. The task description must be self-contained—Codex cannot see the DSH conversation, so you need to state absolute paths, symptoms, constraints, and deliverables.

The default sandbox is read-only. Only when file changes are needed should you pass sandbox: "workspace-write" along with an appropriate cwd.

The repository includes a self-test, which can be run in the plugin directory:

node selftest.mjs             # Offline: contracts, policies, rendering, registration
node selftest.mjs --live      # Reads real quotas and model ladder (does not consume model usage)
node selftest.mjs --live-exec # Runs one tiny codex exec (will consume a small amount of usage)

Applicable Scenarios and Caveats

Suitable for: developers who already use a Codex CLI bound to a ChatGPT plan on their local machine and want to uniformly check quotas within DSH agents, select models based on window remaining amounts, and outsource difficult tasks to codex exec.

Important caveats:

  • The plugin runs under the permissions of the current dsh host process; before installing, read the source code and the MIT license, and assess the trust boundary yourself.
  • Codex and DSH sessions do not share context; delegation content must be written out in full.
  • Under read-only, Codex can read cwd but cannot write; workspace-write is still constrained by Codex’s own sandbox and network policies.
  • The returned quota is a percentage snapshot, not a precise token reservation; the tiered policy is a spending guardrail.
  • Codex CLI upgrades may cause app-server method incompatibilities, reported as CODEX_RPC / CODEX_PROTOCOL errors rather than fabricated data.

The DSH ecosystem emphasizes “everything is a plugin”; community directory sites have no official affiliation with DeepSeek / Hiunke. This article introduces an independent community entry, not a product listed in the official app store.

Closing

dsh-codex-bridge consolidates “read quota → select model and reasoning effort → single codex exec” into two host tools, defaults to conservative behavior, and requires explicit opt-in for low-quota and expensive models. The current package version is 1.1.1.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye