Skip to content

feat(sdk)!: report worker spawn attempts and failures - #2607

Open
Aditya-linux wants to merge 1 commit into
openai:mainfrom
Aditya-linux:fix/956-worker-dispatch-timing
Open

Aditya-linux wants to merge 1 commit into
openai:mainfrom
Aditya-linux:fix/956-worker-dispatch-timing

Conversation

@Aditya-linux

@Aditya-linux Aditya-linux commented Nov 11, 2026 •

Copy link
Copy Markdown

Summary

SDK callers can observe live spawn_agent attempts and failures before persisted worker sessions appear. Addresses #956.

Changes

onWorkerEvent now includes runtime dispatch and failed variants. Both carry a scan-local attempt ordinal; failures reuse the corresponding attempt when its start was observed. A successful completion supplies the dispatch event when the stream omitted its start item.

The API deliberately does not infer a worker phase, planned worker count, or successful-worker count from runtime events. Existing { kind: "observed", worker } session notifications remain unchanged. The SDK guide and package-consumer fixture document the expanded union.

Testing

  • bun test --timeout 30000 ./tests-ts/worker-progress.test.ts - 15 passed
  • tsc --noEmit - passed
  • tsc -p tsconfig.ci.json - passed
  • Prettier checks for all changed SDK files - passed
  • SDK Markdown checks - passed

The broader api-events.test.ts file was attempted locally, but this checkout does not contain the generated _bundled_plugin fixture it requires. The added API regression cases remain enabled for PR CI.

Risk and rollout

This intentionally expands the public ScanWorkerEvent union and requires exhaustive consumers to handle two new variants, so the PR remains marked as breaking. Runtime events report only facts present in the parent stream. They do not replace persisted observed events and do not claim that a dispatched attempt successfully started.

Public disclosure review

  • No customer, partner, prospect, or user identities, data, or identifying details are included.
  • No credentials, personal data, private source, scan findings, or nonpublic links or tickets are included.
  • I reviewed the branch name, title, description, commits, changes, comments, logs, screenshots, attachments, and links for public disclosure.

@Aditya-linux
Aditya-linux force-pushed the fix/956-worker-dispatch-timing branch from 1df4e42 to 33985eb Compare November 11, 2026 18:07
@Aditya-linux Aditya-linux changed the title Expose runtime worker dispatch timing feat(sdk): expose runtime worker dispatch timing Nov 11, 2026
@github-actions github-actions Bot added the enhancement New feature or request label Nov 11, 2026
@mldangelo-oai mldangelo-oai changed the title feat(sdk): expose runtime worker dispatch timing feat(sdk): report worker dispatch timing Nov 13, 2026
@mldangelo-oai mldangelo-oai changed the title feat(sdk): report worker dispatch timing feat(sdk)!: report worker spawn attempts and failures Nov 13, 2026
@github-actions github-actions Bot added breaking-change Breaking change called out in generated release notes and removed enhancement New feature or request labels Nov 13, 2026
Emit onWorkerEvent dispatch and failed signals from live spawn_agent
tool calls so CI guards can see the delegated-work boundary without
relying on model-emitted status markers.

Fixes openai#956
@Aditya-linux
Aditya-linux force-pushed the fix/956-worker-dispatch-timing branch from 33985eb to dc60dea Compare November 15, 2026 07:39
@Aditya-linux

Copy link
Copy Markdown
Author

Updated in dc60dea5 to resolve the event-semantics concerns. Runtime events now expose only a stable scan-local attempt number; they no longer invent phase, planned work, or successful-worker counts. Successful completion recovers an omitted start event, and failures reuse the same attempt ordinal. The focused monitor suite is 15/15, TypeScript and CI compilation pass, and formatting/Markdown checks pass.

@mldangelo-oai mldangelo-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An unrelated MCP server can trigger the CI signal this PR adds. I replayed an mcp_tool_call from a synthetic inventory server with a tool named spawn_agent, followed by a native collab_tool_call. The MCP call emitted dispatch and failure for attempt 1. The first native call then received attempt 2. Both of the added API tests use MCP items, so they accept this false positive. Please restrict dispatch detection to the native item type and exact tool name, and keep an unrelated MCP call as a negative control.

There is also a concrete compatibility cost in the existing callback. A previously valid onWorkerEvent(event) { const worker: number = event.worker; } consumer fails with TS2339 at this head. Existing JavaScript consumers receive the new payloads with worker undefined.

I recommend using #2679 for best-effort notification. At 246da9d8, the same replay ignored the MCP call, numbered the native attempt 1, and sent it only to the opt-in spawn callback. The legacy consumer compiled. The two observer test files passed on both heads (59 here, 60 on #2679). Keep #956 open for the timing guarantee: the v2 runtime can omit the parent spawn item, and observer delivery cannot veto a worker start.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change Breaking change called out in generated release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants