Repository navigation
Studio: stop repeating a two-minute wait on every message after a chat summary times out - #18222
Conversation
|
@codex review |
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: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…18334) Fixes #18306 On a connection that does not compact server-side, a long chat first asks the model for a summary of the older turns. That call had a fixed two-minute limit for the whole reply, so a slow model (a local llama-server behind a custom connection, a CPU model, a large backlog) that was still streaming the summary at two minutes had all of it thrown away. Studio then dropped the oldest turns anyway, so the user paid the full wait and got nothing for it. The reporter's log shows exactly this: `custom stream complete (... events={'delta': 2278})` and `external_provider.summary_failed error='the summary call timed out'` in the same millisecond. The two minutes now count silence instead: the summary call fails only when the provider sends nothing for two minutes, and a stream that keeps arriving is read to the end, up to ten minutes in all. Every summary that finished before still finishes the same way (its gaps were all under two minutes), and a provider that stalls is still given up on after two minutes, remembered per chat and model as in #18222. Both limits run as one `asyncio.timeout_at` scope in the calling task, rescheduled after each line, and the stream is closed outside it. A `wait_for` per line would run each read in a task of its own on Python 3.11 and could race the outer limit (python/cpython#86296). Python 3.10 has no `timeout_at` and keeps the old two-minute limit for the whole call. ## Before / after Same fake OpenAI-compatible provider streaming a summary one piece every 0.5 s for 150 s (about the reporter's pace for a 4k-token summary), real timeouts, through the real `/v1/chat/completions` route: | | main | this PR | |---|---|---| | summary call | timed out at 120 s | finished at 150 s | | summary in the prompt sent to the model | no | yes | | `context_truncated` | `summary_failed: true` (dropped turns) | `summarized: true` | | saved summaries for the thread | 0 | 1 | ## Tests - `test_a_summary_still_streaming_past_the_idle_timeout_is_kept`: a summary streamed word by word for longer than the idle limit is kept, used in the prompt and saved. - `test_a_summary_that_never_ends_hits_the_total_limit_and_closes_the_stream`: a stream that never goes quiet stops at the total limit and its generator is closed. - `test_a_timed_out_summary_is_not_asked_for_again_until_compact` now stalls past the idle limit instead of the total one. - `tests/test_cloud_summary_compaction.py`, `tests/test_external_auto_compaction.py`, `tests/test_custom_provider_api_type.py`: 147 passed. - The collector on Python 3.11, 3.12 and 3.13 with a stream cleanup that suspends: a steady stream past the idle limit is kept, a stall and an endless stream time out, a line arriving at the deadline times out, and the stream's cleanup runs to the end in every case.
On a connection to a slow model, a long chat asks the model to summarize the older messages. If that takes longer than two minutes, Studio gives up and drops the oldest messages instead. It then asked for the same summary again on every later message, so each one waited two more minutes on "Compacting context" and ended with the "Older messages dropped" notice.
A timed-out summary is now remembered for that chat and model, the same way a summary cut off at its token limit already is. Later messages drop the oldest turns without the wait. Compact chat still asks for a summary, and another model on the same chat gets its own attempt.
With Qwen 2.5 1.5B on llama.cpp (CPU), the two messages after the first timeout took 265 s and 193 s before, and 86 s and 99 s now. Trade-off: a server with a prompt cache could finish the summary on a later attempt; now the chat keeps dropping turns until Compact chat is used.
Related to #18189