Repository navigation
Description
What variant of Codex are you using?
CLI
What feature would you like to see?
Feature request
Codex should support handing off a long-running session from one model provider
to another while preserving its working context.
Example:
- Continue a long GPT session with a custom Responses-compatible provider when
the GPT quota is exhausted. - Later hand the resulting session back to OpenAI models.
- Preserve completed conversation history, decisions, tool results, and project
context without requiring a manual summary.
Current behavior
-
codex resumeacross providers is unreliable because the session retains its
original provider-specific state. -
codex fork -p <provider> -m <model> <session-id>copies the history, but the
destination provider may reject valid historical tool records. -
In my case DeepSeek returned:
No tool output found for tool call call_mj42PDsUwFvbo5vPJM4Kunyd -
The corresponding
custom_tool_call_outputwas present in the rollout file,
but a developer message occurred between the tool call and its output.
OpenAI accepted this history; the custom provider rejected it. -
Provider-specific pickers also make the source session difficult to locate,
requiring its UUID.
Desired behavior
Before a cross-provider resume or fork, Codex should normalize the transcript
into a provider-neutral representation:
- preserve all user and assistant messages;
- preserve completed tool calls and outputs;
- guarantee valid call/output pairing and ordering;
- remove or transform provider-specific protocol items;
- retain the source session as an unchanged rollback point;
- clearly indicate that the destination is a new session derived from the
original session.
Ideally:
codex handoff <session-id> --profile deepseek --model deepseek-v4-pro
Environment
- Codex CLI 0.147.0
- macOS
- Source provider: OpenAI
- Destination: custom Responses-compatible provider
Additional information
No response
Activity
CCanxue commentedon Aug 14, 2026
Related evidence: cross-provider history replay is already fragile in this family. DeepSeek stores plaintext
reasoning_text/agent-message shapes that strict OpenAI endpoints reject on switch (see hermes-agent#32617, #17541), and the reverse direction fails too. A normalized, provider-neutral transcript before resume/fork matches the direction several of these issues ask for; our patch only covers task delivery, not history normalization. Family overview: https://github.com/CCanxue/codex-deepseek-subagent-fixjdcodes1 commentedon Aug 18, 2026
Half of the normalization layer you're proposing already exists — which sharpens what's actually missing.
core/src/context_manager/normalize.rsguarantees presence invariants when history is rebuilt:ensure_call_outputs_presentsynthesizes an output for any dangling call,remove_orphan_outputsdrops outputs with no call, and there are strip passes for unsupported media (https://github.com/openai/codex/blob/1f41cc5d92/codex-rs/core/src/context_manager/normalize.rs#L21,#L148).What it never enforces is adjacency: your DeepSeek failure is a call/output pair separated by an interleaved developer message — valid for the OpenAI Responses API, rejected by stricter chat-completions-style validators. That's a pure reordering transform the existing pass could add. The second gap is provider-opaque items: encrypted reasoning payloads and inter-agent messages carry
encrypted_contentonly the originating provider can use (#38656 documents a fork of this problem), and compaction markers are protocol-specific — those need dropping or flattening to text on a provider switch.So the feature could land incrementally: extend the existing normalize pass with adjacency + opaque-item handling, and run it on
fork -p/cross-provider resume. No new transcript format needed.vshulcz commentedon Aug 23, 2026
A different framing that sidesteps the rejection problem rather than normalising around it, from having built handoff across twenty agents.
Do not move the tool history at all. What the destination needs in order to continue is not the provider-specific record of how the work happened — it is the work: the problem being solved, the conclusions reached so far, and where it stopped. That is plain text, and no endpoint rejects plain text. The transcript on disk already holds it, so the package can be rebuilt from the source session instead of converted from the previous provider's wire format.
The trade is explicit and worth stating: you lose replay of tool calls as tool calls, so the new session starts as a fresh conversation that happens to know what the old one concluded. What you gain is that the move works between providers sharing no schema at all — and between different agents, not only different providers behind one agent.
The failure in the report is the general case of the alternative: a normalisation layer has to keep up with every provider's record shape, forever, and
reasoning_textis only the instance that surfaced this week. Text has no such obligation.Ours is
deja handoff --to <agent>in https://github.com/vshulcz/deja-vu, Codex included. If it is useful I can write up which parts of a session actually turned out to matter on the other side and which we stopped carrying.JunkaiWang-TheoPhy commentedon Sep 17, 2026
Related data point, since this issue already frames the normalize layer precisely: the presence invariants you describe are enforced only when history is rebuilt.
ensure_call_outputs_presenthas a single call site (context_manager/history.rs:798),client.rs:849does no send-time validation, and a turn's first sampling request uses the caller-provided input (session/turn.rs:1585) instead of the normalized snapshot. I filed the location plus a runnable strict-upstream checker in #46193.For the cross-provider handoff angle specifically: I measured what a strict third-party upstream actually rejects, and the messages are misleading — a batch split by its own outputs (
callA → outA → callB → outB) is rejected withThe 'reasoning_text' in the thinking mode must be passed back to the API, whilecallA → callB → outA → outBreturns 200 for identical content. Worth knowing before deciding what a normalized history must preserve.bluesky129 commentedon Sep 18, 2026
Adding a concrete UX/architecture requirement from a multi-provider workflow:
A running Codex process can reasonably use one provider at a time, but the persisted session should not be permanently bound to that provider. After changing the active provider/profile, restarting Codex, and resuming the same session, the user should be able to continue the original conversation without manually copying/forking it.
Suggested semantics:
This separation of
Session StatefromExecution Backendwould make provider switching much less disruptive and align the UX with how users already expect long-running coding sessions to behave.NashCC1550 commentedon Sep 18, 2026
Another trigger for the same adjacency gap, confirmed at the wire level:
<image_resize_notice>.Setup: Codex Desktop
0.155.0-alpha.9(macOS), DeepSeek V4.1 Flash (deepseek-flash) through a local Responses gateway, native Responses wire. The gateway passes the history through unchanged.What happens: the model issues two parallel
view_imagecalls. The first image is larger than the limit, so Codex resizes it and records adevelopermessage with<image_resize_notice>right after the first output, before the second one. The persisted history ends with:DeepSeek rejects the next request:
The thread stays wedged after this, because every later turn replays the same history.
A/B, replaying that exact history directly to
https://api.deepseek.com/v1/responses(no gateway in the path):id/status/namespacestrippedSo both outputs are present, and this is not the #44604 race. The only problem is the developer message inside the call/output group. It hits whenever a parallel batch includes an image that gets resized, and it does not need a cross-provider fork.
Workaround applied on the gateway side: before sending to DeepSeek, move any non-assistant
messagethat sits inside a call batch to right after the batch's last output. A batch whose outputs never all arrive is left unchanged, and the transform is idempotent. With it, the same history replays with 200. A send-boundary normalization in Codex, as discussed in #46193, would cover this case too.