Skip to main content

Module codex_fresh

Module codex_fresh 

Source
Expand description

Agents fresh for a Codex or Gemini pane (docs/specs/SPEC_AGENT_SELF_COMPACTION_2026_10_23.md §3.3).

A Codex pane runs one codex exec per turn and resumes its thread by id, and a Gemini pane one gemini -p per turn that resumes with -r <id> only when there is an id: so ending the thread is forgetting the id, and the next turn starts a new one. Three places hold the id, and all three must let go in one step:

  • the controller’s session_id (cleared here, under inner);
  • the block’s agent:sessionid meta (cleared right after; a message built from the meta in between, or one already queued behind a turn, can still carry the old id, so the id is also retired: hydrate_session_id_from_config refuses it);
  • the queue itself: a queued message makes the pane busy, so it refuses.

The idle test and the clearing are one inner acquisition, so a message either started its turn first (refused; the caller waits and tries again) or finds no thread to resume. The old thread stays in $CODEX_HOME and in AgentMux’s record (Agents search_history).