Runtime-enforced event-driven agent orchestration: End parent turns after delegation and eliminate unnecessary inference
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 8/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- rust
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Rust
- スター
- 136k
- フォーク
- 21.6k
- 平均マージ
- 1分
- マージ済み PR(30日)
- 998
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
openai/codex のほかの issue
-
bug CLI performance
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
app bug
難易度 1/5 1時間未満 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
app bug skills windows-os
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
-
app-server bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
openai/codex#63732 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug CLI TUI
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
openai/codex#63725 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
area: cli good first issue type: feature
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
[Bug] Windows Ghidra provider rejects a PATH-only JDK: bare `java.exe` probe fails with Win32 87オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
renaming a provider to a taken name fails with a raw sql error対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンarea:storage kind:bug priority:p3 ready
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
bug bugfix
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
storytold/photocraft#16975 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信