7 ms·
Unrolling the Codex agent loop
- Donkey_Kane 10mo agoextremely helpful
- coffeeaddict1 10mo agoWhat I really want from Codex is checkpoints ala Copilot. There are a couple of issues [0][1] opened about on GitHub, but it doesn't seem a priority for the team. [0] https://github.com/openai/codex/issues/2788 https://github.com/openai/codex/issues/2788 [1] https://github.com/openai/codex/issues/3585 https://github.com/openai/codex/issues/3585
- wahnfrieden 10mo agoThey routinely mention in GitHub that they heavily prioritize based on "upvotes" (emoji reacts) in GitHub issues, and they close issues that don't receive many. So if you want this, please "upvote" those issues.
- deleted 10mo ago[deleted]
- toephu2 10mo agoGemini CLI has this
- adam_patarino 10mo agoI’ve never understood checkpoints / forks. When do you use them?
- coffeeaddict1 10mo agoUsually, I tell the agent to try out an idea and if I don't like the implementation or approach I want to undo the code changes. Then I start again, feeding it more information so it can execute a different idea or the same one with a better plan. This also helps the context window small.
- adam_patarino 10mo agoCan’t you use git for that? I do that often and just revert changes. It does require me to commit often but that’s probably good anyways.
- Sateeshm 10mo agoIt's about not polluting the context. AI doesn't need information about things that didn't work in the new requests' context.
- adam_patarino 10mo agoThat's interesting. I use those moments to show it what not to do. Does it not just repeat the mistakes?
- mkw5053 10mo agoI guess nothing super surprising or new but still valuable read. I wish it was easier/native to reflect on the loop and/or histories while using agentic coding CLIs. I've found some success with an MCP that let's me query my chat histories, but I have to be very explicit about it's use. Also, like many things, continuous learning would probably solve this.
- MultifokalHirn 10mo agothx :)
- jumploops 10mo agoOne thing that surprised me when diving into the Codex internals was that the reasoning tokens persist during the agent tool call loop, but are discarded after every user turn. This helps preserve context over many turns, but it can also mean some context is lost between two related user turns. A strategy that's helped me here, is having the model write progress updates (along with general plans/specs/debug/etc.) to markdown files, acting as a sort of "snapshot" that works across many context windows.
- crorella 10mo agoSame here! I think it would be good if this could be made by default by the tooling. I've seen others using SQL for the same and even the proposal for a succinct way of representing this handoff data in the most compact way.
- vmg12 10mo agoI think this explains why I'm not getting the most out of codex, I like to interrupt and respond to things i see in reasoning tokens.
- behnamoh 10mo agothat's the main gripe I have with codex; I want better observability into what the AI is doing to stop it if I see it going down the wrong path. in CC I can see it easily and stop and steer the model. in codex, the model spends 20m only for it to do something I didn't agree on. it burns OpenAI tokens too; they could save money by supporting this feature!
- deleted 10mo ago[deleted]
- zeroxfe 10mo agoYou're in luck -- /experimetal -> enable steering.
- 10mo ago
- dfajgljsldkjag 10mo agoThe best part about this is how the program acts like a human who is learning by doing. It is not trying to be perfect on the first try, it is just trying to make progress by looking at the results. I think this method is going to make computers much more helpful because they can now handle the messy parts of solving a problem.
- written-beyond 10mo agoHas anyone seriously used codex cli? I was using LLMs for code gen usually through the vscode codex extension, Gemini cli and Claude Code cli. The performance of all 3 of them is utter dog shit, Gemini cli just randomly breaks and starts spamming content trying to reorient itself after a while. However, I decided to try codex cli after hearing they rebuilt it from the ground up and used rust(instead of JS, not implying Rust==better). It's performance is quite literally insane, its UX is completely seamless. They even added small nice to haves like ctrl+left/right to skip your cursor to word boundaries. If you haven't I genuinely think you should give it a try you'll be very surprised. Saw Theo(yc ping labs) talk about how open ai shouldn't have wasted their time optimizing the cli and made a better model or something. I highly disagree after using it.
- procinct 10mo agoSame goes for Claude Code. Literally has vim bindings for editing prompts if you want them.
- behnamoh 10mo agoCC is the clunkiest PoS software I've ever used in terminal; feels like it was vibe coded and anthroshit doesn't give a shit
- estimator7292 10mo agoAll of these agentic UIs are vibe coded. They advertise the percent of AI written code in the tool.
- behnamoh 10mo agowhich begs the question: which came first—agentic AI tools or the AI that vibe coded them?
- songodongo 10mo ago
- ppeetteerr 10mo agoI asked Claude to summarize the article and it was blocked haha. Fortunately, I have the Claude plugin in chrome installed and it used the plugin to read the contents of the page.
- sdwvit 10mo agoGreat achievement. What did you learn?
- ppeetteerr 10mo agoNothing particularly insightful other than avoiding messing with previous messages so as not to mess with the cache.
- rvnx 10mo agoSummary by Claude: Codex works by repeatedly sending a growing prompt to the model, executing any tool calls it requests, appending the results, and repeating until the model returns a text response
- rvnx 10mo agoCodex agent loop: Call the model. If it asks for a tool, run the tool and call again (with the new result appended). Otherwise, done https://i.ytimg.com/vi/74U04h9hQ_s/maxresdefault.jpg https://i.ytimg.com/vi/74U04h9hQ_s/maxresdefault.jpg
- jmkni 10mo agoI think this should be called the Homer Simpson loop, it seems more apt
- rvnx 10mo agoThey sadly renamed the Ralph Wiggum loop due to copyright concerns so little hope for Homer :( https://github.com/anthropics/claude-plugins-official/commit/44328beed48874d8e00da6c4ca5daaa5f0f3183c https://github.com/anthropics/claude-plugins-official/commit...
- jmkni 10mo agoha I didn't know that, very interesting
- deleted 10mo ago[deleted]
- deleted 10mo ago[deleted]
- tecoholic 10mo agoI use 2 cli - Codex and Amp. Almost every time I need a quick change, Amp finishes the task in the time it takes Codex to build context. I think it’s got a lot to do with the system prompt and a the “read loop” as well, amp would read multiple files in one go and get to the task, but codex would crawl the files almost one by one. Anyone noticed this?
- sumedh 10mo agoWhich Gpt model and reasoning level did you use in Codex and Amp? Generally I have noticed Gpt 5.2 codex is slower compared to Sonnet 4.5 in Claude Code.
- nl 10mo agoAmp doesn't have a conventional model selector - you choose fast vs smart (I think that's what it is called). In smart mode it explores with Gemini Flash and writes with Opus. Opus is roughly the same speed as Codex, depending on thinking settings.
- anukin 10mo agoWhat is your general flow with amp? I plan to try it out myself and have been on the fences for a while.
- tecoholic 10mo agoI do the same thing with both. Nothing specific to Amp. But I have read it’s great for brainstorming and planning if I “ask oracle” - oracle being their tool that enables deep thinking. So I tend to use that when I think I have multiple solutions to something or the problem is big enough and I need to plan and break it down into smaller ones
- nl 10mo agoAmp uses Gemini 3 Flash to explore code first. That's model is a great speed/intelligence trade-off especially for that use case.
- westoncb 10mo agoInteresting that compaction is done using an encrypted message that "preserves the model's latent understanding of the original conversation": > Since then, the Responses API has evolved to support a special /responses/compact endpoint (opens in a new window) that performs compaction more efficiently. It returns a list of items (opens in a new window) that can be used in place of the previous input to continue the conversation while freeing up the context window. This list includes a special type=compaction item with an opaque encrypted_content item that preserves the model’s latent understanding of the original conversation. Now, Codex automatically uses this endpoint to compact the conversation when the auto_compact_limit (opens in a new window) is exceeded.
- icelancer 10mo agoTheir compaction endpoint is far and away the best in the industry. Claude's has to be dead last.
- kordlessagain 10mo agoYes, agree completely.
- nubg 10mo agoHelp me understand, how is a compaction endpoint not just a Prompt + json_dump of the message history? I would understand if the prompt was the secret sauce, but you make it sound like there is more to a compaction system than just a clever prompt?
- EnPissant 10mo agoMaybe it's a model fine tuned for compaction?
- FuckButtons 10mo agoThey could be operating in latent space entirely maybe? It seems plausible to me that you can just operate on the embedding of the conversation and treat it as an optimization / compression problem.
- postalcoder 10mo agoThe best part about this blog post is that none of it is a surprise – Codex CLI is open source. It's nice to be able to go through the internals without having to reverse engineer it. Their communication is exceptional, too. Eric Traut (of Pyright fame) is all over the issues and PRs. https://github.com/openai/codex https://github.com/openai/codex
- redox99 10mo agoFor some reason a lot of people are unaware that Claude Code is proprietary.
- causalmodels 10mo agoYeah this has always seemed very silly. It is trivial to use claude code to reverse engineer itself.
- mi_lk 10mo agolooks like it's trivial to you because I don't know how to
- n2d4 10mo agoIf you're curious to play around with it, you can use Clancy [1] which intercepts the network traffic of AI agents. Quite useful for figuring out what's actually being sent to Anthropic. [1] https://github.com/bazumo/clancy https://github.com/bazumo/clancy
- fragmede 10mo agoIf only there were some sort of artificial intelligence that could be asked about asking it to look at the minified source code of some application. Sometimes prompt engineering is too ridiculous a term for me to believe there's anything to it, other times it does seem there is something to knowing how to ask the AI juuuust the right questions.
- mohsen1 10mo agoTool call during thinking is something similar to this I am guessing. Deepseek has a paper on this. Or am I not understanding this right?
- I_am_tiberius 10mo agoPity it doesn't support other llms.
- evilduck 10mo agoIt does, it's just a bit annoying. I have this set up as a shell script (or you could make it an alias): codex --config model="gpt-oss-120b" --config model_provider=custom with ~/.codex/config.toml containing: [model_providers.custom] name = "Llama-swap Local Service" base_url = "http://localhost:8080/v1" http_headers = { "Authorization" = "Bearer sk-123456789" } wire_api = "chat" # Default model configuration model = "gpt-oss-120b" model_provider = "custom" https://developers.openai.com/codex/config-advanced#custom-model-providers https://developers.openai.com/codex/config-advanced#custom-m...
- daxfohl 10mo agoI like it but wonder why it seems so slow compared to the chatgpt web interface. I still find myself more productive copying and pasting from chat much of the time. You get virtually instant feedback, and it feels far more natural when you're tossing around ideas, seeing what different approaches look like, trying to understand the details, etc. Going back to codex feels like you're waiting a lot longer for it to do the wrong thing anyway, so the feedback cycle is way slower and more frustrating. Specifically I hate when I ask a question, and it goes and starts editing code, which is pretty frequent. That said, it's great when it works. I just hope that someday it'll be as easy and snappy to chat with as the web interface, but still able to perform local tasks.
- energy123 10mo agoxhigh reasoning effort for 5.2 Thinking is not available for ChatGPT Plus subscribers in the web interface.
- SafeDusk 10mo agoThese can also be observed through OTEL telemetries. I use headless codex exec a lot, but struggles with its built-in telemetry support, which is insufficient for debugging and optimization. Thus I made codex-plus (https://github.com/aperoc/codex-plus https://github.com/aperoc/codex-plus) for myself which provides a CLI entry point that mirrors the codex exec interface but is implemented on top of the TypeScript SDK (@openai/codex-sdk). It exports the full session log to a remote OpenTelemetry collector after each run which can then be debugged and optimized through codex-plus-log-viewer.
- fcoury 10mo agoThis looks pretty cool, nice UI too. Gonna take it for a spin.
- kordlessagain 10mo agoIf anyone cares to use Codex in a nice Docker container: https://github.com/DeepBlueDynamics/codex-container https://github.com/DeepBlueDynamics/codex-container
- albert_e 10mo agoOfftopic but -- The "Listen to article" media player at the top of the post -- was super quick to load on mobile but took two attempts and a page refresh to load on desktop. If I want to listen as well as read the article ... the media player scrolls out of view along with the article title as we scroll down ..leaving us with no way to control (pause/play) the audio if needed. There are no playback controls other than pause and speed selector. So we cannot seek or skip forward/backward if we miss a sentence. the time display on the media player is also minimal. Wish these were a more accessible standardized feature set available on demand and not limited by what the web designer of each site decides. I asked "Claude on Chrome" extension to fix the media player to the top. It took 2 attempts to get it right. (It was using Haiku by default -- may be a larger model was needed for this task). I think there is scope to create a standard library for such client side tweaks to web pages -- sort of like greasemonkey user scripts but at a slightly higher level of abstraction with natural language prompts.
- ltbarcly3 10mo agoCodex is extremely bad to the point it is almost useless. Claude Code is very effective. Opus is a solid model and claude very reliably solves problems and is generally efficient and doesn't get stuck in weird loops or go off in insane tangents too often. You can be very very efficient with claude code. Gemini-cli is quite good. If you set `--model gemini-3-pro-preview` it is quite usable, but the flash model is absolute trash. Overall gemini-3-pro-preview is 'smarter' than opus, but the tooling here is not as good as claude code so it tends to get stuck in loops, or think for 5 minutes, or do weird extreme stuff. When Gemini is on point it is very very good, but it is inconsistent and likely to mess up so much that it's not as productive to use as claude. Codex is trash. It is slow, tends to fail to solve problems, gets stuck in weird places, and sometimes has to puzzle on something simple for 15 minutes. The codex models are poor, and forcing the 5.2 model is expensive, and even then the tooling is incredibly bad and tends to just fail a lot. I check in to see if codex is any good from time to time and every time it is laughably bad compared to the other two.
- cactusplant7374 10mo agoI have the complete opposite experience. Claude Code is for building small demo apps. Like a 10 line Javascript example. Codex is for building GPU pipelines and emulators.
- doanbactam 10mo agoI completely agree. I use the Codex for complex, hard-to-handle problems and use OpenCode alongside other models for development tasks. The Codex handles things quite well, including how it handles hooks, memory, etc.
- gzalo 10mo agoWow, this part where they describe skills sounds quite odd https://github.com/openai/codex/blob/99f47d6e9a3546c14c43af99c7a58fa6bd130548/codex-rs/core/src/skills/render.rs#L20 https://github.com/openai/codex/blob/99f47d6e9a3546c14c43af9... Why wouldnt they just expose the files directly? Having the model ask for them as regular files sounds a bit odd
- mike_hearn 10mo agoThat's the whole point of skills - they help reduce context window usage by letting the model open only the ones that are relevant.
- gzalo 10mo agoI know, but part of the logic from below the line I linked could have been deterministic, it could benefit from a single "load skill" tool that just loads the files client side!
- rco8786 10mo agoThink of it as Just-In-Time context injection/enhancement
- ipotapov 10mo agoRegarding the user instruction aggregation process in the agent loop, I'm curious how you manage context retention in multi-turn interactions. Have you explored any techniques for dynamically adjusting the context based on the evolving user requirements?