Skip to content

ThinkHarness: sessions and client tools are Sessions values - #3158

Merged
mattzcarey merged 6 commits into
mainfrom
slim/harness-h4
Nov 25, 2026
Merged

mattzcarey merged 6 commits into
mainfrom
slim/harness-h4

Conversation

@mattzcarey

@mattzcarey mattzcarey commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

ThinkHarness keeps its list of sessions and each session's client tools as Sessions session values (think-harness:session with { parent?, createdAt }, and think-harness:client-tools), and no longer uses HarnessStore at runtime. A released version's harness store, and the 0.27 tables before it, is carried into Tasks and Sessions once, as the harness's schema step 1 on the Lifecycle's versions record, and its tables are then dropped.

After #3147 the store held only sessions and client tools, which are per-session values Sessions can keep (THINK-HARNESS.md, H4):

  • Neither key is under transcript:, so reset() keeps them, as before.
  • sessions.list() reads every session that holds think-harness:session, through one new internal read, Sessions.internal_configs(key), sorted oldest first as before.
  • The carry is idempotent: open operations become runs in batches of 50 (as in ThinkHarness: operations are runs on its own Tasks instance #3147), then sessions and client tools become values, 50 sessions at a time and without calling configureSession, then the store's tables are discarded, settled operations with them, unread. A start finds the tables with hasTable, not sqlite_master, and only while the step has not run.
  • At the root the tables are dropped. In a sub-agent they are emptied instead, as Fibers' carry does: a facet dropping indexed tables on its first start after an upgrade has reset its tree's storage on a deployment (RUNTIME-FACTS). The 0.27 tables follow the same rule.
  • A client tool declaration that is not a list reads as none, as the store's reader did.

Cost, per prompt() on the test fixture, main → this PR: rows written unchanged (21, 35, 39 for a plain reply, one tool call, two tool calls), rows read 115 → 113, 176 → 172, 186 → 182, statements down by one each, setAlarm 2 → 2. A cold start no longer opens the store (its CREATE TABLE IF NOT EXISTS and the legacy sqlite_master read); it reads the root session's value instead.

Harness compat score (pnpm test:harness): 174 → 173 of 1,246. The one test that changed, client-tools.test.ts > holds STREAM_RESUME_REQUEST while continuation is pending, is a race (its continuation ends in about 5 ms, before the resume probe 20 ms later) and fails 2 of 2 reruns on main too. harness-think (83, including a sub-agent emptying the released store, 120 sessions carried forward, a malformed client tool declaration), sessions/annotations and channels tests ran, plus pnpm run check.

How to probe: deploy main and this head with a ThinkHarness host at the root and in a sub-agent; on main create sessions (one forked), submit client tools, leave a queued and a running operation; deploy the head over it and check sessions.list() (ids, parents, order), the client tools on the next turn, both operations finishing, and the cf_think_harness_store_* tables gone at the root and empty in the sub-agent.

@changeset-bot

changeset-bot Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 475980d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
agents Patch
@cloudflare/agent-think Patch

Not sure what this means? Click here to learn what changesets are.

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

@pkg-pr-new

pkg-pr-new Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

agents

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

@cloudflare/ai-chat

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

@cloudflare/codemode

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

hono-agents

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

@cloudflare/shell

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

@cloudflare/think

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

@cloudflare/voice

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

@cloudflare/worker-bundler

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

commit: 475980d

@agent-think

agent-think Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

🟡 agents import sizes: 3 entry points grew

Entry point Exports Largest gzip change Size now
🟡 agents/experimental/channels 1 resized +253 B (+2.35%) 10.8 KiB
🟡 agents/chat 2 resized up to +244 B (+2.52%) 9.7 KiB
🟡 agents/streams 1 resized +243 B (+3.63%) 6.8 KiB
Changed exports (4)
Import Gzip change Size now
🟡 agents/experimental/channels#Channels +253 B (+2.35%) 10.8 KiB
🟡 agents/chat#createChatStreams +244 B (+2.52%) 9.7 KiB
🟡 agents/streams#Streams +243 B (+3.63%) 6.8 KiB
🟡 agents/chat#ResumableStream +132 B (+1.93%) 6.8 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 cfdd723f → 475980df · workflow run · reported by agent-think[bot]

@mattzcarey
mattzcarey marked this pull request as ready for review November 25, 2026 13:18
devin-ai-integration[bot]

This comment was marked as resolved.

… batches without configureSession; a non-list client tool declaration declares none
devin-ai-integration[bot]

This comment was marked as resolved.

@mattzcarey
mattzcarey merged commit b3009e1 into main Nov 25, 2026
26 checks passed
@mattzcarey
mattzcarey deleted the slim/harness-h4 branch November 25, 2026 13:46
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