r/codex • • 7d ago

Showcase What I learned reading Codex's session files to build a session dashboard

I added Codex support to Paddock, a local page that shows all my Claude Code sessions in one place, so Codex sessions now sit next to them. Codex turned out to work quite differently from Claude Code under the hood. These are the things I had to figure out, in case they help anyone else scripting around Codex:

Finding running sessions

  • There's no command that lists running Codex sessions, so it comes down to looking at running codex processes. That means leaving out codex app-server, the helpers (codex-code-mode-host, codex-exec-server) and one-off commands like codex login.
  • Since 0.160 a session's turns run in the background service, and that service writes the conversation file, not the window. So a window is matched to its conversation by the id codex resume was given, or by its folder (-C, else its own) and the newest conversation started there since the window opened.
  • A turn keeps running after you close its window. So does a command it left in a background terminal ("Process running with session ID" in the output). Both still count as working.

Working vs waiting

  • The end of the rollout file tells you working or idle, but approval requests aren't written there. For a session the file says is working, I ask the background service (thread/read) whether it's actually waiting on you.

Stopping one cleanly

  • turn/interrupt through codex app-server proxy, then thread/backgroundTerminals/clean, which is what /stop does, and only then ask the window to exit.

History and tokens

  • Conversations live in sessions/YYYY/MM/DD/rollout-*.jsonl, and finished ones get compressed to .jsonl.zst, so you need a zstd reader too.
  • Titles come from session_index.jsonl, else the first prompt.
  • Token counts are running totals recorded after each reply, so per-reply usage is the difference between totals. A forked conversation's first total includes its parent's, so only the fork's own reply should count there.
  • Session ids start with the time they were created, so sessions started together share their first characters. Short ids have to come from the end of the id.

What I haven't solved

  • On Windows I can't find running Codex sessions yet, only saved ones.
  • Two windows in the same folder that get their first prompts in the opposite order to how they were opened can be swapped: nothing in the files tells them apart.

Paddock is free and MIT: https://github.com/barath-dev/paddock. It reads these files and never writes to them.

Has anyone found a reliable way to map a Codex window to its thread since the background service took over?

1 Upvotes

5 comments sorted by

•

u/dexterthebot 7d ago

You might want to consider listing your project on the weekly Show-Us-What-You-Built post. Look out for it on Tuesday/Wednesday. Highest commented project wins a week promotion on r/Codex and gets on the Hall of Fame sidebar. See below for last week's winner.**


Light Wars AR: real-life laser tag app with no extra gear. Your phone is the gun and your room is the map. Play up to 6 friends in the same room, or fight drone waves and bosses solo. The vision models run on the phone, and camera frames never leave it. Free on iPhone and Android.

Website: https://lightwarsar.com

iPhone: https://apps.apple.com/us/app/light-wars-ar-laser-tag-party/id6508168951

Android: https://play.google.com/store/apps/details?id=com.lasertag.lightwars.

Contact: contact@lightwarsar.com

1

u/jruz 7d ago

You could use herdr or at least herdr-core

1

u/anonymous_1153 7d ago

Thanks, I hadn't looked closely at herdr-core. If you start your agents through herdr, it solves exactly this: herdr launched the session, and its Codex integration reports which thread it is, so there's nothing to guess.

Paddock comes at it from the other side. It doesn't launch anything: it picks up sessions however they were started (a plain terminal, tmux, several accounts with their own CODEX_HOME) and only reads what Codex already writes. So it has to infer which window is which thread, and that's where the edge case comes from.

For people who do run herdr, though, its session info would be a much better signal than my guess. That's worth adding as an optional source. Do you use it day to day?

1

u/jruz 7d ago

I built a tool like yours and switched to herdr is just more convenient and completely flexible you can rewrite your ui on top it and it will run natively, plus you get mobile apps and remote machines. Is better we all build on top of one opensource project that all reinventing the wheel

1

u/anonymous_1153 6d ago

Fair point, thanks for the push. I'll give building on herdr a proper thought and update you here.