codex icon indicating copy to clipboard operation
codex copied to clipboard

[codex] Run async hooks and deliver output on accepted requests

Open abhinav-oai opened this issue 5 months ago • 0 comments

Stack 2/3: #27771 → this PR → #27772

Purpose

#27771 provides the bounded runtime and informational parser, but async hook declarations remain disabled. This PR activates them and connects completed output to accepted model requests.

The central invariant is that an async hook may inform a later request, but it can never alter the operation that launched it.

Behavior

Synchronous hooks retain their existing behavior. Async handlers run in the background without emitting HookStarted or HookCompleted, and any blocking, steering, or input-mutation fields in their output are ignored.

Ready output is snapshotted before synchronous UserPromptSubmit hooks run. Delivery advances only after at least one input is accepted, which means:

  • output that finishes during prompt-hook execution waits for the following accepted request;
  • rejected input does not consume queued output;
  • an accepted steer can receive eligible output; and
  • SessionStart and SubagentStart output always skips the first accepted request.

The runtime survives hook configuration refreshes so in-flight commands and queued output are preserved. Session shutdown aborts and joins detached commands.

Deferred additionalContext is recorded in model-visible history. Deferred systemMessage values are shown to the user without entering model context. Idle threads are not woken solely to deliver hook output.

abhinav-oai avatar Jun 10 '26 20:06 abhinav-oai