Skip to content

harness-backed Think: the view follows the session's change feed; streamed tool calls count before they're stored (harness score K, J) - #3476

Merged
mattzcarey merged 4 commits into
mainfrom
slim/harness-score-KJ
Nov 27, 2026
Merged

mattzcarey merged 4 commits into
mainfrom
slim/harness-score-KJ

Conversation

@mattzcarey

@mattzcarey mattzcarey commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Harness score, groups K and J: the rest that harness consented to (10:08), as one PR with one commit per change.

1. J: the shell's view follows the root session's change feed

As Think's does, the shell's transcript view now follows the root session's mirror with Think's rules:

  • a branch append re-syncs;
  • an update to a row the view doesn't hold marks media eviction's cursor stale (rowChangedOutsideCache);
  • an import marks the view stale, and a clear empties it;
  • a delete or a compaction re-syncs;
  • an append grows the view and counts toward eviction, and an update that grew a row invalidates the cursor.

The harness also forwards writes made straight to the session as message events, so the harness.observe handler no longer applies messages. It wakes the stable waiters, and it still re-syncs on reset and transcript. Before, an update to a row hidden under a compaction was treated as an append at the leaf.

  • New successor: media-eviction "evicts media a late update puts on a row the view does not hold". A pass runs on its own over a row with an image, which moves the cursor past the older rows. Then c1 is hidden under a compaction and given an image by an update made straight to the session. It fails without the mirror. The old test, which drives the private seam, becomes class-only with this successor.
  • Not listed: "counts appends that land during a fruitless pass" holds a pass open through the seam, the same shape rv-6 ruled app-visible on test(think): two more mechanics-only rows (harness score K, J) #3416.

2. K: a reply's streamed tool calls count before it is stored

As Think's in-flight accumulator does: the shell tracks each running operation's streamed tool calls from onChunk (tool-input-available, an approval request, and the output that settles them) and drops them at the turn's end. hasPendingInteraction() counts them as it counts stored ones.

  • New successor: client-tools "waits on it before the reply is stored". The reply is held open after the client tool's call, and hasPendingInteraction() is true mid-stream. "detects a pending CLIENT-tool interaction living ONLY in the in-flight accumulator" becomes class-only with it.
  • Not listed: "stops reporting pending once the accumulator's client-tool part resolves" needs the harness to apply a client's answer that lands while the reply streams (it answers against stored history), which is asked of harness. "dead SERVER-tool in the accumulator" has no public fixture.

3. The view's bookkeeping as Think's (rv-4, Devin)

  • Growth charged as Think charges it: an append charges its bytes plus HYDRATION_MESSAGE_OVERHEAD_BYTES, and an update that grew charges noteGrowth and invalidates the cursor, as _noteCachedReplacement does. The constant moves into transcript-cache.ts and both Thinks import it.
  • Re-windowed at a turn's end: a turn's end is a safe boundary, so a view grown past its budget re-windows there (refreshIfNeeded), as Think's does after a chat request. Before, nothing trimmed a view that browser chats grew, since the observer no longer re-reads.
  • One re-read per compaction: the observer no longer re-syncs on reset or transcript events, because the change feed's clear, delete and compaction cases do.
  • No prompt refresh: Think also refreshes its context's prompt on a compaction. On the harness-backed Think the harness's step loop owns the context and records the change itself.
  • The answerable set is built once per hasPendingInteraction() check.

Score (vitest.harness.config.ts, against main):

File Main This PR
media-eviction 18 of 31 19 of 32
client-tools 43 of 143 45 of 144

think-session (131) and hooks (121) are unchanged. Class suites: media-eviction 32/32, client-tools 144/144.

Cost: the mirror is the subscription Think already has, with no extra statement. Live calls are one in-memory map per running operation.

Shell lines: the observer block and a new mirror subscription in onStart; onChunk and onTurnEnd (one line each); #liveCalls and #noteLiveCall; hasPendingInteraction.

@changeset-bot

changeset-bot Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: ec220ef

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 Nov 27, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

agents

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

@cloudflare/ai-chat

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

@cloudflare/codemode

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

hono-agents

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

@cloudflare/shell

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

@cloudflare/think

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

@cloudflare/voice

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

@cloudflare/worker-bundler

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

commit: ec220ef

@agent-think

agent-think Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

✅ agents import sizes: no significant changes (62423fad → ec220ef9, workflow run)

devin-ai-integration[bot]

This comment was marked as resolved.

@mattzcarey
mattzcarey marked this pull request as draft November 27, 2026 13:08
…ed, as Think's does, so a write made straight to the session reaches media eviction
…ed, as Think's accumulator does; one successor
…urn's end re-windows it, one re-read per compaction; the answerable set is built once per check
@mattzcarey
mattzcarey force-pushed the slim/harness-score-KJ branch from b1b1316 to 298dd59 Compare November 27, 2026 13:20
@mattzcarey
mattzcarey marked this pull request as ready for review November 27, 2026 13:30
devin-ai-integration[bot]

This comment was marked as resolved.

@mattzcarey
mattzcarey marked this pull request as draft November 27, 2026 13:41
…eping, best-effort, so a failed read never skips the cleanup or onChatResponse
@mattzcarey
mattzcarey marked this pull request as ready for review November 27, 2026 13:54

@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 1 new potential issue.

Devin Review

Comment thread packages/think/src/harness/think.ts Resolved
@mattzcarey
mattzcarey merged commit c7bb201 into main Nov 27, 2026
20 checks passed
@mattzcarey
mattzcarey deleted the slim/harness-score-KJ branch November 27, 2026 14:01
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