The 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
Unrolling the Codex agent loop
61–70 of 220 posts
Re: Unrolling the Codex agent loop
#62The 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
Re: Unrolling the Codex agent loop
#63Re: Unrolling the Codex agent loop
#64One 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…
Re: Unrolling the Codex agent loop
#65One 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…
I don't think this is true. I'm pretty sure that Codex uses reasoning.encrypted_content=true and store=false with the responses API. reasoning.encrypted_content=true - The server will return all the reasoning tokens in an encrypted blob you can pass along in the next call. Only OpenaAI can decrypt them. store=false - The server will not persist anything about the conversation on the server. Any subsequent calls must…
I would see my context window jump in size, after each user turn (i.e. from 70 to 85% remaining).
Built a tool to analyze the requests, and sure enough the reasoning tokens were removed from past responses (but only between user turns). Here are the two relevant PRs [0][1].
When trying to get to the bottom of it, someone from OAI reached out and said this was expected and a limitation of the Responses API (interesting sidenote: Codex uses the Responses API, but passes the full context with every request).
This is the relevant part of the docs[2]:
> In turn 2, any reasoning items from turn 1 are ignored and removed, since the model does not reuse reasoning items from previous turns.
[0]https://github.com/openai/codex/pull/5857
[1]https://github.com/openai/codex/pull/5986
[2]https://cookbook.openai.com/examples/responses_api/reasoning...
Re: Unrolling the Codex agent loop
#66The 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
For some reason a lot of people are unaware that Claude Code is proprietary.
Re: Unrolling the Codex agent loop
#67What 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 [1] https://github.com/openai/codex/issues/3585
Re: Unrolling the Codex agent loop
#68The 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
For some reason a lot of people are unaware that Claude Code is proprietary.
Re: Unrolling the Codex agent loop
#69Earlier quoted context omitted.
I don't think this is true. I'm pretty sure that Codex uses reasoning.encrypted_content=true and store=false with the responses API. reasoning.encrypted_content=true - The server will return all the reasoning tokens in an encrypted blob you can pass along in the next call. Only OpenaAI can decrypt them. store=false - The server will not persist anything about the conversation on the server. Any subsequent calls must…
Maybe it's changed, but this is certainly how it was back in November. I would see my context window jump in size, after each user turn (i.e. from 70 to 85% remaining). Built a tool to analyze the requests, and sure enough the reasoning tokens were removed from past responses (but only between user turns). Here are the two relevant PRs [0][1]. When trying to get to the bottom of it, someone from OAI reached out and s…
I wonder why the second PR you linked was made then. Maybe the documentation is outdated? Or maybe it's just to let the server be in complete control of what gets dropped and when, like it is when you are using responses statefully? This can be because it has changed or they may want to change it in the future. Also, codex uses a different endpoint than the API, so maybe there are some other differences?
Also, this would mean that the tail of the KV cache that contains each new turn must be thrown away when the next turn starts. But I guess that's not a very big deal, as it only happens once for each turn.
EDIT:
This contradicts the caching documentation: https://developers.openai.com/blog/responses-api/
Specifically:
> And here’s where reasoning models really shine: Responses preserves the model’s reasoning state across those turns. In Chat Completions, reasoning is dropped between calls, like the detective forgetting the clues every time they leave the room. Responses keeps the notebook open; step‑by‑step thought processes actually survive into the next turn. That shows up in benchmarks (TAUBench +5%) and in more efficient cache utilization and latency.
Re: Unrolling the Codex agent loop
#70Pity it doesn't support other llms.
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-m...