Long-horizon multi-agent monitoring trap in 0.172.0: 3600s wait_agent cap, unhookable short functions.wait loops (62.1M tokens), and 60s polling prompt in gpt-6.2
What version of Codex CLI is running?
codex-cli 0.172.0 (x86_64-unknown-linux-musl)
What subscription do you have?
ChatGPT Pro (20x)
Which model were you using?
gpt-6.2-astra (xhigh parent), gpt-6.2-sol (high), gpt-6.1-terra (low/medium workers)
What platform is your computer?
Linux 6.8.0-134-generic x86_64 unknown
What terminal emulator and version are you using (if applicable)?
VS Code Remote-SSH + Linux CLI (code_mode + multi_agent_v2)
What issue are you seeing?
While running multi-hour monitoring and delegation trees on codex-cli 0.172.0, we audited an 80.15M-token (1,091-request) multi-agent session tree and observed four interacting runtime and prompt constraints that either burn tens of millions of tokens in empty polling loops or break real-time child alert preemption:
1. Asymmetry between multi_agent_v2.max_wait_timeout_ms (<= 3600000 ms) and code-mode functions.exec (43200000 ms+) silently blocks child failure alerts
- Code-mode
functions.exec/functions.waitsupports multi-houryield_time_ms(measured holding silently for21,601s/ 6h and43,200s/ 12h with zero intermediate inference, returning early in a few seconds when the child process exits). - However,
features.multi_agent_v2.max_wait_timeout_msis hard-capped at3600000ms (1 hour) inconfig.toml:Error loading configuration: features.multi_agent_v2.max_wait_timeout_ms must be at most 3600000 - Production failure mode: Because
wake_on_agent_messagesis disabled by default (under development/false), a parent agent that needs to react to background subagents must stay insidewait_agent. On 8–34 hour jobs,wait_agentrepeatedly times out every 30–60 minutes and re-meters the full frontier parent context. When asked by the user to stop repeating timeout/wait status cycles, thegpt-6.2-astraparent replacedwait_agentwith a 6h–12hfunctions.execpolling loop — which silently blocked urgent childsend_messagealerts for hours, because child mailbox messages wakewait_agentimmediately but do not preempt an active parentfunctions.exec/functions.waitcell. - Note on
wake_on_agent_messages(#54961 / #56330) in0.172.0: In an isolated localcodex app-server --listen stdio:// --enable multi_agent_v2 --enable wake_on_agent_messages --disable hookstest (gpt-6.1-terra, 8-second childfunctions.exechold), the parent cleanly ended Turn 1 afterspawn_agent, made0wait_agentcalls and0intermediate requests across a28.56sidle window, and automatically woke24 msafter child completion to emit a non-empty Turn 2 final response (2Turn 1 requests +1Turn 2 request). Graduatingwake_on_agent_messagesto stable/enabled-by-default would remove the need forwait_agentpolling altogether; until then, the 1hmax_wait_timeout_mscap traps multi-hour parents.
2. Unhookable short outer yield_time_ms + functions.wait loop burned 62,114,204 tokens in one worker (#38495, #57604, #59042)
- One worker watching for a pair of output files wrapped an inner
write_stdin(..., yield_time_ms: 300000)inside a short outer pragma (// @exec: {"yield_time_ms": 1000}), then calledfunctions.wait({"cell_id": ..., "yield_time_ms": 20000})852 consecutive times on unchanged empty state. - That single worker consumed
62,114,204tokens in empty wait turns (62,917,760cached input out of63,143,294total across869requests — 77.5% of the entire 5-agent tree). - Because neither
functions.waitnor emptywrite_stdinpolls firePreToolUsehooks (#59042) and there is no configurable minimumyield_time_msfloor (#57604), users cannot enforce a runtime guardrail when a worker omits a long outer// @execpragma.
3. gpt-6.2-astra and gpt-6.2-sol built-in instructions_template still explicitly nudges 60-second polling (#45974, #38495)
In 0.172.0 (models_cache.json), both gpt-6.2-astra and gpt-6.2-sol ship with:
"When the user asks you to wait or monitor through completion or if it's needed for a longer horizon task, you can sleep for as long as is required (generally 60 seconds by default) between checks."
On long-horizon tasks with 100k–300k context windows, a 60-second check cadence drives hundreds of redundant full-context model turns even when an external deterministic observer is already watching the target.
4. Streaming --follow observers only wake functions.exec on process exit (#29922, #32188)
Because an active subprocess inside functions.exec does not return early when a new stdout JSONL line arrives, any streaming --follow observer must implement a custom exit-on-event protocol and remount after every single actionable line. Even a 30-minute safety heartbeat inside the watcher still generated 21 empty waits + 21 status checks (4.32M tokens over ~10h).
What steps can reproduce the bug?
- 1-hour
wait_agentcap: Setfeatures.multi_agent_v2.max_wait_timeout_ms = 43200000in~/.codex/config.tomland runcodex features list-> fails immediately withfeatures.multi_agent_v2.max_wait_timeout_ms must be at most 3600000. - Parent
functions.execblocks childsend_message: Have a parent session spawn a child, then callfunctions.exec({yield_time_ms: 60000})runningsleep 30. Have the child callsend_messageto/rootatT+5s->send_messagedoes not preempt the parentfunctions.execcell, whereas it wakeswait_agentimmediately. - Unhookable short outer
functions.waitloop: Inside code mode, start a long silent command with// @exec: {"yield_time_ms": 1000}and innerwrite_stdin(..., yield_time_ms: 300000). Once the cell returnsScript running with cell ID ..., callfunctions.wait({cell_id, yield_time_ms: 20000})->PreToolUsenever seesfunctions.wait, and each 20s empty yield triggers a full-context model request.
What is the expected behavior?
Concrete asks for @openai/codex-core-agent-team:
- Raise or remove the
3600000ms cap onmulti_agent_v2.max_wait_timeout_ms(e.g., allow multi-hourwait_agentwaits or anuntil_eventwait mode matchingfunctions.exec), and graduatewake_on_agent_messages(#54961 / #56330) to stable so delegating parents can go idle at zero inference cost and resume reliably on child messages/completion. - Support configurable minimum yield floors (
min_exec_yield_time_ms/min_empty_poll_yield_time_ms, #57604) or keep emptyfunctions.wait/write_stdincontinuations inside the runtime (#38495) until output, process exit, or user preemption occurs. - Revise the
(generally 60 seconds by default) between checksinstruction ingpt-6.2-*model templates so models prefer event-driven blocking / exit-on-event waits over 60s model-turn polling. - Add native background line/exit wakeup (
monitor/ wake-on-exit, #29922 / #32188) so--followtools do not require exit-per-event wrappers.
Additional information
Related open issues covering individual slices of this problem: #38495, #15723, #46120, #63464, #57604, #59042, #45974, #29922, #32188.
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
- #63464
Powered by Codex Action
Thanks for the automated pointer to #63464 — we reviewed it carefully (and noted #63464 in our related-issues footer when filing). These two issues are complementary rather than duplicates, so we are keeping #64090 open:
- #63464 is an enhancement proposal for a new runtime-enforced batch-delegation-and-yield tool (
dispatch_batch) that deterministically terminates the parent turn upon delegation on top of existing native wake-up/wait primitives (explicitly noting it does not classify current timeout behavior as a bug). - #64090 reports four reproducible
codex-cli 0.172.0runtime and prompt bugs/gaps measured on long-horizon multi-agent trees:features.multi_agent_v2.max_wait_timeout_mshard schema cap at3600000ms (1h) vs43200000ms (12h) onfunctions.exec, plus the fact that a parentfunctions.execwait blocks urgent childsend_messagepreemption. (Additional0.172.0test datapoint: we also verified in an isolatedstdio://probe thatfeatures.wake_on_agent_messages = truewakes an idle Normal-mode root session on both mid-run non-final childsend_messageand final child completion — however, automatic wakes remainunder development/off by default and are intentionally disabled in Plan mode, after user interrupts, and inside child agents, wherewait_agentand its3600000ms cap still govern.)- Unhookable short outer
yield_time_ms+functions.waitpolling loops (62.1Mtokens across852empty 20s polls in one worker), sincePreToolUsehooks do not observefunctions.wait(#59042) and there is no configurable minimum yield floor (#57604). - Built-in
instructions_template(generally 60 seconds by default) between checksnudging 60-second model-turn polling on 100k–300k context windows (#45974). - Process-exit-only wakeup in
functions.execrequiring custom exit-per-event wrappers for--followobservers (#29922 / #32188).
Excellent analysis, and thanks for referencing #63464.
Your measurements independently highlight the scale of the architectural problem. Spending 62.1M tokens on empty polling cycles in a single worker is particularly striking.
Your wake_on_agent_messages experiment also aligns with my findings. The native wake-up mechanism works. What remains missing is a deterministic runtime guarantee that the delegating parent actually completes its turn without requiring another model decision.
My modified Codex core addresses that specific part of the lifecycle through an explicit delegation-and-yield operation.
The implementation has now passed 30 validation scenarios, including a native child failure after partial, uncommitted code modifications, with correct child correlation, a single parent wake-up and preservation of the actual Git worktree state.
I fully agree that these issues are complementary. Your findings on functions.wait, minimum yield floors and child-message preemption address additional runtime gaps that my current implementation does not attempt to solve.
Together, these findings make a strong case for moving deterministic coordination out of model inference and into the runtime.
Intelligence should be used for decisions, not polling.
Thanks for the automated pointer to #63464 — we reviewed it carefully (and noted #63464 in our related-issues footer when filing). These two issues are complementary rather than duplicates, so we are keeping #64090 open: