Codex and Claude Code Multi-Agent Workflow: Reduce Token Costs on Large Projects with DeepSeek

This is a multi-agent delegation workflow designed for large projects: Codex handles decomposition, dispatch, review, and delivery; Claude Code CLI handles execution; and DeepSeek absorbs high-token-cost tasks. It solves context bloat in the main thread, excessive log noise, and runaway trial-and-error costs. Keywords: Codex, Multi-Agent, DeepSeek

The technical specification snapshot is straightforward

Parameter Description
Primary Language Markdown / Scripted Workflow
Collaboration Protocol Codex → Sub-agents → Claude Code CLI
Model Backend Claude Code + DeepSeek (switched via CC Switch)
Core Capabilities Task decomposition, sub-agent delegation, session reuse, audit tracing
Key Mechanisms Session Pool, Fingerprint, Lease, Artifacts
Best-fit Scenarios Broad code reading, refactoring, migration, test fixing
Star Count Not provided in the original source
Core Dependencies Codex, Claude Code, CC Switch, DeepSeek

The core value of this workflow is freeing the main thread from manual execution work

The essence of codex_with_cc is not “opening a few more AI windows.” It turns AI collaboration into a layered execution pipeline. The primary Codex instance no longer carries all reading, editing, testing, and debugging work by itself. Instead, it focuses on global judgment and final acceptance.

The original pain point is clear: once complex tasks are pushed entirely into the main thread, logs, call chains, failure records, and repair attempts keep expanding. The result is a bloated context window and rapidly escalating token costs.

The responsibilities in the multi-agent chain are clearly separated

Codex main thread -> Codex sub-agent -> Claude Code CLI -> Claude Code/DeepSeek backend

The key to this chain is specialization: the main thread makes decisions, sub-agents take ownership of task nodes, the CLI performs execution, and DeepSeek absorbs repetitive work with high context overhead.

Installation is lightweight, and the main barrier is tool readiness

Prerequisites include installing Claude Code, installing CC Switch, switching the Claude Code backend to DeepSeek, and preparing a target project for the workflow. After that, you can simply open Codex in the project.

The recommended onboarding path is to hand the installation prompt directly to Codex so it can integrate the workflow into the current repository.

Please integrate or update the sub-agent orchestration workflow from https://github.com/xdd666t/codex_with_cc into the current project.

This prompt triggers the automatic integration or update flow, allowing the project to quickly gain delegation, reuse, and audit capabilities.

The key to usage is letting Codex act only as the leader

The most important sentence in this method is simple: let Codex be the leader, and let sub-agents be the execution layer. What it changes is not model capability, but task organization.

If you ask Codex to complete a large requirement on its own, it will pile requirement analysis, file edits, test execution, and log review into a single context. A better approach is to decompose the task first, then hand investigation, implementation, and validation to sub-agents.

A typical dispatch prompt looks like this

You are responsible for decomposition, dispatch, review, and final delivery. Sub-agents are responsible for execution. If the result is not acceptable, send it back for rework until it meets my requirements.

This kind of prompt makes the chain of responsibility explicit and keeps the main thread out of intermediate noise.

The images show the workflow operating in real conditions

ChatGPT Image 2026-05-04 11_53_50

AI Visual Insight: This image is more conceptual. Its core purpose is to emphasize the layered relationship in which Codex acts as the orchestration hub and sub-agents act as the execution layer, highlighting the workflow principle that the main thread no longer performs the heavy lifting directly.

image-20260504101914934

AI Visual Insight: This image shows the interface state where Codex creates multiple sub-agents, indicating that the task has been split into parallel work units suitable for investigation, implementation, review, and other distinct responsibilities.

image-20260504101840375

AI Visual Insight: This image captures the process in which a sub-agent invokes Claude CLI to execute a task, showing that delegation does not stop at the prompt layer but continues into command-line execution and result handoff.

image-20260504103024065

AI Visual Insight: This image shows the stage where the main thread sends results back for revision and performs re-review, demonstrating that the workflow includes a closed-loop acceptance mechanism rather than a one-shot generation process.

The engineering value comes from session reuse and parallelism control

The project does not stop at “role-playing multi-agent behavior.” It adds engineering constraints. One of the most important capabilities is the Claude session reuse pool.

It includes three roles—PrimaryReuse, PrimaryAnchor, and ParallelPool—to support serial continuation, parallel anchoring, and independent branch pooling. The goal is to reduce token waste caused by repeated cold starts.

A task delegation example can be designed like this

# Let Codex decompose the task first, then hand it to multiple sub-agents for execution
codex_delegate_task --plan "Split it into 3 non-conflicting implementation tasks" \
  --require "Each sub-agent must output changed files, validation commands, and risk notes" \
  --review "The main thread performs a unified review and final verification"

This example communicates the workflow intent clearly: decompose first, delegate second, review last, and avoid unbounded parallelism across agents.

Fingerprints, lease locks, and audit artifacts ensure traceability

What truly makes multi-agent execution practical is not prompting, but state management. codex_with_cc generates a fingerprint based on task content, scope, and validation commands, and manages session occupancy through leases.

This solves the classic problems in parallel execution: who is occupying a session, whether the session has gone stale, whether expired tasks have been reclaimed, and whether results can be replayed. Without this layer of control, multi-agent systems are merely busy, not production-capable.

Audit artifacts make task results reviewable

config_
<RunId>.json
status_
<RunId>.json
prompt_
<RunId>.md
stream_
<RunId>.jsonl
trace_
<RunId>.log
claude_
<RunId>.md

These artifacts record configuration, status, prompts, streaming output, execution logs, and the final report, making it easier to inspect execution paths and ownership boundaries.

The best use cases involve high-context, repetitive, and strongly validated tasks

This workflow is particularly well suited to large-scale code reading, multi-file transformations, migration refactoring, solution comparison, test fixing, and separating implementation from review. These tasks demand substantial context and generate large amounts of intermediate noise.

The unsuitable cases are just as clear: small fixes, undefined requirements, or work with extremely high file conflict risk. If parallel boundaries are unclear, multi-agent execution can amplify communication and merge costs instead.

The conclusion is that this is an AI execution layer for complex engineering

The value of codex_with_cc does not come from increasing the number of AIs. It comes from preserving the judgment capacity of the primary Codex instance. The main thread handles decomposition, arbitration, and acceptance, while the execution layer handles reading, implementation, testing, and rework.

When DeepSeek takes on inexpensive high-token-throughput tasks, the session pool handles context reuse, and audit artifacts support execution replay, multi-agent workflows finally evolve from a “prompting trick” into an “engineered collaboration protocol.”

FAQ answers the most important practical questions

1. What is the biggest advantage of this workflow compared with single-threaded Codex?

The biggest advantage is that it strips high-noise execution work out of the main context, reduces token consumption, and allows Codex to focus on architectural judgment, risk control, and final acceptance.

2. Why is DeepSeek especially important in this chain?

Because it is better suited to large-scale code reading, repetitive validation, and long-context exploration—high-cost tasks that significantly reduce the pain of spending tokens on every trial-and-error cycle.

3. Is multi-agent execution always better than a single agent?

No. Multi-agent execution delivers clear benefits only when the task is large enough, the boundaries are clear enough, and the validation requirements are strong enough. For small tasks, using the main thread directly is usually more efficient.

Core Summary: This article reconstructs the core design of the codex_with_cc workflow: let Codex act as the leader, delegate high-noise, high-context, and repetitive tasks to Claude Code CLI, and use DeepSeek, a session reuse pool, task fingerprints, and audit artifacts to reduce cost and improve traceability.