Skip to content

fix(aimux): fail a model stream that goes idle - #2143

Merged
yyhhyyyyyy merged 19 commits into
mainfrom
hui/aimux-idle-timeout-2
Nov 24, 2026
Merged

yyhhyyyyyy merged 19 commits into
mainfrom
hui/aimux-idle-timeout-2

Conversation

@yyhhyyyyyy

@yyhhyyyyyy yyhhyyyyyy commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #2117

A model request waits for the next stream part with no deadline. The transport applies only an optional total request timeout, which no configuration sets by default, so a provider that stops delivering without closing holds the turn until an external deadline ends the process. The benchmark runs that motivated this issue do not show that shape: five trials kept streaming thinking for the whole deadline, so a bound on silence cannot end them. What it bounds is the other class, a connection that stays open and delivers nothing, where one observed request stayed open for its whole lifetime.

This change gives every wait between stream parts a five-minute allowance and classifies an expired one as network, the kind the retry policy retries beside transport failures. The allowance is per wait, not per request: a reply that keeps streaming is never cut. An expired deadline outranks a part that is ready at the same moment, so data that was already waiting when the allowance ran out does not revive a connection that was silent for all of it. Cancelling the request outranks both. AiMuxError::Timeout keeps its existing unknown kind; the bridge builds this failure with its own facts and the reason the stream delivered nothing for 300 seconds.

The wait for the response headers carries the same allowance, because the stream bound starts only once the connection is answered: a provider that accepts the request and never sends headers would otherwise hold the turn forever when no total timeout is set. The wait ends when the response headers actually arrive: the transport reports the moment it produced them, and both that wait and the wait after it are judged against that moment, so headers that arrive inside the allowance are not late because the driver next polls after it, and a report from a non-2xx reply in that position keeps its status. The wait after the headers then runs from the headers to the start of the stream: the OpenAI Chat provider reads one event before it returns the stream, so without that wait the header deadline would still cover it. The header wait itself starts when the request is sent, so the request body and any redirects count against it; an expired header wait fails as network with the reason no response headers arrived within 300 seconds of sending the request, and an expired stream-start wait fails the same way. The OpenAI Responses provider returns only after its SDK's startup scan, which reads response metadata the driver cannot see, so its stream-start wait says what it measures and expires with the reason the response headers arrived, but the stream did not start within 300 seconds; the providers that read one event keep the reason the response headers arrived, but no stream event followed within 300 seconds, and the compatible and Bedrock providers return at the headers and leave the first event to the wait between parts. The retry budget is unchanged: at most eight attempts and 300 seconds of backoff sleep, each attempt bounded by the waits above, so a half-open connection ends the turn as failed instead of holding it forever. The optional network.timeoutMs keeps its meaning: it bounds one whole request, its response body included, separately from these waits.

A non-2xx response is bounded on its own. The provider reads the error body before it returns the failure, so a stalled body would otherwise outlive the request and, if the request were failed as idle, would also discard the status that had already arrived. The transport ends a non-2xx body after a total five-minute allowance, the provider keeps the bytes that arrived and reports the HTTP status it received, and the driver runs no idle deadline over a non-2xx reply. A 401 whose body stops after a partial error object therefore still fails as auth_rejected with status 401, not as a retryable network failure.

Known limitation, also stated in the design document: only decoded stream parts reset the allowance. The provider parser drops SSE comments and Anthropic ping events before they reach the bridge (StreamEvent::Other => {}), so a connection that stays alive only with keep-alives is failed after five minutes without parts. Renewing the allowance on those events needs an upstream aimux change, which this change does not make; the allowance stays a fixed bound of its own and is not configurable.

With #2121's retry, an idle failure before the attempt committed anything is replaced in place under the same request. After committed output it ends the turn without replaying what was already shown, and a step whose tool call was announced continues with a new request, as every retried kind does.

The development model configuration could not state the connection facts a product provider record already carries, so a development run could not set a proxy or a total request timeout. A provider now accepts an optional network block with the same fields, rules and meaning: proxy and timeoutMs (a positive safe integer) belong to the connection, while the idle allowance stays a fixed five minutes of its own.

Verification:

  • cargo test -p dim-agent-aimux --lib covers the deadlines in the stream bridge: the failure's kind and reason, parts that keep the stream open across virtual time, and an expired deadline that outranks a ready part. It also covers the driver's waits through a scripted transport: late headers, a report read after the allowance, a missing first event, the Responses startup, and a stalled error body.
  • cargo test -p dim-agent-aimux --test agent_aimux_flow runs the model flow suite, including the response-header case below.
  • model_flow::a_wait_for_response_headers_past_the_idle_allowance_fails_as_a_network_failure covers a listener that reads the request and never answers: virtual time passes five minutes and the call fails as a network failure naming the headers.
  • driver::tests::a_delayed_header_reply_still_gets_its_first_event_allowance covers headers at 299 seconds of virtual time and a first event at 301 seconds: the call starts and delivers its text.
  • driver::tests::a_header_report_read_past_its_allowance_is_on_time covers a header report written at 299 seconds and read only after 301: the call starts from the reported instant and delivers the text of a first event at 301 seconds.
  • driver::tests::a_header_report_read_past_its_allowance_keeps_the_response_status covers a 401 reported at 299 seconds and read only after 301: the call fails with status 401 and auth_rejected, not as a retryable network failure.
  • driver::tests::a_header_report_starts_the_stream_allowance_at_its_instant covers the same report read at 301: the stream-start allowance ends three hundred seconds after the report, not three hundred seconds after the poll that read it.
  • driver::tests::a_first_event_past_its_own_allowance_fails_as_a_network_failure covers headers that arrive and a first event that never does: the call fails as a network failure naming the missing event.
  • driver::tests::a_responses_startup_past_its_allowance_names_the_stream_start covers a Responses reply whose startup scan decodes response.created and then delivers no output: the call fails as a network failure naming the stream's start.
  • driver::tests::a_responses_start_inside_its_allowance_delivers_the_output covers the same metadata followed by output inside the allowance: the reply starts and delivers its text.
  • driver::tests::a_stalled_error_body_keeps_the_response_status covers a 401 whose body stops after a partial error object: the call fails with status 401 and auth_rejected, not as an idle network failure.
  • cargo test -p dim-agent-aimux --test agent_aimux_flow network_block covers the block reaching the connection a request resolves, and the values the transport cannot use failing the load next to the provider that states them.
  • cargo test -p dim-agent-capabilities --test capabilities_flow idle_timeout covers the in-place retry before any committed event, and the turn ending after committed text without a replay.

The stream cases that require a deadline fail by assertion, not by timing out, when the deadline arm is absent; the third pins that arriving parts keep the stream open. The response-header and stream-start cases fail the same way without their bounds, a report read after the allowance is failed as missing headers when its instant is ignored, and the error-body case fails on the status assertion because the idle failure replaces the status.

A request waited for the next stream part with no deadline, so a provider that stopped delivering without closing held the turn until an external deadline ended the process. Each wait now has a five-minute allowance, and an expired one fails the request as a network failure so the retry policy can replace the attempt while nothing was committed.

The allowance is per wait, not per request: a reply that keeps streaming is never cut. Cancelling the request outranks the deadline, and the deadline outranks a part that is ready at the same moment.
The stream fixture now lets a test feed parts after the idle wait is armed, so virtual time can pass inside one wait. The cases cover the failure's kind and reason, parts that keep the stream open, and an expired deadline that outranks a part ready at the same moment.
An idle failure is a network failure, so an attempt that committed nothing is replaced in place under one request, while one that already committed text ends the turn without replaying it. Both outcomes are scripted with the failure the aimux stream builds.
The development model configuration could not state the facts the transport already reads from a product provider record, so a development run could not set a proxy or a total request timeout. A provider now takes an optional network block with the rules the product record applies: an HTTP or HTTPS root proxy URL and a positive safe-integer timeout.

The block sets the connection the catalog resolves for every request of that provider. The streaming idle allowance stays a fixed bound of its own, not a connection setting.
A provider that reads the request and never sends the response headers holds the turn with no deadline. The case keeps a raw listener at that point after its request head arrives, moves the clock five minutes, and expects the network failure the bridge reports for an idle stream, with the reason naming the response headers.

Without the bound the wait never ends; the test's guard reports it, and the assertions on the failure's kind and reason cannot be reached.
The idle allowance started only after the response headers arrived, so a provider that accepted the request and never answered held the turn until an external deadline whenever the connection's optional total timeout was unset, which is the default. The wait for the headers now carries the same five-minute allowance and fails as a network failure with the reason naming the headers, so the retry policy replaces the attempt in place while nothing was committed.

The connection's optional total timeout is unchanged: this bounds one wait, not the whole request. Cancelling the request still outranks the deadline.
The development configuration's network check also refuses a timeout above the largest safe JSON integer, but its message and the CLI README asked for a positive integer, which such a value satisfies. Both now ask for a positive safe integer, and the load-failure case asserts that wording.
The five-minute bound starts when the request is sent and covers its body and any redirects, so the failure reason, the constant's documentation and the design pages now name the whole exchange instead of only the wait for the response headers. The retry budget is unchanged: eight attempts of five minutes each bound a half-open connection to roughly 42 minutes before the turn fails.

@eric8810 eric8810 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.

[P2] Start the first-event allowance when headers actually arrive (crates/dim-agent-aimux/src/driver.rs:735). This races the whole model.do_stream() future, not the HTTP response headers. In the pinned Aimux 0.6.1, OpenAI Chat reads one SSE event after receiving the headers and before returning StreamResult. If the headers arrive at 4m59s and the first event at 5m01s, both documented allowances are satisfied, but this branch aborts at 5m, reports that no headers arrived, and can retry the request. The header test only covers a peer that never sends headers, so it cannot catch this. Please anchor the header deadline to actual header receipt, give the first event its own idle window, and cover the delayed-headers/short-first-event-gap case.

The same distinction matters for errors: Aimux reads a non-2xx response body before returning the failure. If that body stalls after a 401, this timer discards a known status and returns a retryable network failure instead. Bound that body read separately without losing the status. Also, please carry the decoded-parts-only limitation from the PR description into the EN/ZH model-failure docs so readers know SSE keep-alives do not reset the timer.

Static review of c346caa8; GitHub's Linux workspace tests were still running. I did not run the tests locally.

A reply whose headers arrive inside the allowance must still get its own allowance for the first event, and a stalled non-2xx body must keep the HTTP status instead of becoming an idle network failure. Both cases fail on the current driver by assertion.
The wait for the response headers raced the whole do_stream call, so a reply whose headers arrive inside the allowance but whose first event follows after it was failed as a missing header. The transport now reports the response status, the deadline moves to the first event when the headers arrive, and a non-2xx body is read under its own total allowance so a stalled error body keeps the HTTP status and its kind.
The design document now names the three waits the idle allowance bounds, the separate total allowance for a non-2xx body, and the limitation that only decoded stream parts renew the wait between parts.
A reply whose headers arrive and whose first event never does fails as a network failure that names the missing event, so the window that starts at the headers is both extended and bounded.
The three deadline tests answered over a real listener and held the call in real time with a blocking sleep before the virtual clock moved, so a scheduler slower than the sleep failed them without a product defect. They now build the driver in the crate, answer each exchange from a scripted transport, and poll the call until it has no ready work before the clock moves, so the same assertions hold with no real waiting. The flow suite keeps the real-transport case for the response headers.
@yyhhyyyyyy

Copy link
Copy Markdown
Collaborator Author

Thanks. All four points are addressed in 4a0f220f3741d7468478e1a58c1ef7974d1d49d9.

  1. The header deadline now ends when the response headers actually arrive. The transport every model call already carries reports the response status, and the wait that starts when the request is sent ends as soon as that report arrives; the first event is no longer inside the header window. The new test answers the call through a scripted transport that releases the headers after 299 seconds of virtual time; the call starts, and the previous driver failed it at 300 seconds with no response headers arrived within 300 seconds of sending the request. Test: driver::tests::a_delayed_header_reply_still_gets_its_first_event_allowance.

  2. The first event has its own five-minute window from the headers. In the same test the first event arrives at 301 seconds and the reply delivers its text; the header window ends at 299 seconds and the event window starts there. For the OpenAI Chat provider, whose one-event peek is inside do_stream, that peek is now covered by the second window. A second test answers with the headers and never sends an event: the call fails after five minutes with the response headers arrived, but no stream event followed within 300 seconds, so the window is bounded as well as extended. Test: driver::tests::a_first_event_past_its_own_allowance_fails_as_a_network_failure. The compatible provider returns at the headers, so for it the first event falls under the wait between stream parts in the bridge and the second window is never reached.

  3. A non-2xx body is read under its own total five-minute allowance. When the allowance expires the transport ends the body, the provider handler keeps the bytes that arrived and builds the failure from the status it already received, and the driver runs no idle deadline over a non-2xx reply, so the status cannot be replaced by an idle network failure. Test: driver::tests::a_stalled_error_body_keeps_the_response_status answers 401 with a partial error object and then stalls; the call fails with HTTP 401 and auth_rejected, where the previous driver returned a retryable network failure.

  4. The decoded-parts-only limitation is now in the design document. docs/design/model-failures.md and docs/zh/design/model-failures.md state the three waits, the separate allowance for a non-2xx body, and that only decoded stream parts renew the wait between parts, so SSE keep-alives do not.

One boundary remains and the design document states it: the header window still starts when the request is sent, so the request body and any redirects count against it.

@yyhhyyyyyy
yyhhyyyyyy requested a review from eric8810 November 24, 2026 14:55

@eric8810 eric8810 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.

The new split addresses the original delayed-header/first-event case, preserves the HTTP status for the partial 401 body, and documents the keep-alive limitation. One boundary still contradicts the new contract:

[P2] Use when headers were received, not when the driver next polls (crates/dim-agent-aimux/src/driver.rs:276–280,805–838). ResponseWatch sends only the status, then do_stream can yield pending while reading the body. If the response is reported just before the deadline but the task next runs just after it, the biased select takes the timer before the already-ready report. It can still say “no response headers arrived” and retry a known 401. When the status branch does win, the first-event window starts at the receiver's Instant::now() instead of at receipt. Report the receipt timestamp, use it to distinguish on-time headers from genuinely late ones, and derive the first-event deadline from it while keeping cancellation precedence. The existing test reads the report at 299s; please also cover a report sent before the boundary but not polled until afterward.

Non-blocking diagnostics note: the bridge's mid-stream deadline is outside RecordingOutcomeStream, so dropping it without an Aimux terminal item records Cancelled, even though the application receives a network failure. The pre-stream timeout paths already record failure explicitly. Recording both consistently would make these incidents easier to diagnose.

Static re-review at 4a0f220f; Linux CI was still running. No local test run.

@zerob13 zerob13 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.

Define the startup deadline for OpenAI Responses, including managed Codex. The separated HTTP-header and body waits fix the previous Chat cases. On the Responses path, the driver still treats completion of do_stream() as receipt of the first decoded part, but the pinned SDK's startup scan can already have decoded and buffered response metadata before returning the stream. The current deadline can therefore classify a progressing response as having delivered no event.

Base the deadline on observable decoded progress, or explicitly define a separate SDK startup-completion deadline and its error and retry behavior. Add Responses-path coverage; the new Chat tests and green exact-head CI do not establish this behavior. This is separate from the peer's existing header receipt timestamp finding. No external provider was called during this review.

zerob13
zerob13 previously approved these changes Nov 24, 2026

@zerob13 zerob13 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.

Verdict: approved for the delta c346caa8..4a0f220f. The three blockers from the previous review are fixed at this head, and the follow-up commits do not introduce new ones.

Scope: this review covers the seven commits pushed after c346caa8 (94c0607f through 4a0f220f). Everything before that, including the network block, was already covered by the earlier review.

What changed and why it is correct

1. The header wait and the first-event wait are now separate. The transport is wrapped in ResponseWatch, which reports the status as soon as the headers arrive; driver.rs:781-836 then resets the allowance for the first event. This is the distinction the previous review asked for: the old code raced the whole do_stream() call, so headers at 4m59s plus a first event at 5m01s was failed as "no response headers". The new test at driver/tests.rs:160 reproduces exactly that case and passes.

2. A stalled non-2xx body no longer loses the HTTP status. For a non-2xx reply the body is read under one total five-minute allowance (ResponseWatch, driver.rs:269-298), the driver stops applying its own idle deadline for that exchange, and the provider still reports the status it received. The test at driver/tests.rs:260 sends a 401 with a partial error body and gets host_error_code = Some(401) with AuthRejected, not a retryable network failure.

3. The documentation matches the code. docs/design/model-failures.md and docs/zh/design/model-failures.md now state the three waits, the separate error-body allowance, and the limitation that only decoded stream parts renew the wait (SSE comments and Anthropic ping events do not).

Verification

  • cargo test -p dim-agent-aimux --lib — 77 passed, including the three new driver tests.
  • cargo test -p dim-agent-aimux --test agent_aimux_flow — 88 passed.
  • cargo fmt -p dim-agent-aimux -- --check — clean.
  • CI at 4a0f220f is green (ci-ok, verify (linux), macos-native, windows-cli, dependencies).

Non-blocking notes

  • When a non-2xx status arrives, bounded = false removes the driver's idle deadline for the rest of that exchange (driver.rs:836). That is safe today because the body read is the only remaining wait, but if a provider later does other work after a non-2xx status, that work will be unbounded. A comment saying the body wrapper is now the only bound would help the next reader.
  • A refused 3xx takes the same non-success path. follow_redirects already strips Location before the provider sees it, and the body allowance still bounds the exchange, so there is no hang.
  • The deadline branch is biased ahead of the status branch, so headers that are ready at the same instant the allowance expires still fail as "no response headers". This matches the documented "an expired bound outranks a part that is ready at the same moment" rule; noted only because the error text can be slightly misleading at that exact boundary.

Where to look

  • crates/dim-agent-aimux/src/driver.rs:269 — ResponseWatch (status reporting + non-2xx body cap).
  • crates/dim-agent-aimux/src/driver.rs:781 — the three-wait loop and the deadline reset.
  • crates/dim-agent-aimux/src/stream.rs:31 — the updated allowance documentation.
  • crates/dim-agent-aimux/src/driver/tests.rs:160, :211, :260 — the three new deadline tests.

The earlier REQUEST_CHANGES was posted against c346caa8; this approval only covers the delta above. The PR stays blocked until the remaining review state is resolved.

@zerob13
zerob13 dismissed their stale review November 24, 2026 15:09

Withdrawing this approval. After checking the pinned aimux 0.6.1 Responses path, do_stream runs read_until_output before it returns, so the driver's first-event window starts at the headers and cannot observe the events the SDK consumes during that startup scan. A slow-but-progressing Responses startup can therefore be failed as 'no stream event'. The separate changes-requested review covers the fix this needs; this head is not merge-ready. The delta verification in the dismissed review still stands for the Chat and non-2xx paths.

…tart

The transport reports the response headers at 299 seconds of virtual time and the task is not polled again until 301: the reply must still start, and a 401 in the same position must still keep its status instead of becoming a header timeout. The OpenAI Responses startup scan can decode response metadata before it returns the stream, so a stream that never starts must name the stream start rather than a missing event, and a reply whose metadata arrives before its output must still deliver that output.

All four fail on the current driver by assertion, except the last, which pins the path the fix must keep working.
The transport now reports when it produced the response headers, and the wait after them starts at that instant, so a report written inside the header allowance is on time even when the driver next polls after the deadline. The deadline arm still runs before the report and the exchange: it reads the report there and treats an on-time non-2xx reply as a reply whose status must survive, instead of declaring that no headers arrived.

The wait after the headers is named by what the provider does with it. The OpenAI Responses SDK reads response metadata before it returns the stream, so that wait ends at the stream's start and its expiry says so, while the providers that read one event keep the reason that names the missing event.
The design document now states that a wait with a producer-reported instant is judged against that instant, so the header wait and the wait after it meet where the transport produced the headers rather than where the driver next polls. It also states that the OpenAI Responses provider's wait ends at the stream's start because its SDK reads response metadata first, and which providers leave the first event to the wait between parts.
Headers reported at 299 seconds and read at 301 must end the stream-start allowance at 599 seconds, three hundred seconds after the report, not at 601 seconds after the poll that read it. The case fails on the driver that starts the window at the poll.
@yyhhyyyyyy

Copy link
Copy Markdown
Collaborator Author

Thanks. Both points are addressed in c78ad3f646ed5514d925e108bd0bee47657840da.

The transport now reports when it produced the response headers, and that instant decides the boundary. ResponseWatch sends the status together with the clock reading taken immediately after the inner transport returned, so the report says when the headers arrived rather than when it was read. The driver uses it in two places. The report starts the stream-start allowance from that reading, not from the next poll: a reply whose headers arrived at 299 seconds keeps its full window even when the task is next polled at 301. And the deadline arm reads a report already written before it declares that no headers arrived, so a report from inside the allowance is not turned into a timeout by the biased order. The deadline arm still runs before the report and the exchange, so an expired deadline still outranks a ready event; it only treats a report whose own instant is inside the allowance as on time. A report written after the allowance is still a timeout, and a non-2xx report written inside it keeps its status instead of being retried as a network failure.

driver::tests::a_header_report_read_past_its_allowance_is_on_time answers with the headers at 299 seconds of virtual time, polls the task once so the transport writes its report, advances past the header allowance without polling the task again, and then polls: the reply starts, and it delivers the text of a first event that arrives at 301 seconds. The previous driver failed that poll with no response headers arrived within 300 seconds of sending the request.

driver::tests::a_header_report_read_past_its_allowance_keeps_the_response_status puts a 401 with a stalled error body in the same position: the request stays open until the body's own allowance ends and then fails with status 401 and auth_rejected, where the previous driver discarded the known status at the header deadline.

driver::tests::a_header_report_starts_the_stream_allowance_at_its_instant pins the other side of the same instant: that report, written at 299 seconds and read at 301, ends the stream-start allowance at 599 seconds, three hundred seconds after the report, not at 601 seconds after the poll that read it.

On the diagnostics note: this change does not alter it. The mid-stream deadline is in the bridge, outside RecordingOutcomeStream, and the bridge holds no recording handle; recording that failure needs either an entry from the bridge into the recording or the deadline moved inside the recording wrapper. Both change the recording path rather than this deadline behavior, so they are left for a separate change.

@yyhhyyyyyy

Copy link
Copy Markdown
Collaborator Author

Thanks. The OpenAI Responses path now has its own startup deadline in c78ad3f646ed5514d925e108bd0bee47657840da.

The wait after the response headers is now defined by what the provider does before it returns the stream, and on this path it ends at the stream's start, not at an event the driver can see. The pinned Responses SDK reads and buffers response.created and other metadata events before it returns, so decoded progress inside do_stream is not observable to the driver without an upstream aimux change. Instead of reporting that wait as a missing event, the driver names what it measures. On openai-responses, the managed openai-codex preset included, an expired wait fails as network with the reason the response headers arrived, but the stream did not start within 300 seconds; it is retried in place like the other network failures while the attempt has committed nothing. The providers that read one event before returning keep the reason the response headers arrived, but no stream event followed within 300 seconds, and the design document now states the split and why the Responses startup scan cannot be observed.

driver::tests::a_responses_startup_past_its_allowance_names_the_stream_start answers the Responses protocol with a response.created frame the SDK decodes and then no output; virtual time passes the allowance and the call fails with the startup reason and network, where the previous driver reported no stream event followed. driver::tests::a_responses_start_inside_its_allowance_delivers_the_output sends the same metadata first and the first output item inside the allowance: the reply starts and delivers its text, so the startup wait does not cut a reply that is producing output.

@eric8810 eric8810 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.

Approved at c78ad3f6. The timestamp on the transport report now preserves headers received before the cutoff even when the driver resumes late, and anchors the startup window to receipt. I verified the exact-head Linux CI log: the late-read 200, stalled 401 (status preserved), receipt-anchored startup deadline, and both OpenAI Responses startup cases all ran and passed. The ci-ok job passed. The mid-stream recording outcome discrepancy remains a non-blocking follow-up, as discussed. I did not run tests locally.

@zerob13 zerob13 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.

The transport records header receipt time, late driver polling preserves on-time responses and a stalled non-success body keeps the HTTP status. OpenAI Responses, including the managed Codex path, now has an explicit SDK startup deadline rather than claiming that no event arrived. This addresses my earlier request; exact hosted CI passed the metadata-first, header receipt, stalled 401 and interruption cases. Non-blocking follow-up: compare the reported timestamp with the cutoff on every completion path, so a report produced around the timer boundary is classified the same way regardless of poll order.

@yyhhyyyyyy

Copy link
Copy Markdown
Collaborator Author

Fixed in #2150. The report arm now compares the reported instant with the header cutoff and ends the wait as missing headers, with the same kind and reason the deadline arm uses, so a report produced around the timer boundary is classified the same way whichever arm reads it. The select order is unchanged: the deadline still runs before the report and the exchange, so a part that is ready when the allowance expires still loses to it.

The boundary was narrower than a whole completion path: the header allowance is a timer and fires on its next millisecond tick, so for up to one tick the report arm could read a report stamped after the cutoff while the deadline arm was still pending. driver::tests::a_header_report_written_after_its_allowance_is_late writes that report 0.2 ms after the allowance with a paused clock half a tick off the grid, and it failed by assertion on the merged code. driver::tests::a_header_report_written_after_its_allowance_is_late_after_the_tick pins the same report read after the tick, and driver::tests::a_header_report_written_at_the_allowance_stays_on_time pins a report written exactly at the cutoff, where the reply still starts and delivers its text.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(model): a model stream has no idle timeout, and the development model config cannot set one

3 participants