Skip to content

Think on the harness: stop means stop, several approvals in one reply, the tab's window, and more - #3562

Merged
mattzcarey merged 16 commits into
mainfrom
slim/push-29-shell
Dec 2, 2026
Merged

mattzcarey merged 16 commits into
mainfrom
slim/push-29-shell

Conversation

@mattzcarey

@mattzcarey mattzcarey commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

The harness-backed Think only (the shell; the exported Think class is not changed by this PR): stop means stop, several approvals in one reply, a carried partial reply, context kept in memory, a stop during a backoff, the tab's window of the chat, one origin per turn, an echoed row, a stream left open, and a long path at hydration. Each unit below was reviewed on its own; the suites' proof is this PR's CI (locally: build, check and the changed test files, 405 passed).

# Unit Commit on local-main
1 waitUntilStable() on the harness-backed Think could report false at its deadline for a chat that was stable. b1644b939
2 Think publishes chat:continuation:dropped with reason stopped when a stop drops a continuation a tab's answer asked for. ThinkHarness withdrew the queued continuation on a stop and published nothing, so an app that stops every chat with cancelAllChats() never heard of it. 6c088c20f
3 Stop means stop, as on Think. Two cases on the harness-backed Think did not hold. be0280945
4 The lead's rule for approvals of durable pauses, taken from verify's run of think@0.24.0: a reply that parked two calls continues after each approval. An approval that arrives while another one's continuation still waits to start joins it. The reply never waits for every pause: with one approved and one left undecided it goes on, and the other stays approvable and continues again when approved. However many continuations, the reply is one assistant message. f03bc0e2f
5 The upgrade case rv-1 asked for beside slim/harness-carry-applied's test. 2a1276032
6 think@0.24.0 kept the last request's client tools and body in two config rows. When they are over the row budget together, Think does not store them, but the isolate that read them still runs with them: a turn the server starts there is offered the release's client tools. After the next restart they are gone. cbdd75e75
7 Think reports chat:recovery:skipped with reason user_cancelled when a tab stops a turn that is waiting to be retried, for example during a rate limit's retry-after, and it keeps what the turn had streamed. d47c40a36
8 With hydrationByteBudget set, Think holds the newest messages that fit and sends its tabs those. The harness-backed Think sent a tab the whole chat: at connect, when a message was placed, and at a turn's end. Verify measured about 350 KB a frame at about 1,700 stored messages, several times a turn (P14-4). df6106c89
9 Closes the last difference verify measured against think@0.24.0 under hydrationByteBudget (WF-5): in a warm object the harness-backed Think asked the model with one message more than its view holds. e845f14b9
10 The harness-backed Think runs each tool's execute and each hook inside the connection of the tab the turn runs for. It asked the harness for that tab every time, and each ask read the run's record. 205bb043c
11 The lead's ruling: on a stop, a server call that was approved but never started stays approval-responded, as on Think. Only a reset reports a call as interrupted. b7f71d443
12 A tab's reconciled list may hold replies the transcript lacks. ThinkHarness took them only before the question the list ends in. A list with a reply after its question, such as a tab echoing a paused call under a message id of its own, was turned away whole as client_role. The question was not stored and nothing answered it. 2b0f1a95b
13 The lead's ruling on COA-1: two approvals of durable pauses fired at the same moment join one continuation, as on think@0.24.0. 123611898
14 test(think): my answered-replay test follows the coalesce rule 2a1fabca4
15 Harness-backed Think: the system prompt is frozen from the window, not the whole path 0ecf49fd5
16 Think on the harness: a tab that comes back before the reply's first chunk is offered the stream, as on Think 7a9d3c7e2

1. waitUntilStable() on the harness-backed Think could report false at its deadline for a chat that was stable.

Its waiters were woken at a run's end and on a transcript change. A run's end is told before its operation has settled, so a waiter that looked then still saw the operation open and waited again, and nothing woke it afterwards. Each round now also ends when the oldest open operation settles.

Test: client-tools "reports stable only after the continuation the batch's last result armed has run". It timed out on the harness config and passes on both configs.


2. Think publishes chat:continuation:dropped with reason stopped when a stop drops a continuation a tab's answer asked for. ThinkHarness withdrew the queued continuation on a stop and published nothing, so an app that stops every chat with cancelAllChats() never heard of it.

The stop now publishes the event through the chat host, both for a queued continuation it withdraws and for one still only asked for while its reply streams.

Test

client-tools "cancelAllChats also drops the continuation of a result answered while the reply streamed", in its public form (the wait on a class private replaced by the server having handled the result). That form is finish's and is carried with this unit.


3. Stop means stop, as on Think. Two cases on the harness-backed Think did not hold.

  • A stop of every turn with nothing running. A reply holds two client calls. The first answer asks to continue and waits for its sibling. cancelAllChats() left that request in place, because the stop returned before it dropped it, so the sibling's later answer continued the reply though it asked for nothing.
  • A tab's stop of a running continuation. An answer that arrived while the continuation ran had queued another continuation behind it. That one ran after the stop. Every tool answer's continuation queued behind a running turn that is stopped is now withdrawn and published as dropped.

Tests

client-tools, harness config:

  • "a stop of everything drops a continuation waiting on a sibling: the sibling's answer alone does not continue"
  • "a tab's stop of a running continuation drops the answer that arrived while it ran"

Both read green before only because the file's settled() returned before a continuation that was still to start. finish's fix to settled() (it also waits through waitUntilStable) is carried as the first commit; with it both failed on the harness config, and pass on both configs now.


4. The lead's rule for approvals of durable pauses, taken from verify's run of think@0.24.0: a reply that parked two calls continues after each approval. An approval that arrives while another one's continuation still waits to start joins it. The reply never waits for every pause: with one approved and one left undecided it goes on, and the other stays approvable and continues again when approved. However many continuations, the reply is one assistant message.

On the harness-backed Think two things differed.

  • A decision's outcome held its continuation back when the reply "already ended in an answer". With calls parked in separate steps, a later step had parked another call and said so, so the first approval made no model call and only the last one continued. That gate is removed.
  • Each decision started its own continuation. One is no longer started while another decision's continuation of the session is still queued; that one reads both outcomes.

Test

actions-public "continues after each approval, with the outcomes so far", on the harness config. Two calls are parked in two steps. The first approval gives one more model call with the other call still pending, the second gives one more, and the conversation holds one assistant message. Before the change the first approval made no call.

The class Think waits for every pause and takes the rule with the flip, so the case is skipped on the class config. The fixture's model gains a "pause in two steps" script and an answer to a continue prompt.

verify gates the three cells on a deployment: back to back, 2 s apart, and one approved with one left undecided.

Not covered by a test

The join of an approval to a continuation that has not started. No public gate holds a continuation between queued and started without another turn in front of it, which moves the chat on. It rests on verify's back-to-back cell.


5. The upgrade case rv-1 asked for beside slim/harness-carry-applied's test.

A row think@0.24.0 left running and unmarked, with the first of its two messages already in the conversation, ends in error "Submission was interrupted after messages were partially applied." after the upgrade. It is not answered again and its second message is not stored.

Test only: submissions "fails a running row with only some of its messages stored as partially applied, without answering it again". It passes on both configs.


6. think@0.24.0 kept the last request's client tools and body in two config rows. When they are over the row budget together, Think does not store them, but the isolate that read them still runs with them: a turn the server starts there is offered the release's client tools. After the next restart they are gone.

The harness-backed Think stored nothing and kept nothing, so that first turn ran without the tools.

ThinkHarness now keeps such a context for the isolate through an internal method, keepRequestContext. Its client tools and body serve the turns placed there. They are not written, so a restart runs without them, as it runs without the context. A newer declaration or a clear ends it.

Tests

land's, in think-session, both configs:

  • "offers the release's client tools to a server turn in the isolate that read them, though they are over the row budget" failed on the harness config and passes now.
  • "deletes the release's request context when it is over the row budget, and nothing brings it back" still holds.

Not in this PR

A live request whose context is over the row budget. The class keeps that in memory for the isolate too; the shared chat turn drops it. That is the chat module's.


7. Think reports chat:recovery:skipped with reason user_cancelled when a tab stops a turn that is waiting to be retried, for example during a rate limit's retry-after, and it keeps what the turn had streamed.

The harness-backed Think took every stop of an open turn to the harness, which ended the run and reported no recovery outcome. A turn waiting out a retry is now left to the shared chat dispatch, which ends it as it ends the other hosts'.

Test (land's): think-session "reports a retry a tab stopped while it waited as skipped by the user, not given up". It failed on the harness config and passes on both configs.


8. With hydrationByteBudget set, Think holds the newest messages that fit and sends its tabs those. The harness-backed Think sent a tab the whole chat: at connect, when a message was placed, and at a turn's end. Verify measured about 350 KB a frame at about 1,700 stored messages, several times a turn (P14-4).

Two changes:

  • ThinkChat takes the host's view of the transcript through a plumbing option, transcript(reread). It is the messages the agent holds in memory, read again first only when something other than a turn wrote. Every list ThinkChat sends, and /get-messages, is that view.
  • ThinkHarness passes the host's hydrationByteBudget to the chat turn. A turn then reads, and sends with its own lists, the newest messages that fit, as the class's turn reads its window.

The second change also bounds what the model is sent on a chat over the budget, as on the class. The default budget is 32 MiB, so a chat under it is unchanged.

Test

window-frames.test.ts "sends the window at connect and with a turn's lists": ten stored messages of about 30 KB under a 64 KB budget. On the harness config the connect's list held all ten. It passes on both Thinks.

Cost: a connect and a turn's own lists no longer read the stored transcript. A turn under a budget reads the newest messages that fit instead of the whole path.

Not covered here: the read counts of the rest of a turn (the run-record and config reads in verify's flipcost-diff.md), and the shared chat dispatch's own whole-history reads.

Warm objects and list frames (verify's FIX)

verify measured two differences from think@0.24.0 in an object that had not restarted, and extra list frames.

  • A connect re-windowed the view first, so a view that held what this lifetime appended was cut to the window. Think sends this.messages as it stands. A connect no longer re-windows.
  • A tab was sent four lists during one turn where Think sends one. The question's placement reached the tab that asked, because ThinkChat did not know the origin of a turn the shared dispatch started. The chat turn's own writes, its question and its reply, also came back through the session's change feed as messages written outside a turn. The tab that asked is now left out of the placement's list, and the running turn's own question and reply are not told a second time.

Tests, both configs, both failing first on the harness config: "sends a connecting tab the agent's view as it stands, with what this lifetime appended" (new), and "sends the window at connect and with a turn's lists", which now expects exactly two lists: the connect's and the turn's end.

  • A view grown past its budget re-windowed at a turn's end. Think re-windows after it stores the turn's question, so after the turn its view is that window with the reply. The harness-backed Think now re-windows at the same moment. New test, both configs: "holds the same view as Think after twenty turns in one lifetime" (budget 2,000: the view's size after each of twenty turns; the harness config held 14 where Think holds 16, then 15).

9. Closes the last difference verify measured against think@0.24.0 under hydrationByteBudget (WF-5): in a warm object the harness-backed Think asked the model with one message more than its view holds.

Cause

The shell stamped channel: "web" on a browser's new user message when the turn's first model call was prepared. That was a read and a second write of the message every turn, and it landed after the turn had read its window. The stamp grows the row (74 to 103 bytes in the test), so the window the turn had read could be one message longer than a read made afterwards. Think stores the message with its channel when it takes the request.

Fix

ThinkHarness takes the host's stamp for an operation's user messages through an internal plumbing option, questionMetadata, and writes it with them when they are placed. The shell gives { channel: "web" } for a browser's request and no longer stamps afterwards.

Test

window-frames "holds the same view as Think after twenty turns in one lifetime", both configs. It now also compares what the model is asked with, turn by turn. The windowed fixture records each request's size. It failed on the harness config.

Cost

One read and one write fewer per browser turn.


10. The harness-backed Think runs each tool's execute and each hook inside the connection of the tab the turn runs for. It asked the harness for that tab every time, and each ask read the run's record.

A run's origin does not change, so it is now kept with the operation while it runs here.

Cost

One read of the run's record per operation for its origin, where there was one per tool call and hook. verify's table had the run record read 7 times by the class and 40 times by the harness-backed Think in a twenty-tool turn; verify re-measures.

No behaviour change. harness-think 225, and client-tools, hooks and tab-closes-mid-tool on the harness config are unchanged.


11. The lead's ruling: on a stop, a server call that was approved but never started stays approval-responded, as on Think. Only a reset reports a call as interrupted.

The harness-backed Think failed such a call when it kept the stopped turn's reply: as interrupted, or as "no longer available" for a tool the build lacks. A tab's later result for it then had nothing to settle, and nothing continued.

The calls an attempt starts are now noted. The reply a stop keeps leaves an approved call that was never started untouched.

Test

client-tools "an answer that arrives after a tab stopped a running continuation still continues", finish's public form of row 21, carried here. Its helper now reads the reply's calls only, since a Think that stores one message keeps the stopped continuation's step start in the same reply. It timed out on the harness config and passes on both configs.


12. A tab's reconciled list may hold replies the transcript lacks. ThinkHarness took them only before the question the list ends in. A list with a reply after its question, such as a tab echoing a paused call under a message id of its own, was turned away whole as client_role. The question was not stored and nothing answered it.

Think stores the question and that reply and answers from there. The harness now does the same for a reconciled list. Input that is not a reconciled list may still only add user messages.

Test

parity's #1992 case, both configs: actions-public "does not resolve a later identical paused call a tab echoes under its own message". On the harness config neither the question nor the echoed reply was stored. It now passes on both: the first call keeps its outcome, the echoed one stays paused, and the action ran once.


13. The lead's ruling on COA-1: two approvals of durable pauses fired at the same moment join one continuation, as on think@0.24.0.

On the release the continuation after an approval is a queue item with one id. An approval that arrives before the item has run replaces it, and one model call reads both outcomes. One that arrives while its continuation runs queues the next. The harness-backed Think started the continuation at once, so two approvals fired together made two model calls (verify: 8 of 8 runs; the release makes one in 10 of 14).

The shell now starts a decision's continuation through a queue item too. The item and its callback carry the names the release queued its own under, so an item a release left queued is run after an upgrade. A stop of every turn dequeues it, and waitUntilStable counts it as work to come.

Lands with slim/harness-coalesce-approvals and land's slim/land-coalesce-tests.

Test

actions-public "joins approvals that arrive before the continuation has started", on the harness config. Two calls are parked in two steps and both are approved at once: one more model call, both outcomes stored, one assistant message. It made two calls before; 5 of 5 runs pass. The class Think takes the rule with the flip, so the case is skipped there.

verify re-runs its three cells.


14. test(think): my answered-replay test follows the coalesce rule

One commit on slim/harness-coalesce-approvals 58cf7b3e6. Tests and one fixture only. It lands with harness's unit: that unit turns my test red on the harness config.

Why. durable-pause-answered-replay.test.ts (from land-pr20-devin, Devin P4ad) pinned 'an approved pause whose reply already answered is not continued, also when the report is replayed'. The lead's coalesce ruling removes that gate: the reply continues after each approval, as think@0.24.0 does. With the gate, the chat:continuation:dropped 'answered' event is gone too, and my test cut the report at that event.

What the test asserts now (harness-backed Think only; the class takes the rule at the flip):

  • The 'with a receipt' reply is approved: the reply is continued ONCE (one more model call, 'continued with 5'), the waiting text is gone, and the later step's text is kept.
  • No decision run is kept once the report has run to its end (the gate Devin's Q13W asked for).
  • A real restart after it continues nothing more: the model calls stay the same, nothing is pending, the outcome is in place.

What it no longer shows, said in the file: a reset BETWEEN the outcome's write and the continuation. There is no public seam at that point any more.

  • I tried throwing from broadcast; the write does not go through it.
  • The 'once' there rests on two things by design: the continuation's choice is kept on the run before the write, and its operation id is the execution's (decision-continue:<executionId>).

Fixture: the _emit override and its flag are removed (dead with the event); decisionRunsKeptForTest and resetStoredForTest stay.

Runs. The file: skipped on the class config, passes twice on the harness config. actions-public, durable-pause-mid-reply and -later-turns: the class config passes; on the harness config one test fails, 'keeps the outcome when a tab that missed it resends the transcript from before the approval', which fails the same on 58cf7b3e6~1 (not from this unit or harness's).


15. Harness-backed Think: the system prompt is frozen from the window, not the whole path

One commit on harness's stack top slim/harness-echoed-row 5b7f416. One hunk in the shell (packages/think/src/harness/think.ts, 6 lines). Shell only (the harness-backed Think is unreleased): no changeset line. harness's OK on the hunk is asked.

The gap. hydration-budget "a tab's resent transcript, over a socket > matches on a path too long to read root-first" timed out at 120 s on the harness config; the class answers. The chat holds 200,005 messages and a tab resends its oldest message with a new question.

The cause, measured. The reconcile itself was fine (harness's G19 work reads by id). The turn then failed while preparing its model call: the shell's system option called Context.freezeSystemPrompt() with no history, so Context read the session's whole active path, and Sessions refuses a root-first read of more than 200,000 messages (SessionPathTooLongError). I found it with a stack trace on Session.getHistory (probe removed).

The fix. The shell passes the window it holds (this.messages, bounded by hydrationByteBudget). ContextReadOptions.messages is documented for exactly that: "a host that already holds the transcript, or a bounded window of it, passes it".

Tests. The socket twin is the failing-first test: timeout before, passes after (about 10 s). No new test.

  • hydration-budget: class 28 of 28; harness config, the only red test that is not a row is the class-private twin 'reconciles on a path too long to read root-first', which parity-2 rows on the socket twin now that it passes.
  • context-upgrade and think-session's system-prompt tests on the harness config: no red test that is not a row.
  • Typecheck, oxfmt and oxlint clean.

Cost. One whole-path read fewer per model-call preparation on an agent with no context blocks and no overridden getSystemPrompt.

For the reviewer and harness.

  • The window is read as it is when the call is prepared. If it could be empty there on a chat with stored messages, an agent whose release froze a prompt would fall back to getSystemPrompt(); I believe the turn hydrates the window before this, and no test says otherwise. Say if you know a path where it is not.
  • Seen on the way, not changed here: when the turn failed with that error, the tab got no end for its request (the test waited out 120 s). On the class a failed turn ends the request with an error.

For verify: a tab can see it (a turn on a very long chat answers instead of failing).


16. Think on the harness: a tab that comes back before the reply's first chunk is offered the stream, as on Think

One commit on slim/local-main 8bfd95041 (rebased over harness's chain, with harness's two notes). agents/src/harness/think/harness.ts, types.ts and the shell (packages/think/src/harness/think.ts): harness's files, written by switch as the difference's owner (the conductor); harness's OK asked on the sha. No change in the chat module.

What was different

A tab that asks to resume is offered the running turn once its reply has begun (its start was seen), and is held (cf_agent_stream_pending) before that. On Think the reply's stream has started when beforeStep runs (the AI SDK's prepareStep), so a turn held there is offered; during beforeTurn there is no stream and the tab is held. The harness-backed Think runs both hooks inside the harness's beforeTurn callback, before streamText is called, so the start came only with the model's first output: a fresh turn held in beforeStep answered pending where Think offers the stream (parity-2's finding; onconnect-broadcast "tells no reconnecting tab of a failed turn once a new question is asked, while its reply has not started", red on the harness config).

The fix

The hook's context gets begin(messageMetadata?) (@internal): the host says its configuration is done and the model call starts. The shell calls it between its beforeTurn and beforeStep. The loop then yields the reply's start at once (the message id it already chose, with the metadata the writer gives for start and the turn's owner, by the same rule as before), and drops the model's own start when it comes; the writer is not asked twice for it. A host that never calls begin behaves as before.

Rebased over harness's chain (8bfd95041)

harness OK'd the hunks in its three files, with two notes, both done: (a) begin goes through #prepareCall, so the hook hears it on both paths: the model call's, and the one that runs ahead of a tab's answered tool calls (there the start is yielded right after the preparation); the start's metadata is one private method (#replyMetadata) used by the early start and by the stream's own parts; (b) a model call that fails after the early start still reports stage: "turn": the shell's onChunk does not count a start as streamed (client-tools '#2381 reports an approval continuation that fails before streaming' passes on the harness config).

Validated

  • On 8bfd95041, the same seven Think files on the harness config, before and after (347 tests): 71 failures before, 69 after; the two that differ are the onconnect-broadcast test and client-tools 'a tab's stop of a running continuation drops the answer that arrived while it ran' (both now pass); nothing else changed. harness-think 225 of 225. (The lines below are the first cut's, on the earlier base.)
  • The onconnect-broadcast test, UNCHANGED, passes on the harness config (it failed) and on the class.
  • Seven Think files on the harness config, before and after on the same tree (assistant-message-metadata, onconnect-broadcast, client-tools, chat-recovery-public, one-reply, stop-reason, errored-stream-replay; 343 tests): 75 failures before, 74 after; the one that differs is that test; nothing else changed. (A first cut without the start's metadata broke two metadata tests: fixed by passing the writer to begin.)
  • client-tools "holds STREAM_RESUME_REQUEST while continuation is pending" and "releases a held STREAM_RESUME_REQUEST when the continuation fails before streaming" pass on the harness config.
  • agents --project harness-think 224 of 224; tsc (agents, think); oxlint; check:public-api clean.
  • NOT run: the whole Think suite on either config; a deployment. rv-2 also measured the shell sending a chat_messages list before the offer at connect (Think sends none): not looked at here.

Cost

One promise race per model call until the reply has started.

Changeset

None (the harness-backed Think is not released).


Devin Review

…at its deadline for a chat that was stable.

Its waiters were woken at a run's end and on a transcript change. A run's end is told before its operation has settled, so a waiter that looked then still saw the operation open and waited again, and nothing woke it afterwards. Each round now also ends when the oldest open operation settles.

Test: client-tools "reports stable only after the continuation the batch's last result armed has run". It timed out on the harness config and passes on both configs.

Unit: slim/harness-stable-settled @30378fd72 (base bd29299a4)
…n a stop drops a continuation a tab's answer asked for. `ThinkHarness` withdrew the queued continuation on a stop and published nothing, so an app that stops every chat with `cancelAllChats()` never heard of it.

The stop now publishes the event through the chat host, both for a queued continuation it withdraws and for one still only asked for while its reply streams.

## Test

client-tools "cancelAllChats also drops the continuation of a result answered while the reply streamed", in its public form (the wait on a class private replaced by the server having handled the result). That form is finish's and is carried with this unit.

Unit: slim/harness-stop-dropped @f363bf66a (base 30378fd72)
…id not hold.

- **A stop of every turn with nothing running.** A reply holds two client calls. The first answer asks to continue and waits for its sibling. `cancelAllChats()` left that request in place, because the stop returned before it dropped it, so the sibling's later answer continued the reply though it asked for nothing.
- **A tab's stop of a running continuation.** An answer that arrived while the continuation ran had queued another continuation behind it. That one ran after the stop. Every tool answer's continuation queued behind a running turn that is stopped is now withdrawn and published as dropped.

## Tests

client-tools, harness config:

- "a stop of everything drops a continuation waiting on a sibling: the sibling's answer alone does not continue"
- "a tab's stop of a running continuation drops the answer that arrived while it ran"

Both read green before only because the file's `settled()` returned before a continuation that was still to start. finish's fix to `settled()` (it also waits through `waitUntilStable`) is carried as the first commit; with it both failed on the harness config, and pass on both configs now.

Unit: slim/harness-stop-requests @c83651139 (base f363bf66a)
…run of think@0.24.0: a reply that parked two calls continues after each approval. An approval that arrives while another one's continuation still waits to start joins it. The reply never waits for every pause: with one approved and one left undecided it goes on, and the other stays approvable and continues again when approved. However many continuations, the reply is one assistant message.

On the harness-backed Think two things differed.

- A decision's outcome held its continuation back when the reply "already ended in an answer". With calls parked in separate steps, a later step had parked another call and said so, so the first approval made no model call and only the last one continued. That gate is removed.
- Each decision started its own continuation. One is no longer started while another decision's continuation of the session is still queued; that one reads both outcomes.

## Test

actions-public "continues after each approval, with the outcomes so far", on the harness config. Two calls are parked in two steps. The first approval gives one more model call with the other call still pending, the second gives one more, and the conversation holds one assistant message. Before the change the first approval made no call.

The class Think waits for every pause and takes the rule with the flip, so the case is skipped on the class config. The fixture's model gains a "pause in two steps" script and an answer to a continue prompt.

verify gates the three cells on a deployment: back to back, 2 s apart, and one approved with one left undecided.

## Not covered by a test

The join of an approval to a continuation that has not started. No public gate holds a continuation between queued and started without another turn in front of it, which moves the chat on. It rests on verify's back-to-back cell.

Unit: slim/harness-coalesce-approvals @b2e1b08d2 (rv-1; base 8226866)
… test.

A row think@0.24.0 left `running` and unmarked, with the first of its two messages already in the conversation, ends in error "Submission was interrupted after messages were partially applied." after the upgrade. It is not answered again and its second message is not stored.

Test only: submissions "fails a running row with only some of its messages stored as partially applied, without answering it again". It passes on both configs.

Unit: slim/harness-carry-partial @3d5569973 (rv-1; base b2e1b08)
…fig rows. When they are over the row budget together, Think does not store them, but the isolate that read them still runs with them: a turn the server starts there is offered the release's client tools. After the next restart they are gone.

The harness-backed Think stored nothing and kept nothing, so that first turn ran without the tools.

`ThinkHarness` now keeps such a context for the isolate through an internal method, `keepRequestContext`. Its client tools and body serve the turns placed there. They are not written, so a restart runs without them, as it runs without the context. A newer declaration or a clear ends it.

## Tests

land's, in think-session, both configs:

- "offers the release's client tools to a server turn in the isolate that read them, though they are over the row budget" failed on the harness config and passes now.
- "deletes the release's request context when it is over the row budget, and nothing brings it back" still holds.

## Not in this PR

A live request whose context is over the row budget. The class keeps that in memory for the isolate too; the shared chat turn drops it. That is the chat module's.

Unit: slim/harness-context-in-memory @58771a430 (rv-1; base 3d55699)
…en a tab stops a turn that is waiting to be retried, for example during a rate limit's `retry-after`, and it keeps what the turn had streamed.

The harness-backed Think took every stop of an open turn to the harness, which ended the run and reported no recovery outcome. A turn waiting out a retry is now left to the shared chat dispatch, which ends it as it ends the other hosts'.

Test (land's): think-session "reports a retry a tab stopped while it waited as skipped by the user, not given up". It failed on the harness config and passes on both configs.

Unit: slim/harness-stop-in-backoff @7eacddbc6 (rv-1; base 58771a4)
…fit and sends its tabs those. The harness-backed Think sent a tab the whole chat: at connect, when a message was placed, and at a turn's end. Verify measured about 350 KB a frame at about 1,700 stored messages, several times a turn (P14-4).

Two changes:

- `ThinkChat` takes the host's view of the transcript through a plumbing option, `transcript(reread)`. It is the messages the agent holds in memory, read again first only when something other than a turn wrote. Every list `ThinkChat` sends, and `/get-messages`, is that view.
- `ThinkHarness` passes the host's `hydrationByteBudget` to the chat turn. A turn then reads, and sends with its own lists, the newest messages that fit, as the class's turn reads its window.

The second change also bounds what the model is sent on a chat over the budget, as on the class. The default budget is 32 MiB, so a chat under it is unchanged.

## Test

`window-frames.test.ts` "sends the window at connect and with a turn's lists": ten stored messages of about 30 KB under a 64 KB budget. On the harness config the connect's list held all ten. It passes on both Thinks.

Cost: a connect and a turn's own lists no longer read the stored transcript. A turn under a budget reads the newest messages that fit instead of the whole path.

Not covered here: the read counts of the rest of a turn (the run-record and config reads in verify's `flipcost-diff.md`), and the shared chat dispatch's own whole-history reads.

## Warm objects and list frames (verify's FIX)

verify measured two differences from think@0.24.0 in an object that had not restarted, and extra list frames.

- A connect re-windowed the view first, so a view that held what this lifetime appended was cut to the window. Think sends `this.messages` as it stands. A connect no longer re-windows.
- A tab was sent four lists during one turn where Think sends one. The question's placement reached the tab that asked, because ThinkChat did not know the origin of a turn the shared dispatch started. The chat turn's own writes, its question and its reply, also came back through the session's change feed as messages written outside a turn. The tab that asked is now left out of the placement's list, and the running turn's own question and reply are not told a second time.

Tests, both configs, both failing first on the harness config: "sends a connecting tab the agent's view as it stands, with what this lifetime appended" (new), and "sends the window at connect and with a turn's lists", which now expects exactly two lists: the connect's and the turn's end.

- A view grown past its budget re-windowed at a turn's end. Think re-windows after it stores the turn's question, so after the turn its view is that window with the reply. The harness-backed Think now re-windows at the same moment. New test, both configs: "holds the same view as Think after twenty turns in one lifetime" (budget 2,000: the view's size after each of twenty turns; the harness config held 14 where Think holds 16, then 15).

Unit: slim/harness-window-frames @3e9ffdfd2 (rv-1; base 7eacddb)
… `hydrationByteBudget` (WF-5): in a warm object the harness-backed Think asked the model with one message more than its view holds.

## Cause

The shell stamped `channel: "web"` on a browser's new user message when the turn's first model call was prepared. That was a read and a second write of the message every turn, and it landed after the turn had read its window. The stamp grows the row (74 to 103 bytes in the test), so the window the turn had read could be one message longer than a read made afterwards. Think stores the message with its channel when it takes the request.

## Fix

`ThinkHarness` takes the host's stamp for an operation's user messages through an internal plumbing option, `questionMetadata`, and writes it with them when they are placed. The shell gives `{ channel: "web" }` for a browser's request and no longer stamps afterwards.

## Test

window-frames "holds the same view as Think after twenty turns in one lifetime", both configs. It now also compares what the model is asked with, turn by turn. The windowed fixture records each request's size. It failed on the harness config.

## Cost

One read and one write fewer per browser turn.

Unit: slim/harness-window-request @b29f1c3b9 (rv-1; base 3e9ffdf)
…ide the connection of the tab the turn runs for. It asked the harness for that tab every time, and each ask read the run's record.

A run's origin does not change, so it is now kept with the operation while it runs here.

## Cost

One read of the run's record per operation for its origin, where there was one per tool call and hook. verify's table had the run record read 7 times by the class and 40 times by the harness-backed Think in a twenty-tool turn; verify re-measures.

No behaviour change. harness-think 225, and client-tools, hooks and tab-closes-mid-tool on the harness config are unchanged.

Unit: slim/harness-origin-once @e6dbdd947 (rv-1; base b29f1c3)
…er started stays `approval-responded`, as on Think. Only a reset reports a call as interrupted.

The harness-backed Think failed such a call when it kept the stopped turn's reply: as interrupted, or as "no longer available" for a tool the build lacks. A tab's later result for it then had nothing to settle, and nothing continued.

The calls an attempt starts are now noted. The reply a stop keeps leaves an approved call that was never started untouched.

## Test

client-tools "an answer that arrives after a tab stopped a running continuation still continues", finish's public form of row 21, carried here. Its helper now reads the reply's calls only, since a Think that stores one message keeps the stopped continuation's step start in the same reply. It timed out on the harness config and passes on both configs.

Unit: slim/harness-stop-keeps-approved @2337bcfdb (rv-1; base e6dbdd9)
…Harness` took them only before the question the list ends in. A list with a reply after its question, such as a tab echoing a paused call under a message id of its own, was turned away whole as `client_role`. The question was not stored and nothing answered it.

Think stores the question and that reply and answers from there. The harness now does the same for a reconciled list. Input that is not a reconciled list may still only add user messages.

## Test

parity's #1992 case, both configs: actions-public "does not resolve a later identical paused call a tab echoes under its own message". On the harness config neither the question nor the echoed reply was stored. It now passes on both: the first call keeps its outcome, the echoed one stays paused, and the action ran once.

Unit: slim/harness-echoed-row @5b7f4160b (rv-1; base 2337bcf)
…the same moment join one continuation, as on think@0.24.0.

On the release the continuation after an approval is a queue item with one id. An approval that arrives before the item has run replaces it, and one model call reads both outcomes. One that arrives while its continuation runs queues the next. The harness-backed Think started the continuation at once, so two approvals fired together made two model calls (verify: 8 of 8 runs; the release makes one in 10 of 14).

The shell now starts a decision's continuation through a queue item too. The item and its callback carry the names the release queued its own under, so an item a release left queued is run after an upgrade. A stop of every turn dequeues it, and `waitUntilStable` counts it as work to come.

Lands with `slim/harness-coalesce-approvals` and land's `slim/land-coalesce-tests`.

## Test

actions-public "joins approvals that arrive before the continuation has started", on the harness config. Two calls are parked in two steps and both are approved at once: one more model call, both outcomes stored, one assistant message. It made two calls before; 5 of 5 runs pass. The class Think takes the rule with the flip, so the case is skipped there.

verify re-runs its three cells.

Unit: slim/harness-coalesce-queued @e75fe3408 (rv-1; base 5b7f416)
…pproved pause's reply is continued once, and a restart after it continues nothing more; its 'answered' seam is gone with the gate

Unit: slim/land-coalesce-tests @ce92ed64a (rv-2; tests for the shell stack)
…t the whole path (hydration-budget's long path)

A tab's resent transcript on a chat too long to read root-first (200,005
messages) failed its turn: preparing the model call read the whole path to
find the system prompt the chat had been sent (Context.freezeSystemPrompt
with no history), and Sessions refuses a root-first read that long. The
shell now passes the window it holds, which Context is written to take.

Unit: slim/land-hb-long-path @cb2da004d (rv approved)
…so a returning tab is offered it as on Think

Unit: slim/switch-shell-stream-open @cb2ccf4f4 (rv-1 approved 787c5bbb6; rebase; verify PASS d0c32a2fb by diff)
@changeset-bot

changeset-bot Bot commented Dec 2, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 86a2032

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Dec 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

agents

npm i https://pkg.pr.new/agents@3562

@cloudflare/ai-chat

npm i https://pkg.pr.new/@cloudflare/ai-chat@3562

@cloudflare/codemode

npm i https://pkg.pr.new/@cloudflare/codemode@3562

hono-agents

npm i https://pkg.pr.new/hono-agents@3562

@cloudflare/shell

npm i https://pkg.pr.new/@cloudflare/shell@3562

@cloudflare/think

npm i https://pkg.pr.new/@cloudflare/think@3562

@cloudflare/voice

npm i https://pkg.pr.new/@cloudflare/voice@3562

@cloudflare/worker-bundler

npm i https://pkg.pr.new/@cloudflare/worker-bundler@3562

commit: 86a2032

@agent-think

agent-think Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

🟡 agents import sizes: 1 entry point grew

Entry point Exports Largest gzip change Size now
🟡 agents/harness/think 1 resized +103 B (+1.73%) 5.9 KiB
Changed exports (1)
Import Gzip change Size now
🟡 agents/harness/think#ThinkChat +103 B (+1.73%) 5.9 KiB
How this works

Each runtime export is bundled on its own, minified, and gzipped. Changes smaller than 100 B, or smaller than 1% and 1 KiB, are ignored. Growth over 10% or 5 KiB is marked 🔴. This report is informational and does not fail CI. The workflow artifact contains every measurement.

Compared 880282f4 → 86a20324 · workflow run · reported by agent-think[bot]

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 7 potential issues.

Devin Review

Comment thread packages/think/src/harness/think.ts Resolved
Comment thread packages/think/src/harness/think.ts Resolved
@mattzcarey
mattzcarey merged commit c1c4893 into main Dec 2, 2026
34 checks passed
@mattzcarey
mattzcarey deleted the slim/push-29-shell branch December 2, 2026 11:00
mattzcarey added a commit that referenced this pull request Dec 2, 2026
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.

1 participant