Expose runtime worker dispatch timing for CI budget guards
Summary
CI integrations need to know when delegated review is actually dispatched so they can enforce a pre-review time or cost guard. Model-emitted status markers and later session observations do not reliably identify that boundary.
Current status
#962 added onWorkerEvent and clarified that onWorkerStatus dispatch messages are best effort. The current callback documentation also explains the limits of observed worker sessions: they can arrive after a worker starts and do not provide a planned dispatch count or a pre-dispatch gate.
This issue remains open for the timing requirement. It no longer assumes that the SDK promises deterministic delivery through onWorkerStatus itself.
Original reproduction
Reported with @openai/codex-security 0.1.28, plugin producer 0.1.95, Node 24 on GitHub Actions Linux, and a Standard committed-diff scan using gpt-5.6-sol / low effort.
const workerStatuses = [];
const progress = [];
const result = await security.run(repository, {
target: DiffTarget.refs({ base, head }),
outputDir,
onWorkerStatus(status) {
workerStatuses.push(status);
},
onProgress(update) {
progress.push(update);
},
});
Preflight emitted:
{"kind":"preflight","delegation":"available","configuredSlots":null}
The scan completed with sealed artifacts and reported two delegated batches plus parent consistency review, but workerStatuses contained no kind: "dispatch" event. The original dispatch parser depended on a marker in an agent_message; missing or malformed model text could therefore omit a real dispatch.
Remaining requirement
- Provide a supported runtime-derived signal at the actual delegated-work boundary, with whatever phase and planned/started counts the runtime can establish.
- Make failure to start workers observable, rather than interpreting missing text markers as zero work.
- State the ordering/latency guarantees so CI callers know whether the signal is suitable for a pre-review guard.
- Keep late worker-session observations distinct from scheduler/dispatch events.
The reported integration currently uses a less precise first-completed-file fallback. Raw session transcripts are not an appropriate general control-plane interface. A regression should exercise real delegation without a model status marker and verify the promised event timing/counts.
#962 added onWorkerEvent, which reports worker sessions without relying on model-written status markers. Those notifications can arrive late, so they don’t reliably identify when file review starts. Does that callback help with your integration, or do you still need the timing signal for your CI guard? Leaving this open for now.
@mldangelo-oai thanks for getting back to me!
On my use case the idea is to time-bound the preflight steps (like threat modelling) so as to avoid spending too much time and too many tokens on preflight steps if a PR being reviewed is too large or too complex. For that to work we need something near real-time. What is the expected arrival delay here ? Is it a few seconds or can be more ?
There’s no reliable upper bound I can give you for the current callback. In a test with one accepted worker and one rejected spawn, the v2 runtime only reported the accepted worker after its session appeared. It never delivered either dispatch event. The v1 path in #2607 did report both attempts and the rejection. The scan also continued while the callback’s promise was pending.
For the preflight budget you described, would a signal that file review has already started be enough to stop your timer, or does your integration need the chance to stop the scan before the first worker starts? That distinction affects what we need to expose.
Thanks, that distinction helps. We do not need a pre-dispatch veto or an opportunity to stop the scan before the first worker starts.
Our integration independently monitors elapsed time and SDK-reported cost and aborts through AbortSignal if the pre-review allowance is exceeded. We only need a reliable signal to stop applying that startup allowance once actual file review has begun.
The minimum useful contract would be:
- emitted when the first
file_reviewworker is accepted/started, not merely whenspawn_agentis attempted; - phase-qualified, because a generic dispatch could belong to ranking, threat modelling, validation, or another phase;
- delivered with bounded latency or ordering—ideally before subsequent worker activity/cost is reported.
We do not require planned-worker counts. A failed/rejected spawn should not release the guard; a corresponding failure event would still be useful diagnostically.
Therefore, the dispatch/failed events proposed in #2607 are directionally useful, but { kind: "dispatch", attempt } at tool-call start alone would not be safe for our boundary because it has no phase and the attempt may subsequently fail. A runtime-derived “accepted/started file-review worker” event would fully address our use case.
Issue #956 and the v2 worker-start signal
I traced this on rust-v0.172.0 (3d86e43). Once a v2 spawn succeeds, core emits a SubAgentActivity item with kind: Started and the child thread ID. The app-server payload carries that ID as agentThreadId. It has no Codex Security scan-phase field. Spawn handler · App-server item
The TypeScript SDK starts exec --experimental-json. Both the started and completed notifications go through the same item mapper in exec. SubAgentActivity falls through to None, so the start item and its child ID never enter that JSONL stream. In an offline replay, the pinned JavaScript adapter preserved the fields when supplied on synthetic JSONL. Codex Security’s phase callback still depended on a model-written marker. SDK launcher · Exec mapper · Notification handlers
For the CI budget guard in #956, could we forward the accepted v2 start on the SDK stream and associate it with an explicit scan phase? The guard needs one signal for the first accepted file_review worker and a documented ordering relative to later worker activity and cost. A rejected spawn and an earlier ranking worker should leave the guard active. This can complement #2607’s attempt and failure events. Issue #956 · PR #2607
Verification was a pinned release source trace and offline synthetic adapter replay. Live worker timing was outside scope.