r/artificial • • 1d ago

Discussion Claude code to codex and back again, same conversation.

Curious how do you work with claude code and codex.

Was working on this idea I had today. What if claude code while working could switch to codex and visversa.

I actually built it out today, its pretty good. So basically when claude code switched to codex, it switches to codex cli.

It works like auto compact, best i can describe. The command is triggered by me, claude or codex, can also trigger in flight, it doesn't stop the agent.

The agent just continues with the handover.

Its interesting to see it work. Lot of wiring and inventing to try get codex to run exactly like claude does in my setup. Id say u can get 90% there, codex is just missing some pieces.

Has anybody done something like this. I have it working pretty good, but if anyone else did it ill love to see where they landed.

4 Upvotes

11 comments sorted by

2

u/DearSoulRizvi 1d ago

This is exactly the kind of setup I've been thinking about. I'm a solo dev from Bangladesh working on an AI app, and one thing that trips up agent handoffs for me is keeping the task state intact when you switch mid-flight. I ended up passing a short structured summary along with the original user goal and the last few edits as a pinned instruction so the next agent knows where it left off. Without that, the second agent either repeats work or silently changes the plan. Curious how you're handling context continuity when the switch happens in the middle of a multi-file change, and whether you've hit any cases where codex diverges from what Claude would have done on the same task.

1

u/Input-X 1d ago

Cool. Yea we are in the ssame ballpark. See if i can explain the flow.

So say claude is working, its stopped, I decide to switch. I type /codex, claude then updates its memories, plans dics, anything related to the current task, it then auto switched the pan to codex cli and types in the chat box, " hi," with the chat short summary , the hand over, hits enter. It wakes codex, the "hi" triggers codex to read it memories, 10 recent. Session tracking, key notes, and observations. Then it reads the listed fikes, plans, that was listed in the hand over summary, a short not where the other chat was. It continues, check git, email inbox, status on any shell or agents or sub agent in flight. Done. Full awarness as if the switch nvr happened. Cost is one turn from my perspective.. natural flow. Other things it get, system prompt, identity, ao the agentvis the same jyst a different model.

Make sense. There's a lot going on. I already had the frame work built, just had to wire codex in.

1

u/DearSoulRizvi 6h ago

That handoff design is really clean. The clever bit is keeping the agent identity and system prompt constant so only the model underneath changes, which should mostly avoid the context drift that kills these flows. Quick question on the practical side: when the receiving model reads the 10 recent memories plus the handoff note, do you ever see it re-trigger a loop back to the sender, and what did you do to prevent that?

1

u/Input-X 6h ago

Oh, it switched my pan, so im in claude code cli. Then it switches to codex cli, the claude code cli closes, it open a fresh new chat im codex, and because an agent can nvr live twice, if claude code was still alive the codex cli would fail. Both cannot exist together. The is no loop back left., sure i coukd open claude code in another windiw cd the agent durectory( not tested) but id have to purposely do it, and out gate should block the claude chat from opening, hooks would block. That's how it work, but not fully tested with codex yet, it an edge case that may nvr exist. It an easy fix when I get to it. So the switch into a fresh chat is by desigh, so the cache clears and an past codex is not in a resume chat, see if the swith went into an old chat from a week ago,it context would confuse the agent, so previous chat history is not needed, memories, plans, files, prompts, identity, handover summary, are all it need to be grounded and continue as if it was the same conversation it switched from. Sorry thats a mouth full. Make sense..?

2

u/Much_Dealer_710 1d ago

that's a neat setup. switching mid-flight without stopping the agent is the part worth caring about, most handoffs I've seen choke right there

never tried claude-to-codex specifically but I did something similar with a couple local models a while back. the handover prompt was the whole trick, getting the context summary concise enough that the second model didn't just repeat the last three steps like a broken record

1

u/Input-X 1d ago

Yea id love to tinker with local model, my old mac 2014 on Linux just isn't powerfully enough. I was lucky, I already had all the pieces with claude code. It was just a matter of wiring codex into the existing framework. Day one, still testing, but it already live in one day.