跪拜 Guibai
← Back to the summary

One Window for Nine Coding Agents: The Architecture Behind Seamless Handoffs

Tired of Being a Human Relay: I Put 9 Agents into One Chat Window

Anyone who has used AI coding tools heavily will probably agree: different agents have wildly different 'temperaments'.

Take the most common ones: Codex writes code very rigorously, but when discussing plans it's often abstract and cold, like it 'doesn't treat you as human'; on the other hand, Claude and Gemini speak with a lot of 'human touch', can explain problems in your business context, and are much more comfortable for brainstorming requirements and refining plans. Once the plan is settled, let the rigorous Codex review details, define tests, or even directly write code—that's the most comfortable combination.

But truly mixing this way in daily development feels very fragmented: every CLI tool is an island. The common hack is: first finish the Plan conversation in Claude Code, then ask it to output a 'handoff document' or summary, then open another terminal and paste it to Codex to continue; when the other side discovers new boundaries and wants to switch back, you have to organize and transport it again in reverse. Every time you switch agents, the context breaks once, and the developer becomes a literal 'human relay' between two tools.

We normally use a proprietary Agent Console that mainly handles R&D automation—like automatically claiming and fixing bugs, automatically dispatching requirement tasks to backend agents to write code and run delivery. Today I won't expand on the whole system, but will single out one of the most convenient small capabilities: when sorting requirements and outputting Plans, how to let multiple agents seamlessly take over in the same chat window.

Its interface is intuitive, a left-right split Plan workbench: left is the chat area for switching agents to discuss requirements and nail down boundaries anytime; right is the plan area. Every time you and the agent finalize a new conclusion or request revisions, the latest Plan text synchronously updates on the right (you can also hand-tune it). Take a common 'login redirect' requirement: first let Codex chew through the code and produce a hardcore draft; when hitting business boundaries ('the original page is deleted, where to go after login?') directly switch to Claude Code in the same window to continue, then switch back to Codex to confirm test branches. The whole process requires no copy-paste, and history discussions and plan text automatically follow. Below we'll follow this requirement's flow and fully break down the underlying design of this 'single-window multi-agent relay'.


First, clarify a premise: what exactly is being switched?

Many people's first reaction equates 'switching agents' with 'switching models', but in local coding agent scenarios, these are two completely different layers.

When you send a message in one window, behind the scenes stand three roles with separated responsibilities: Plan (task window), Agent (local executor), and Model (underlying LLM).

The workbench passes the question to the local Agent CLI via protocol, and the agent calls the specific model and returns the result.

So when you click 'Codex / some model' in the selector, you're actually choosing two things: the part before the slash decides which executor goes on, and the part after the slash decides which model it calls.

Operation example. The selector has selected Codex / GPT-6.2 Sol. The session shows the previous round switched from Antigravity / Gemini 4 Neon to Claude Code / Claude Sonnet, replied by Claude Code. Next round switch from Claude Code to Codex, takes effect after sending.

Separating these three layers is the premise for switching agents in a single window—task context belongs to Plan, no longer tied to a private process of a single CLI. Agents become pluggable collaborators.

After clicking 'send', what two things actually happen in the backend?

Switching agents on the page looks like one click, but to make it feel like 'the same chat box', the backend silently carries two core dirty tasks after pressing send:

  1. Be a unified front desk + number dispenser: no matter which agent you choose, the frontend only sends messages to the same entry, and the backend issues a 'number plate' for each round, ensuring you can switch agents or click stop anytime without mixing conversations.
  2. Be a 'protocol translator': CLIs on the market speak different dialects; the backend translates and converges 9 agents into 3 channels.

Look at the first thing. The page side is actually 'simple'—whether this round selects Codex or Claude Code, it sends a request to the same address (POST /api/tasks/{taskId}/plan/turn), carrying only three key pieces of info: who goes on (agentId), which brain (model), and what you asked (text):

{
  "agentId": "claude",
  "model": "sonnet",
  "text": "What if the original page is invalid?"
}

The backend stores your question, gives the round a dedicated 'number plate' (turnId), and dispatches the work. Clarify a small concept: 'Turn' here refers to one full back-and-forth where you send a message and the agent gives a final reply—intermediate internal loops like scanning dozens of files or calling code-search tools are all contained in the same Turn, not counted as a new turn.

Why issue a number plate? Think of a scenario you've definitely hit: you just asked Codex to check code (round 3), halfway through you think the direction is off, quickly click 'stop', and immediately switch to Claude Code to ask a new question (round 4). The local CLI process, after receiving a stop signal, doesn't shut up in milliseconds; before exiting it may involuntarily spit out one or two late messages like 'checking file X'. With the turn number plate, the backend only recognizes the current latest round 4—residual messages from round 3 are discarded immediately if they don't match the number, never mixing into Claude Code's conversation.

User sends a message, agent internally scans files and calls tools multiple times, finally gives reply, together counted as 1 Turn. In the example, round 4's Claude Code progress enters Plan; round 3's late Codex progress after stop is discarded by the backend.

Now look at the second thing: how to deal with 9 local CLIs with different temperaments and interfaces? The backend converges them into 3 protocol channels:

After integration. Codex uses app-server, Claude Code uses stream-json. Cursor Agent, Grok Build, OpenCode, OMP, Antigravity, Pi, and DeepSeek Harness share ACP.

  1. Codex → dedicated app-server channel: create and resume sessions via Codex's official App Server interface, directly getting its native read-only sandbox and structured output constraints.
  2. Claude Code → dedicated stream-json channel: send/receive messages via Claude Code CLI's streaming JSON pipe, combined with --permission-mode plan, --json-schema, and --resume for read-only planning and session resumption.
  3. Cursor Agent, Grok Build, OpenCode, OMP, Antigravity, Pi, DeepSeek Harness → unified ACP channel: all converge to the open standard ACP (Agent Client Protocol); future tools like Gemini CLI that support ACP can also be plugged in directly.

First, what is ACP? Think of it as the USB-C standard interface of AI coding tools. Previously every coding agent spoke its own dialect; a workbench wanting to connect 7 tools had to write 7 sets of adapter code. ACP is a public universal conversation protocol—as long as the workbench sends commands following this standard (how to greet, open sessions, ask questions, receive progress), all ACP-supporting local agents can be plugged into the same session window without rewriting integration logic for each new tool.

Many people will ask: since ACP is as convenient as USB-C, why not route everything through ACP, and give Codex and Claude Code two separate dedicated channels?

Use a simple analogy: app-server and stream-json are like two big companies' own 'proprietary fast-charging protocols', while ACP is the 'USB-C standard interface' everyone accepts. Their core differences are in three things:

Comparison dimension Codex (app-server) Claude Code (stream-json) Other 7 agents (ACP)
How to talk Private JSON-RPC, uses its own commands to open sessions and send messages CLI arguments + line-by-line JSON stream Cross-vendor universal protocol, one set of client code works with many
How to control hands (read-only) Built-in read-only sandbox + hooks to intercept write operations Locks plan mode at startup, disables write tools Switch to read-only mode + host intercepts permission popups as fallback
How to deliver in format Native JSON Schema validation, extremely stable Native --json-schema strong validation, very stable Rely on Prompt soft convention for format + backend tolerant parsing as fallback

In short, Codex and Claude Code are the most heavily used daily workhorses: using their private channels lets you get full native read-only sandbox and strong Schema validation, ensuring they never mess up files or output format. Meanwhile, new coding agents keep emerging; rewriting adapter code for each one isn't feasible. Unified ACP works like a USB-C cable—plug in and talk. This 'workhorse dedicated + long-tail standard protocol' hybrid architecture is the most pragmatic balance today.

What happens behind an ACP call?

Earlier we said Codex and Claude Code use private channels; how do the other 7 ACP agents start? Take the more familiar Cursor Agent as an example (shown with OMP which also uses ACP, flow is identical). After the workbench launches the local CLI process, it doesn't just throw a sentence into stdin; it follows the ACP spec through a four-step lifecycle (refer to ACP session setup and prompt turn):

A new OMP session sequentially completes protocol init, creates session, applies selected model, and submits question.

  1. initialize handshake: host and CLI exchange protocol version and capability declarations.
  2. session/new create session: Cursor Agent returns its own sessionId to identify this conversation context.
  3. Lock planning mode and model: workbench switches the session to read-only planning mode and applies your selected model—so the agent can freely search code and verify call chains when discussing plans, but won't mistakenly modify workspace files.
  4. session/prompt submit question: during execution, it continuously pushes thinking fragments and read-only tool call progress via session/update, so the frontend can show 'currently checking files' in real time.

But after completing these four steps (launch process → handshake → create session → set read-only mode), cold start is quite time-consuming. If you had to start from scratch for every follow-up, the experience would stutter. So the backend has two down-to-earth designs (common to all three channels) so follow-ups connect instantly:

  1. Don't hang up the phone too quickly (background resident process): after a Q&A round ends, the workbench doesn't immediately kill the local CLI process; it keeps it waiting in the background (each follow-up refreshes the timer, auto-recycles after 30 idle minutes). When you immediately follow up with the next question, it sends the question to this still-warm process, skipping the first three steps and starting the conversation directly.
  2. Backend keeps a phonebook (double-layer ID mapping): the task you see in the workbench is called Plan #101, but Cursor Agent only recognizes its own chat ID (e.g., cursor_sess_88), Codex only recognizes its own thread_99, none know each other. So the backend records a mapping table by 'which Plan + which Agent':
Plan #101 + Cursor Agent → background waiting process + cursor_sess_88
Plan #101 + Codex → background waiting process + thread_99

Next time you continue with the same agent in the same Plan, the backend checks the phonebook and directly reconnects to its native session from last time, saving time and not losing context.

Warm process and background phonebook. Cold start requires launching process, handshake, create session, set read-only. On next follow-up, Plan #101 finds native session ID by agent. Green solid line sends message to warm Cursor Agent process; blue dashed line marks waiting Codex.

Core principle: when switching agents mid-way, how does context connect seamlessly?

Now back to the key question: if you just stuff different agents into one input box but the new one knows nothing, that's no different from opening two windows.

Let's break the login requirement into three rounds of relay to see what the backend does:

In the same Plan, Codex drafts first, Claude Code takes over draft and relevant discussion, switching back to Codex adds the discussion it missed.

If you had to replay the entire conversation from scratch every time you switch agents, not only would tokens explode, but the model's original cache would be entirely wasted.

You can think of the backend's handling as 'like a requirements review meeting where different experts take turns entering the room'—the backend doesn't use a one-size-fits-all approach, but looks at the situation and feeds context in three modes, plus a fallback:

Handoff package for a newcomer's first takeover. Right column full plan, last 12 conversations, and unresolved questions are compiled into handoff package. Backend sends package to Claude Code, continuing discussion on login redirect fallback plan.

  1. New person just enters → Handoff (a concise handoff package) When round 2 switches to first-time Claude Code, it hasn't participated in the discussion before. The backend won't stupidly carry over all the source code Codex scanned or tool-call processes; instead it picks three most useful things to compile a concise handoff package:

Answer a common question: why not have the previous agent write a 'handoff document' on the fly? First, every switch would need an extra LLM generation round, burning tokens, and AI's second-hand retelling often distorts details; second, the plan text that keeps updating on the right is already the cleanest 'living handoff document'—even if the previous agent just errored, ran out of quota, or you stopped it mid-way, the backend can compile the package from the database and switch instantly.

  1. Same person continues → Follow-up (no supplement, just ask) If you keep asking the same agent for consecutive rounds and no one else interjects, it still remembers what was just discussed. The backend directly sends your new question to its original session—saving tokens, taking full advantage of model cache, fastest and cheapest.

  2. Old acquaintance returns to meeting → Catch-up (open bookmark, only supplement the missed lines) When round 3 switches back to Codex, here's the clever part: it left briefly, but it still remembers what was discussed earlier. The backend attaches a 'bookmark' for each agent, remembering which message number it left at. When you call Codex back, the backend opens its bookmark and only feeds it the new conclusions you and Claude Code discussed during its absence—like passing a note: 'While you were out, we decided invalid original page returns to homepage, continue from here.' No need to restart, and memory connects seamlessly.

  3. What if the old acquaintance suddenly 'loses memory'? (Automatic fallback reconnect) The local CLI process might be recycled due to long idle, computer restart, or server session expiry. Don't panic. As soon as the backend detects the old session can't connect, it quietly discards it and automatically falls back to step 1, re-delivering a handoff package as a 'newcomer entering the room' to finish this round—you won't even notice on the page that it disconnected.

A very practical tip from experience: To save tokens during cross-agent handoff, the chat history only brings the last 12 entries (roughly 6 rounds); after 20-30 rounds, earlier spoken details aren't fully carried over; but the plan text on the right is always fully carried without omission. So hard conclusions settled during discussion (e.g., 'original page invalid always returns to homepage') must be written into the plan text. The chat box is just short-term scratch paper; the plan text is the long-term memory for cross-agent relay.

How does one reply manage both left chat and right plan?

In a left-right split window for requirements, there's an easy pitfall:

Sometimes you just casually ask 'what if the original page is gone?', wanting to hear Claude Code's suggestion; after you understand and decide, you say 'let's settle on homepage, write into the plan.' Normally when chatting with AI, it produces a whole block of text each time—if the program naively overwrites the right side with every reply, a couple of Q&A answers could wipe out the carefully written plan.

Two-grid answer sheet comparison. Casual Q&A reply enters left conversation, planMarkdown empty, right plan retains original. Decision to revise: reply enters left, validated new plan updates right.

The solution is actually simple: don't let the agent freely spit out a whole block; instead the workbench defines a fixed two-grid answer format in advance—{ "reply": "...", "planMarkdown": "..." }—this two-grid answer sheet lets the model decide how to fill these two grids based on your words and current context:

See two scenarios to instantly understand:

{
  "reply": "Suggest fallback to homepage to avoid staying on 404 page. Does that seem okay?",
  "planMarkdown": ""
}

The model judges this round only needs advice, so it leaves planMarkdown empty—backend pastes reply to the left, right plan document untouched.

{
  "reply": "OK, added 'original page invalid returns to homepage' to exception fallback section.",
  "planMarkdown": "# Login Redirect Plan\n1. Normal login returns to original page\n2. When original page invalid, uniformly return to homepage..."
}

The model fills both grids—backend first pastes reply to left, then checks planMarkdown actually changed (preventing model from copying old draft), finally updates right plan text to latest.

This also echoes the 'how to deliver in format' in the comparison table; the two channel types have very different constraint levels:

The UI experience is clearly separated: while the agent is still scanning code or thinking, the page only shows real-time updates like 'checking which file'; after it submits this two-grid answer sheet and the backend stores the conversation reply and plan text together, it then simultaneously shows the formal answer with agent name tag and the new draft on the right—no 'half-spoken words, right-side document already messed up' intermediate state.

An easy-to-trip exception: why can some agents not be mixed into the relay pool?

At this point you might wonder: we've been talking about how great it is for different agents to share context, so why are we isolating them here?

Here hides a real-world issue often overlooked when building multi-agent tools: although each CLI on your machine mostly requires logging into your own account, different vendors' platform usage rules and risk-control thresholds differ greatly; you can't one-size-fits-all throw them into the same automatic relay pool.

Take Google's Antigravity (agy acp, see Google official docs): it also uses ACP under the hood, but Google has stricter rules for this entry—it emphasizes 'real human presence, explicit manual interaction'. In other words, you personally selecting it on the Plan page to chat manually is fine, but handing it to the backend for unattended automatic bug fixing, auto-dispatching tasks, silent health checks, or mixing into cross-vendor relay chains to automatically shuffle context risks tripping platform compliance or risk-control red lines.

Platform-stricter entry (like Antigravity) only triggers when user explicitly manually sends, and is isolated from automatic scheduling and cross-agent handoff.

So even though the underlying protocol is ACP, the workbench still draws three hard rules in upper-level strategy—it remains usable in the same window, but doesn't enter that 'shared meeting room'; instead it sits alone in an 'independent single chat booth':

When you install all sorts of CLIs into the same workbench, 'which agents should be connected for relay and which entries should have red lines drawn per vendor rules' often tests engineering boundary sense more than 'how to make interfaces work'.

In closing

Looking back at this 'single-window multi-agent relay' design, what really smooths the experience isn't some flashy Prompt, but four basic engineering decouplings:

  1. State decoupling: extract task context (Plan) from individual CLI sessions, making agents pluggable executors;
  2. Protocol layering: keep native private channels for main workhorses (app-server / stream-json) to get full sandbox and Schema capabilities; converge the rest of ecosystem to USB-C-like ACP;
  3. Incremental relay: feed context on demand via 'newcomer handoff / old friend follow-up / bookmark catch-up', avoiding replays of full history every switch; auto-fallback rebuild when old session fails;
  4. Read-write separation and boundary isolation: use reply / planMarkdown to separate 'chatting ideas' and 'modifying documents', and for stricter platform entries, keep manual trigger and context isolation bottom lines.

If your daily work is starting to use two or three different coding agents simultaneously, how would you divide the work? Feel free to leave a comment about your multi-agent collaboration habits.

Comments

Top 5 of 12 from juejin.cn, machine-translated. The original thread is authoritative.

侵晨

Doing it for the sake of doing it, I don't see any meaning in it.

不一样的少年_

If you stick with one agent long-term, you really don't need it. We're used to discussing solutions with Claude and having Codex review details and write code; copying context back and forth is annoying, so we just saved that step in our in-house console.

行走的前端码农  → 不一样的少年_

Hasn't Claude been banned yet?

flyfox 1 likes

I used AI to make a mini-program: specifically for couples' quarrels and family discord [melon-eating crowd]

不一样的少年_  · 1 likes

[sly grin]

flyfox  · 1 likes

Welcome big shots to give valuable feedback [heart]

knockkey 1 likes

Awesome!

不一样的少年_

[heart gesture]

badhope

I just stepped on this exact point about single-window multi-agent relay last week. At first I treated 'switching agents' as 'switching models', and the constraints in the Plan got lost with the change: Codex defined the test branch, Claude took over and changed it based on its own understanding. Later I separated the three layers - Plan, Agent, Model - where Plan only stores facts and decisions, Agent only executes, and Model doesn't touch state; only then did it stabilize. In your setup, how do you prevent the next agent from eating the previous agent's implicit constraints when switching?

不一样的少年_  · 1 likes

For things like the test branch you mentioned, we write them directly into the Plan on the right once we've settled them in the chat on the left, not leaving them as just talk; when switching to a new agent, we carry the entire Plan and the recent chat over, and only let it add on top of the original plan, not let it change what was already decided based on its own understanding.

不一样的少年_

Friends who usually use Obsidian can check out the open-source plugin 'Oh My Claudian' made by my colleague, which also uses the multi-agent + ACP approach from this article, embedding local CLIs like Claude Code, Codex, Cursor, and OpenCode directly into Obsidian for use; the experience is quite smooth: https://community.obsidian.md/plugins/oh-my-claudian [heart gesture]