Patrick Buckley
2e18d159a3
feat(session): fold the main streaming loop onto model_turn ( #832 )
...
The send path's plant call is now one model_turn invocation per attempt,
reached through a lane-swap fallback walk that mirrors the old creation
ladder 1:1: an inner per-lane retry (_model_turn_with_retry) inside the
two-pass healthy/degraded walk (_model_turn_with_fallback), with health
success recorded at the request-accepted instant via the per-attempt
_CancelRef's new on_first_append hook and failure once per lane ladder.
The hook is also the creation-vs-midstream classifier: an armed attempt's
death re-raises to the re-issue ladder on every lane — a fallback stream
that died after tokens reached the UI is never swallowed into
try-the-next-alias — and carries the per-turn usage-slot resets at the
old timing so a reconnecting tab's status bar never blanks mid-walk.
Chunk-to-UI translation lives in _StreamTurnConsumer (model_turn's
on_chunk body): display-side only, the canonical turn always assembled by
drain_stream at the one seam; the inline-tag scan reads the SAME lane
capability the drain gate reads (server_parses_reasoning), replacing the
creation-time handoff register — which is deleted — so display and commit
cannot disagree about a backend's posture, fallback walk included.
Cancellation converges: every model-call site now builds fresh
generation-scoped refs, closing the force-cancel hole where the old gen-0
shared ref read aborted=False for an orphaned generation and would have
let a retry re-issue on its behalf; the pre-dispatch abort read inside
model_turn also means a Stop set before the turn no longer mints a
credential on a dynamically authenticated alias.
send() consumes the result natively: the committed Turn carries minted
ids, the finalized native lane, and an accurate producer — fixing the
latent mislabel where fallback-served turns were persisted under the
primary provider's name, and the fork asymmetry where in-memory turns
decoded with producer="". Ruled behavior changes (design D12): the
trailing citations footer now folds into committed content (it previously
lived only in an ephemeral info bubble and vanished on reload); a stream
that exhausts without a finish reason is a retryable mid-stream death
instead of a silent partial commit; length-truncated turns keep dropping
partial tool calls, now as an explicit post-drain policy. The replay
parity harness pins all thirteen scenarios against pre-fold baselines,
transformed only where a ruling applies — and caught two real bugs during
the fold (the splitter's end-of-stream carry never flushing to the UI,
and the footer splicing into the answer's held tail).
ChatSession imports no provider module: create_streaming has exactly one
caller module, and the protocol types, merge_usage, and create_provider
reach the session through model_turn's re-export seam.
2026-08-06 01:04:32 -07:00
..
2026-08-06 01:04:32 -07:00
2026-03-02 00:33:37 -08:00
2026-08-03 20:11:28 -07:00
2026-07-07 16:42:36 -07:00
2026-08-02 06:15:40 -07:00
2026-08-03 20:11:28 -07:00
2026-08-06 01:04:32 -07:00
2026-07-10 15:42:33 -07:00
2026-08-05 12:58:55 -07:00
2026-07-05 01:57:54 -07:00
2026-08-05 00:23:11 -07:00
2026-07-20 22:38:32 -07:00
2026-07-24 18:15:03 -07:00
2026-07-04 20:54:20 -07:00
2026-07-18 16:12:59 -07:00
2026-05-05 15:27:14 -07:00
2026-08-06 01:04:32 -07:00
2026-08-03 20:11:28 -07:00
2026-07-11 18:15:48 -07:00
2026-05-19 08:09:33 -07:00
2026-05-29 21:11:16 -07:00
2026-08-04 05:19:03 -07:00
2026-06-01 15:47:14 -07:00
2026-04-26 22:14:22 -07:00
2026-08-04 05:19:03 -07:00
2026-06-04 11:03:13 -07:00
2026-06-16 00:48:14 -07:00
2026-08-03 20:11:28 -07:00
2026-04-27 22:51:31 -07:00
2026-08-04 05:19:03 -07:00
2026-08-02 15:15:02 -07:00
2026-07-10 15:42:33 -07:00
2026-07-10 15:42:33 -07:00
2026-07-20 22:38:32 -07:00
2026-08-02 01:48:30 -07:00
2026-08-04 04:53:17 -07:00
2026-05-23 14:20:36 -07:00
2026-07-29 22:11:38 -07:00
2026-04-18 05:49:54 -07:00
2026-07-05 01:57:54 -07:00
2026-07-29 22:11:38 -07:00
2026-04-18 05:49:54 -07:00
2026-03-23 11:11:40 -07:00
2026-05-12 13:15:09 -07:00
2026-05-11 01:06:47 -07:00
2026-04-30 23:20:14 -07:00
2026-04-30 23:20:14 -07:00
2026-05-24 18:31:23 -07:00
2026-05-30 16:27:15 -07:00
2026-07-17 11:28:44 -07:00
2026-07-29 22:11:38 -07:00
2026-05-31 19:54:43 -07:00
2026-07-19 19:09:58 -07:00
2026-07-05 01:59:38 -07:00
2026-07-05 01:59:38 -07:00
2026-05-11 01:06:47 -07:00
2026-04-27 21:52:57 -07:00
2026-04-16 13:30:25 -07:00
2026-04-18 19:02:52 -07:00
2026-07-03 00:29:26 -07:00
2026-08-03 20:11:28 -07:00
2026-07-25 00:50:29 -07:00
2026-06-08 10:08:30 -07:00
2026-07-17 11:28:44 -07:00
2026-08-04 04:53:17 -07:00
2026-07-17 11:28:44 -07:00
2026-07-05 01:57:54 -07:00
2026-07-07 16:42:36 -07:00
2026-07-29 22:11:38 -07:00
2026-06-26 03:28:06 -07:00
2026-08-03 20:11:28 -07:00
2026-07-06 19:16:09 -07:00
2026-08-03 20:11:28 -07:00
2026-07-29 22:11:38 -07:00
2026-07-29 22:11:38 -07:00
2026-04-16 21:40:50 -07:00
2026-07-29 22:11:38 -07:00
2026-08-02 06:15:40 -07:00
2026-07-19 19:09:58 -07:00
2026-03-13 21:21:09 -07:00
2026-07-13 22:39:19 -07:00
2026-06-17 18:07:45 -07:00
2026-08-03 20:11:28 -07:00
2026-08-05 12:58:55 -07:00
2026-04-04 17:53:20 -07:00
2026-03-02 00:33:37 -08:00
2026-07-05 01:59:38 -07:00
2026-07-13 22:39:19 -07:00
2026-05-04 00:46:43 -07:00
2026-07-29 22:11:38 -07:00
2026-07-29 22:11:38 -07:00
2026-06-04 11:03:13 -07:00
2026-06-26 19:37:01 -07:00
2026-03-03 22:57:34 -08:00
2026-07-22 23:44:04 -07:00
2026-07-03 00:29:26 -07:00
2026-07-03 00:29:26 -07:00
2026-06-10 13:31:53 -07:00
2026-06-09 18:37:46 -07:00
2026-04-04 23:44:29 -07:00
2026-07-13 08:48:27 -07:00
2026-06-04 11:03:13 -07:00
2026-05-30 01:11:48 -07:00
2026-07-29 22:11:38 -07:00
2026-07-17 11:28:44 -07:00
2026-06-16 03:41:51 -07:00
2026-05-31 19:54:43 -07:00
2026-08-05 12:58:15 -07:00
2026-06-04 11:03:13 -07:00
2026-05-31 19:54:43 -07:00
2026-04-05 01:53:33 -07:00
2026-06-09 20:00:55 -07:00
2026-08-05 12:58:55 -07:00
2026-03-04 06:47:30 -08:00
2026-07-11 16:37:13 -07:00
2026-03-02 16:55:12 -08:00
2026-08-02 15:15:02 -07:00
2026-07-12 19:03:35 -07:00
2026-08-02 15:15:02 -07:00
2026-07-13 21:13:42 -07:00
2026-05-04 22:00:23 -07:00
2026-08-02 01:48:30 -07:00
2026-05-06 11:29:25 -07:00
2026-05-04 22:00:23 -07:00
2026-07-14 11:39:25 -07:00
2026-07-14 11:39:25 -07:00
2026-08-02 15:15:02 -07:00
2026-06-25 20:42:22 -07:00
2026-07-04 03:27:55 -07:00
2026-05-04 22:00:23 -07:00
2026-05-04 22:00:23 -07:00
2026-07-12 19:03:35 -07:00
2026-05-07 13:59:50 -07:00
2026-05-07 13:59:50 -07:00
2026-08-03 20:11:28 -07:00
2026-05-12 13:15:09 -07:00
2026-07-04 03:27:55 -07:00
2026-07-12 19:03:35 -07:00
2026-06-17 18:07:45 -07:00
2026-07-14 11:39:25 -07:00
2026-06-17 18:07:45 -07:00
2026-06-17 18:07:45 -07:00
2026-07-13 21:13:42 -07:00
2026-03-12 16:57:31 -07:00
2026-03-21 16:12:50 -07:00
2026-03-20 20:01:26 -07:00
2026-03-23 11:11:40 -07:00
2026-05-07 13:59:50 -07:00
2026-05-04 22:00:23 -07:00
2026-07-06 18:46:28 -07:00
2026-07-14 11:39:25 -07:00
2026-08-02 15:15:02 -07:00
2026-06-26 17:24:06 -07:00
2026-06-26 17:24:06 -07:00
2026-07-29 22:11:38 -07:00
2026-08-04 04:53:17 -07:00
2026-05-04 22:00:23 -07:00
2026-06-04 11:03:13 -07:00
2026-06-12 13:54:49 -07:00
2026-06-26 17:24:06 -07:00
2026-07-03 00:29:26 -07:00
2026-07-04 16:48:52 -07:00
2026-07-08 00:59:14 -07:00
2026-05-31 16:05:21 -07:00
2026-05-09 02:45:13 -07:00
2026-07-13 22:39:19 -07:00
2026-08-04 05:19:03 -07:00
2026-08-04 05:19:03 -07:00
2026-08-05 12:58:55 -07:00
2026-06-11 20:27:29 -07:00
2026-06-04 11:03:13 -07:00
2026-04-28 13:49:31 -07:00
2026-04-06 03:08:19 -07:00
2026-08-05 12:58:55 -07:00
2026-05-11 01:23:54 -07:00
2026-04-05 17:18:26 -07:00
2026-07-17 11:28:44 -07:00
2026-07-29 22:11:38 -07:00
2026-07-06 21:52:42 -07:00
2026-07-12 19:03:35 -07:00
2026-08-02 15:15:02 -07:00
2026-07-04 16:48:52 -07:00
2026-07-12 19:03:35 -07:00
2026-07-07 08:20:57 -07:00
2026-08-03 20:11:28 -07:00
2026-07-05 11:59:52 -07:00
2026-08-05 00:23:11 -07:00
2026-06-11 14:00:42 -07:00
2026-05-24 17:49:27 -07:00
2026-08-05 12:58:55 -07:00
2026-07-06 21:42:51 -07:00
2026-06-16 00:48:14 -07:00
2026-07-02 19:23:04 -07:00
2026-08-05 00:23:11 -07:00
2026-07-03 00:29:26 -07:00
2026-07-29 22:11:38 -07:00
2026-07-06 19:58:36 -07:00
2026-07-03 00:29:26 -07:00
2026-07-06 19:16:09 -07:00
2026-07-07 22:07:20 -07:00
2026-07-07 08:20:57 -07:00
2026-07-01 18:01:50 -07:00
2026-06-26 17:24:06 -07:00
2026-07-01 18:01:50 -07:00
2026-07-06 19:16:09 -07:00
2026-07-03 19:16:36 -07:00
2026-07-03 00:29:26 -07:00
2026-08-05 12:58:55 -07:00
2026-05-09 02:45:13 -07:00
2026-06-04 11:03:13 -07:00
2026-06-04 11:03:13 -07:00
2026-07-11 16:37:13 -07:00
2026-07-13 22:39:19 -07:00
2026-07-13 22:39:19 -07:00
2026-08-05 12:58:55 -07:00
2026-04-26 22:14:22 -07:00
2026-08-04 04:53:17 -07:00
2026-07-01 21:05:57 -07:00
2026-06-04 11:03:13 -07:00
2026-08-02 06:15:40 -07:00
2026-04-18 19:02:52 -07:00
2026-07-20 11:16:08 -07:00
2026-08-03 20:11:28 -07:00
2026-06-01 21:34:12 -07:00
2026-03-30 20:30:05 -07:00
2026-07-24 15:04:31 -07:00
2026-05-31 19:54:43 -07:00
2026-05-31 19:54:43 -07:00
2026-03-02 00:33:37 -08:00
2026-07-03 00:29:26 -07:00
2026-07-08 00:59:14 -07:00
2026-07-08 00:59:14 -07:00
2026-07-08 00:59:14 -07:00
2026-07-03 00:29:26 -07:00
2026-03-02 16:55:12 -08:00
2026-07-08 00:59:14 -07:00
2026-05-31 19:54:43 -07:00
2026-04-04 22:19:03 -07:00
2026-04-16 13:30:25 -07:00
2026-07-08 00:59:14 -07:00
2026-04-26 22:14:22 -07:00
2026-08-04 04:53:17 -07:00
2026-04-26 13:11:07 -07:00
2026-07-01 21:05:57 -07:00
2026-07-17 11:28:44 -07:00
2026-07-17 20:08:56 -07:00
2026-07-29 22:11:38 -07:00
2026-05-30 14:03:39 -07:00
2026-07-04 20:54:20 -07:00
2026-08-03 20:11:28 -07:00
2026-08-04 04:53:17 -07:00
2026-08-04 05:19:03 -07:00
2026-05-22 15:13:39 -07:00
2026-03-30 20:30:05 -07:00
2026-08-03 20:11:28 -07:00
2026-08-04 04:53:17 -07:00
2026-08-02 15:15:02 -07:00
2026-07-03 00:29:26 -07:00
2026-06-26 08:38:31 -07:00
2026-07-13 22:39:19 -07:00
2026-07-07 08:20:57 -07:00
2026-08-04 04:53:17 -07:00
2026-07-07 23:32:20 -07:00
2026-07-17 11:28:44 -07:00
2026-08-05 12:58:55 -07:00
2026-08-03 20:11:28 -07:00
2026-05-31 19:03:16 -07:00
2026-05-31 19:54:43 -07:00
2026-08-02 06:15:40 -07:00
2026-07-03 17:30:33 -07:00
2026-05-24 14:56:43 -07:00
2026-05-24 14:56:43 -07:00
2026-05-24 14:56:43 -07:00
2026-07-03 19:16:36 -07:00
2026-03-17 01:26:44 -07:00
2026-03-23 11:11:40 -07:00
2026-03-16 15:45:21 -07:00
2026-05-08 13:58:02 -07:00
2026-07-03 19:16:36 -07:00
2026-07-03 19:16:36 -07:00
2026-07-03 19:16:36 -07:00
2026-07-20 22:38:32 -07:00
2026-07-17 11:28:44 -07:00
2026-07-24 18:15:03 -07:00
2026-07-20 22:38:32 -07:00
2026-07-20 22:38:32 -07:00
2026-07-20 22:38:32 -07:00
2026-04-25 20:11:47 -07:00
2026-07-07 08:20:57 -07:00
2026-05-11 01:23:54 -07:00
2026-04-04 17:53:20 -07:00
2026-05-24 14:56:43 -07:00
2026-04-18 10:20:19 -07:00
2026-06-04 11:03:13 -07:00
2026-07-07 08:20:57 -07:00
2026-06-28 20:24:20 -07:00
2026-06-28 20:24:20 -07:00
2026-07-03 19:16:36 -07:00
2026-08-05 12:58:55 -07:00
2026-06-16 03:41:51 -07:00
2026-04-01 19:38:24 -07:00
2026-06-16 17:10:12 -07:00
2026-04-01 19:38:24 -07:00
2026-05-30 16:27:15 -07:00
2026-03-25 16:07:05 -07:00
2026-06-04 11:03:13 -07:00
2026-03-30 20:30:05 -07:00
2026-03-12 14:49:58 -07:00
2026-08-02 01:48:30 -07:00
2026-08-04 04:53:17 -07:00
2026-07-20 07:25:56 -07:00
2026-08-05 12:58:55 -07:00
2026-08-05 00:23:11 -07:00
2026-03-23 11:11:40 -07:00
2026-06-16 17:10:12 -07:00
2026-07-10 15:42:33 -07:00
2026-08-02 15:15:02 -07:00
2026-05-14 15:13:00 -07:00
2026-07-07 16:42:36 -07:00
2026-08-05 12:58:15 -07:00
2026-06-01 11:01:30 -07:00
2026-07-03 19:16:16 -07:00
2026-07-07 23:32:20 -07:00
2026-07-10 15:59:40 -07:00
2026-07-24 15:04:31 -07:00
2026-07-20 07:25:56 -07:00