Repository navigation
Conversation
Await HTTP response preparation once per accepted SDK Responses attempt, then consume the existing stream in recovery without a forwarding generator.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: passed. What this changesThis PR prepares each SDK Responses attempt once before consuming its events, removing a forwarding generator from long streams. Example: A synthetic Responses reply streams 3,600 reasoning, text, and tool-argument deltas.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR provides a focused allocation improvement with no actionable correctness findings, preserved lifecycle boundaries, and passing exact-head CI. Reviewed head: Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe AI transport layer converts provider Responses events into assistant events; response preparation gates readiness, while the existing recovery loop retains retry sequencing and stream cleanup. flowchart TD
A[Agent model call] --> B[Managed or shared Responses adapter]
B --> C[SDK request and recovery owner]
C --> D[Response hook and readiness]
D --> E[Provider event stream]
E --> F[Responses reducer]
F --> G[Assistant events and diagnostics]
Technical reviewBest possible solution: Keep preparation shared and once per accepted attempt, with event consumption, cleanup, and retries owned by the existing recovery loop. Do we have a high-confidence way to reproduce the issue? Source confirms that fetched main forwards every SDK Responses event through the response-hook generator; the reported allocation measurements were not rerun during this read-only review. Is this the best way to solve the issue? The patch removes recurring forwarding work at its existing owner while retaining one preparation implementation for both optimized callers and sibling transports. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ec90f8b46052. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +8, Tests +95, Other +41. Total +144 across 7 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 28, 2026, 9:20 PM ET / November 29, 2026, 02:20 UTC. |
|
Merged via squash.
|
…line * commit 'c876514dc21154a07f3755320495d2a93584b46b': (538 commits) perf(agents): reuse prepared tool catalog executors (#207900) fix: show the Gateway command default beside host rules in Devices (#207887) fix: verify chat Stop recovery after dashboard pairing (#207888) test(activity): check midnight refresh against the elapsed window (#207859) test(ui): use one persisted message ID in queued-image handoff (#207861) test(agents): release configured MCP fixture resources (#207716) fix(workboard): clear CI failures in the session filter editor (#207858) perf(ai): reduce allocation in OpenAI Responses streams (#207889) chore: stop the Workboard resident-owner CLI test from failing on main (#207898) test(agents): isolate endpoint-based overflow classification (#207688) chore(doctor): record why the root defaultModel migration stays (#207890) refactor(infra): simplify audit recovery write progress (#157141) fix: show restart blockers in service logs (#207879) test(infra): exercise group identity in session roundtrip (#207671) test(infra): exercise live owner expiry policy (#207672) feat: let Knowledge learn from your Gmail through Composio (#207266) test: stop the history-worker overload test from failing CI on slow runners (#207862) test(auth): assert SecretRef plaintext is absent from storage (#207698) chore(doctor): hold expired doctor migrations as removal-pending (#207865) fix: show ended one-time automations in History (#201280) ...
* commit '2194d14488091e2047d2f87ebbb093212f30840e': (540 commits) fix: stop reporting a child worker as finished when the Gateway loses contact (#207713) fix: keep the Activity visibility test stable at midnight (#207847) perf(agents): reuse prepared tool catalog executors (#207900) fix: show the Gateway command default beside host rules in Devices (#207887) fix: verify chat Stop recovery after dashboard pairing (#207888) test(activity): check midnight refresh against the elapsed window (#207859) test(ui): use one persisted message ID in queued-image handoff (#207861) test(agents): release configured MCP fixture resources (#207716) fix(workboard): clear CI failures in the session filter editor (#207858) perf(ai): reduce allocation in OpenAI Responses streams (#207889) chore: stop the Workboard resident-owner CLI test from failing on main (#207898) test(agents): isolate endpoint-based overflow classification (#207688) chore(doctor): record why the root defaultModel migration stays (#207890) refactor(infra): simplify audit recovery write progress (#157141) fix: show restart blockers in service logs (#207879) test(infra): exercise group identity in session roundtrip (#207671) test(infra): exercise live owner expiry policy (#207672) feat: let Knowledge learn from your Gmail through Composio (#207266) test: stop the history-worker overload test from failing CI on slow runners (#207862) test(auth): assert SecretRef plaintext is absent from storage (#207698) ...
…seline * commit '32403124cae2ccbcfc556e844b218682b133956e': (547 commits) perf(gateway): skip session display preparation for transcript recall (#207916) test(agents): verify complete bracketed paste payload (#207733) test: stop timing out the cron recovery settlement test on slow runners (#207920) fix: show when worktree cleanup stopped or will retry (#207883) fix: show approval destinations only when the forwarding mode uses them (#207885) fix: keep inherited tools when changing agent settings (#207884) feat: let Knowledge add someone's email or other alias to a page without rewriting it (#207881) fix: stop reporting a child worker as finished when the Gateway loses contact (#207713) fix: keep the Activity visibility test stable at midnight (#207847) perf(agents): reuse prepared tool catalog executors (#207900) fix: show the Gateway command default beside host rules in Devices (#207887) fix: verify chat Stop recovery after dashboard pairing (#207888) test(activity): check midnight refresh against the elapsed window (#207859) test(ui): use one persisted message ID in queued-image handoff (#207861) test(agents): release configured MCP fixture resources (#207716) fix(workboard): clear CI failures in the session filter editor (#207858) perf(ai): reduce allocation in OpenAI Responses streams (#207889) chore: stop the Workboard resident-owner CLI test from failing on main (#207898) test(agents): isolate endpoint-based overflow classification (#207688) chore(doctor): record why the root defaultModel migration stays (#207890) ...
…eline * commit 'eee1e0553d29456424ac367008c3cf080f9866ec': (550 commits) fix(acp): deliver bound channel replies to the pending question (#207035) fix(cron): keep required reports from going silent when nothing changes (#207044) test(sessions): assert participant queue rollback state (#207891) perf(gateway): skip session display preparation for transcript recall (#207916) test(agents): verify complete bracketed paste payload (#207733) test: stop timing out the cron recovery settlement test on slow runners (#207920) fix: show when worktree cleanup stopped or will retry (#207883) fix: show approval destinations only when the forwarding mode uses them (#207885) fix: keep inherited tools when changing agent settings (#207884) feat: let Knowledge add someone's email or other alias to a page without rewriting it (#207881) fix: stop reporting a child worker as finished when the Gateway loses contact (#207713) fix: keep the Activity visibility test stable at midnight (#207847) perf(agents): reuse prepared tool catalog executors (#207900) fix: show the Gateway command default beside host rules in Devices (#207887) fix: verify chat Stop recovery after dashboard pairing (#207888) test(activity): check midnight refresh against the elapsed window (#207859) test(ui): use one persisted message ID in queued-image handoff (#207861) test(agents): release configured MCP fixture resources (#207716) fix(workboard): clear CI failures in the session filter editor (#207858) perf(ai): reduce allocation in OpenAI Responses streams (#207889) ...
What Problem This Solves
Long OpenAI Responses streams allocate extra promises for every delta after their HTTP response hook has already finished. The response hook sits in a forwarding generator, so its once-per-request work adds overhead until the stream ends.
User Impact
Responses streaming uses less allocation on long reasoning, text, and tool-call output. The response hook still runs before start, and the first-event deadline still includes time spent in the hook.
Why This Change Was Made
The SDK Responses recovery loop already opens and consumes each accepted attempt. It can await response preparation once and then consume the existing stream directly. Both managed and shared SDK Responses paths use the same readiness operation. Terminal drain, retry provenance, diagnostics, and transport context keep their existing owners.
The supplied Team profile at
90ab1fad(Nov 28 at 17:45 PST, 163 RPC/min) sampled 2,008 MB over about 30 seconds. The biggest inclusive iterator frame wasobserveModelCallIterator().next()at 144.6 MB over 289 samples, including 67.7 MB native and 9.5 MB self at the reported site. The attribution identified the Responses wrapper stack for investigation. The change removes a forwarding layer inside that stack.Evidence
Five fresh-process A1/A2/B rounds using
scripts/perf/openai-sdk-stream-measure.tsreplayed the same synthetic SDK SSE response with 3,600 reasoning, text, and tool argument deltas per request and the first-event deadline enabled. Request and assistant-event hashes matched. A1 and A2 are independent runs of the parent2f2edbf36836.Median absolute A/A spread was 0.39% for sampled bytes, 4.53% for process CPU, 4.55% for main-thread CPU, and 24.79% for p95 wall time. The CPU and latency measurements give limited resolution on the busy host. An independent counting run saw 26.741 / 26.741 / 24.736 promises per delta, with the candidate removing 2.005 per delta. With the production model-call diagnostic iterator around the same transport, sampled allocation went from 7,534 / 7,499 to 7,236 B/delta (−3.5% paired, 0.53% A/A spread). Process CPU was 6.01 / 5.91 / 5.36 µs/delta (−3.0% paired, 9.38% A/A spread). The diagnostic path also removed 2.005 promises per delta.
Focused suites passed for Responses hook, timeout, retry, terminal drain, iterator ordering and cleanup, prompt prefix stability, and model-call diagnostics. The new integration cases cover mid-stream abort and provider failure after a text delta, with exact diagnostic event sequences. Existing tests cover unopened return and transport context across interleaved next, return, and throw. The added behavior checks also pass with the parent implementation. Allocation and promise counts establish the performance difference.
Codex autoreview completed on the staged change against
2f2edbf36836with no actionable P0–P2 findings. Production +44/−36 (net +8), tests +120/−25 (net +95), benchmark +46/−5 (net +41). The production growth shares the same preparation logic with sibling transports that still use the standalone iterator.Focused Chromium chat tests passed. The broad local UI run had browser and unit failures. Eight reproduced on the exact parent, and a worker stalled during shutdown. The isolated real-Gateway UI E2E Stop test passed with a synthetic Responses stream. The selected Send now case skipped under its existing gate.
The final committed-range
pnpm check:changedpassed typecheck, formatting, lint, and all other checks except the Knip export scan. Its three findings reproduced on a clean2f2edbf36836checkout. #202209 introducedAgentCommandPluginIngressOptsand exportedclearNativeRepositorySourceModulesForTestfor a test consumer. #207581 removed the final consumer ofresolveUpdateInstallSurfaceMock. These are existing main regressions outside the streaming change.