Runtime-enforced event-driven agent orchestration: End parent turns after delegation and eliminate unnecessary inference
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 8/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- rust
- Área
- ai-infra-agents
Línea de trabajo
This is a design proposal for an opt-in event-driven mode in the Rust core. Start with codex-rs/core/src/tools/handlers/multi_agents_v2/wait.rs, which the issue links, to see how wait timeouts return control to the model. Then check how subagent completion events wake a parent turn. Done would need agreed semantics for the delegate-and-yield operation and turn completion, which the thread has not settled.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
What variant of Codex are you using?
26.1117.41037
What feature would you like to see?
Summary
Codex should support a runtime-enforced, event-driven orchestration mode in which a parent agent can delegate work, deterministically complete its current turn, and remain idle until a relevant event requires further reasoning.
Currently, a parent agent can repeatedly invoke wait tools, poll subagent status, and trigger additional model inference without receiving any new information relevant to its task.
For long-running, multi-agent engineering workflows, this creates unnecessary inference, repeated context processing, usage consumption, and orchestration overhead.
This should not depend on the model's ability to follow orchestration instructions. It should be an enforceable property of the runtime.
I have implemented and successfully tested a working proof of concept by modifying the Codex Rust core and running it within the regular Windows Codex Desktop application.
Problem
I use Codex Desktop as part of CapaLynx, a multi-agent engineering system with dedicated orchestration, architecture, implementation, and quality assurance roles.
My orchestrators delegate work to native Codex subagents as well as externally executed CLI agents through native runner agents.
Despite explicit orchestration instructions, parent agents can continue to perform actions after successful delegation:
- Repeatedly invoke
collaboration.wait_agent. - Request shorter waiting periods than defined by the orchestration contract.
- Poll subagent status through
list_agents. - Inspect external worker status and output files.
- Trigger additional inference without receiving new actionable information.
The fundamental problem is not that a blocking wait itself consumes tokens. It is that a technical timeout returns control to the model, potentially triggering another inference request with a substantial conversation context.
A parent agent that has delegated all remaining work has no reason to perform additional inference until something relevant changes.
Increasing the wait timeout reduces the frequency of this behavior but does not eliminate it. Prompt instructions are also insufficient because they remain subject to model interpretation.
Evidence from a real engineering workflow
During a production engineering workflow on November 22, 2026, my orchestration contract specified a ten-minute waiting period.
The parent agent nevertheless explicitly requested nine 60-second waits.
Observed execution metrics:
- Requested 60-second waits: 9
- Timer expirations without a relevant event: 6
- Subsequent parent model requests: 6
- Additional wait calls: 4
- Additional status queries: 2
- Total input tokens across those six requests: 806,401
- Cached input tokens: 804,608
- Output tokens: 390
All six subsequent model requests resulted in either another wait or a status query.
The parent received no new actionable subagent event from those six timer expirations.
These figures represent observed token usage from one real workflow, not an estimate. I am not claiming that cached and uncached tokens have identical economic costs or that these figures establish an exact monetary saving.
However, the six additional inference requests demonstrate a concrete opportunity to eliminate redundant orchestration work.
Why this belongs in the runtime
The underlying architectural principle is straightforward:
The model should decide what to delegate. The runtime should enforce the delegation lifecycle.
An agent's decision to delegate work and the technical lifecycle of that delegation are separate concerns.
Relying on the model to repeatedly decide whether it should continue waiting introduces unnecessary nondeterminism into an otherwise deterministic coordination problem.
Once delegation has been successfully completed, the runtime already has the information necessary to determine whether the parent should remain idle or resume execution.
A technical timer expiration is not necessarily a meaningful orchestration event.
Proposed feature
Introduce an optional, project-level or thread-level event-driven orchestration mode.
The mode should support an explicit delegation-and-yield operation, allowing an orchestrator to start or resume one or multiple subagents and complete its current turn as part of the same runtime-controlled operation.
The desired lifecycle is:
- The parent agent prepares the next group of delegated tasks.
- The runtime starts or resumes the corresponding subagents.
- The runtime registers the successfully delegated work and the corresponding parent-child relationships.
- Following a successful handoff, the runtime completes the parent turn.
- Subagents continue executing independently.
- The parent remains idle without further inference or polling.
- A relevant event triggers a new parent turn.
Relevant wake-up events should include:
- A message or clarification request from a subagent.
- Successful subagent completion.
- Subagent failure or cancellation.
- Completion or failure of an external job managed through a native runner.
- New user input or an explicit status request.
- User-initiated interruption or cancellation.
Internal timer maintenance should not require another model request unless the timeout itself represents an actionable event, such as an explicitly configured task deadline.
Runtime guarantees
The proposed mode should provide the following guarantees:
- No further parent inference within the completed delegation turn.
- No further tool execution from that turn after successful handoff, including additional tool calls emitted in the same model response.
- No parent-side polling solely to discover whether a registered child has completed.
- Prompt event delivery without an artificial minimum waiting period.
- Reliable registration of child identities before the parent turn completes.
- Correct handling of events arriving at the turn-completion boundary.
- Explicit reporting of partially successful batch delegations, including the identities of children already started.
- Preservation of user interruption and cancellation semantics.
- Defined recovery and event-delivery behavior when sessions or the app-server are resumed.
This should be an opt-in capability rather than a breaking change to existing subagent workflows. Agents that need to perform productive work concurrently with their children should remain able to do so.
Working proof of concept
I have implemented this architecture locally using a modified Codex Rust core.
The regular Windows Store Desktop application remains unchanged. It communicates with my locally built, version-qualified core.
My implementation introduces a project-specific batch delegation tool:
capalynx_delivery.dispatch_batch
In designated orchestration threads, this tool replaces individual native agent start and resume operations.
After successful delegation, the core:
- Registers the delegated work and its parent-child relationships.
- Completes the parent turn deterministically.
- Prevents further tool execution from the completed turn.
- Prevents additional model inference within that turn.
- Allows child agents to continue independently.
- Uses the native event inbox and
wake_on_agent_messagesfunctionality to resume the parent when a relevant event arrives.
If only part of a delegation batch succeeds, the parent receives the successful child registrations and failure information instead of being forced to terminate its turn. This avoids blindly duplicating already running work.
The implementation does not depend on the model voluntarily complying with a prompt-based waiting policy.
Validation and measured results
The modified core was validated through 29 native test scenarios, including:
- Multiple subagents.
- Partial delegation failures.
- Additional tool calls emitted in the same model response.
- User STOP behavior.
- Cold session resumption.
- Project and thread eligibility checks.
I also conducted a controlled comparison using the original, unmodified Codex core and subsequently validated the implementation with two actual Codex Desktop orchestrators.
Desktop end-to-end results
Implementation orchestrator:
- Further parent tool calls after handoff and before child completion: 0
- Further parent model requests during that interval: 0
- New parent turns triggered by the observed child completion: 1
- Child completion to new parent turn initiation: 59 ms
Specification orchestrator:
- Further parent tool calls after handoff and before child completion: 0
- Further parent model requests during that interval: 0
- New parent turns triggered by the observed child completion: 1
- Child completion to new parent turn initiation: 112 ms
The implementation orchestrator delegated a real shell task to a native runner.
The specification orchestrator delegated work to a restricted external Codex CLI author through WSL, supervised by a native runner.
Both completed successfully in the regular Desktop environment.
The latency measurements represent the time between the recorded native child completion event and initiation of the new parent turn, not the time required to generate a complete model response.
These two measurements establish end-to-end feasibility on the tested build. They are not intended as general latency benchmarks or scalability guarantees.
Reproduction with the unmodified Codex core
Environment
- Platform: Windows x64
- Codex Desktop Store package:
26.1117.4957.0 - Core version:
rust-v0.171.0-alpha.13 - Multi-Agent v2 enabled
- Upstream revision:
581161ab41e643d942e1e1b5f561034060bf18e3
Scenario A: Timeout-driven inference
- Start a parent agent and a native subagent.
- Keep the child running without producing messages or completing.
- Invoke
collaboration.wait_agentwithtimeout_ms = 60000, using a configuration that permits this timeout. - Allow the timer to expire without any relevant child or user event.
- Observe the tool result and subsequent parent model request.
Current behavior: The technical timeout can trigger another model inference request despite the absence of new actionable information.
Desired behavior in event-driven mode: The parent remains idle until a meaningful event or an explicitly configured actionable deadline occurs.
Scenario B: Continued execution after delegation
- Start the original app-server with agent wake-up notifications enabled.
- Create a parent thread and start a native subagent.
- Keep the child running.
- Use a controlled test provider to request
list_agentsin the next model response of the same parent turn. - Observe tool execution, model requests, and turn-completion events.
Current behavior: The original core permits additional parent actions within the same turn after successful delegation. My controlled comparison reproduced this behavior.
Desired behavior when using an explicit delegation-and-yield operation: The runtime completes the parent turn immediately after successful delegation and registration. No further tools or inference execute within that turn.
A subsequent relevant child event initiates a new parent turn.
The existing wait behavior is consistent with the current implementation. This request therefore proposes an additional orchestration capability rather than classifying the documented timeout behavior itself as a bug.
Relevant upstream implementation:
Observability
An additional improvement would be structured runtime telemetry for delegation, waiting, and wake-up events.
Useful information would include:
- Parent thread and turn identifiers.
- Registered child identifiers.
- Delegation and turn-completion timestamps.
- Requested and effective wait timeouts.
- Actual wake-up reason.
- Correlation between the wake-up event and subsequent inference request.
This would allow developers to distinguish productive inference from timer-driven orchestration overhead and independently validate runtime behavior.
Benefits
For users:
- Reduced unnecessary usage consumption.
- More predictable orchestration behavior.
- Less dependence on model-specific instruction-following capabilities.
- More reliable long-running agent workflows.
- Improved observability and troubleshooting.
For OpenAI:
- Fewer unnecessary inference requests.
- Less repeated context processing.
- Potentially more efficient inference infrastructure utilization.
- A stronger runtime foundation for enterprise-grade multi-agent systems.
- Improved support for complex orchestration workloads without relying on increasingly elaborate prompt instructions.
The benefits should become particularly relevant as agentic systems scale to larger numbers of concurrent workers, longer execution times, and more complex orchestration hierarchies.
Why upstream support matters
My local implementation demonstrates that this architecture is feasible within the existing Codex ecosystem.
However, maintaining a modified core requires compatibility validation, rebuilding, testing, and qualification for each new Desktop package version.
My implementation is intentionally version-bound and includes a tested rollback mechanism. It is currently qualified only for the specified Windows environment.
This is not a sustainable integration model for users who need reliable, long-running agent orchestration across regular Codex updates.
A first-class upstream capability would eliminate the need for maintaining a custom runtime while making the same efficiency improvements available to other Codex users.
I can provide additional implementation details, sanitized execution traces, reproduction artifacts, and information about the core patch if useful to the Codex engineering team.
Related issue
Related to #61901 — Support automatic parent wake-up for create_thread assignments.
The two requests address complementary parts of the agent orchestration lifecycle:
- #61901 addresses how and when the parent receives events and wakes up.
- This request addresses how and when the parent deterministically completes its turn after delegation.
Reliable event delivery and deterministic turn completion together provide the foundation for genuinely event-driven agent orchestration.
Closing thought
Agentic systems should reason when there is something to reason about.
Waiting for delegated work is a runtime responsibility, not a reasoning task.
Intelligence should be used for decisions, not polling.
Additional information
No response
- Lenguaje dominante
- Rust
- Estrellas
- 136k
- Forks
- 21.6k
- Merge medio
- 1 min
- PR fusionados (30 d)
- 998
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de openai/codex
-
bug CLI performance
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
app bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
Windows data plugin feedbackAbiertoapp bug skills windows-os
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
-
app-server bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
openai/codex#63732 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug CLI TUI
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
openai/codex#63725 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de openai/codex
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
qingjian-team/qingjian#1181 ·
Los mantenedores suelen responder en 2 días
-
bug P2: medium
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
leepokai/Codync#618 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
oxidecomputer/opte#1125 ·
Los mantenedores suelen responder en 2 días
-
[Bug] StreamLifecycleConfig clamps post-TTFT stream timeouts to remaining admission budgetPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
lbjlaq/Antigravity-Manager#4063 ·
Los mantenedores suelen responder en 1 día