Skip to content

Studio: keep a chat summary that is still streaming past two minutes - #18334

Merged
danielhanchen merged 3 commits into
mainfrom
studio-summary-idle-timeout
Nov 19, 2026
Merged

danielhanchen merged 3 commits into
mainfrom
studio-summary-idle-timeout

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

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.

@danielhanchen danielhanchen self-assigned this Nov 18, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T15:57:40.060536Z d73aa56 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 9985e153f2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 7f70d1df72

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: d73aa567a2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

danielhanchen added a commit that referenced this pull request Nov 18, 2026
…18357)

## Summary

Six tests in `unsloth_cli/tests/test_eval.py` fail on main since #18319:

```
FAILED test_dataset_task_avoids_explicit_yaml_name[True-.yaml]   (and the other 3 params)
FAILED test_standalone_yaml_is_copied_alone           - assert ['task_0.yaml'] == ['my_task.yaml']
FAILED test_eval_dataset_before_yaml_with_same_task_name - Error: unknown task 'qa'
```

They show up on every PR's CPU test run (for example on the staging runs
for #18332, #18334 and #18338).

## Cause

#18319 stages a standalone custom task YAML as `task_<n>.yaml` instead
of `<task name>.yaml`, so a task name like `../../x` cannot write
outside the staging directory. That change is correct. lm-eval names
tasks by the `task:` / `group:` key inside each file, not by the file
name: `lm_eval/tasks/_index.py` globs `**/*.yaml` and registers
`cfg["task"]` or `cfg["group"]` (checked against lm-eval 0.4.13). The
task name the user passes and sees is unchanged.

The tests were wrong in two ways:

- The fake `TaskManager` used by the CLI integration tests indexed tasks
by `p.stem`. Real lm-eval does not, so a correctly staged `task_1.yaml`
holding `task: qa` read as an unknown task.
- Two unit tests pinned the old staged file name (`custom/qa.yaml`,
`["my_task.yaml"]`).

## Fix

Test-only:

- The fake `TaskManager` now indexes each YAML under the include path by
its in-file `group:` / `task:` key, the same way lm-eval does.
- The two unit tests now check what lm-eval actually reads: exactly one
staged `.yaml`, whose content matches the source file and whose `task:`
key is the requested name.

## Verification

| `unsloth_cli/commands/eval.py` | old tests | these tests |
|---|---|---|
| main (#18319 staging) | 6 failed, 107 passed | 113 passed |
| before #18319 (`<name>.yaml` staging) | 113 passed | 113 passed |
| staged copy has the wrong `task:` key (sabotage) | n/a | 6 failed, 107
passed |

`tests/test_eval_custom_task_staging.py` from #18319 still passes. ruff
check is clean.
@danielhanchen
danielhanchen merged commit ffe16dd into main Nov 19, 2026
@danielhanchen
danielhanchen deleted the studio-summary-idle-timeout branch November 19, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] API/provider connections: compaction spends time generating a summary, then fails to write it

1 participant