Skip to content

ThinkHarness tells the model once when the tools change - #3250

Merged
mattzcarey merged 6 commits into
mainfrom
slim/ext-e3c
Nov 26, 2026
Merged

mattzcarey merged 6 commits into
mainfrom
slim/ext-e3c

Conversation

@mattzcarey

@mattzcarey mattzcarey commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

ThinkHarness now passes the tools each model call actually sends, as names and definition hashes, to the session's context. With #3219, when a turn sends a different list from the previous turn, the model is told once, right after that turn's user message, what was added, what is gone and what changed. This is E3c of the Think extensions design: an extension loaded or unloaded, an MCP server connecting, a client tool declared late, or beforeTurn choosing different activeTools. The change costs one cache miss, and the model is told why.

The context prepares a turn in two steps. prepareTurn reads the last tool list and the turn's user message, then prepares the blocks, so beforeTurn still gets the system prompt. After beforeTurn, recordTools takes the tools the request sends. A record the blocks wrote carries the earlier tools forward. So a changed block doesn't hide the earlier list, a message beforeTurn appends doesn't move where the notice is recorded, and the blocks' reminder is sent once on a continuation or a regeneration. A hash covers what the model sees of a tool (description, input schema, input examples, provider fields) and is cached per tool object.

Cost: one SHA-256 per tool object, once. Per model call, the same reads as a single prepare with tools: the newest record and the latest leaf. With unchanged tools, nothing more is read or written and the history is projected once. Only a change adds a record write and a second projection.

Validation:

  • New harness.test.ts tests: tools changed between turns, a tool declared by a client, changed inputExamples, activeTools filtering, a block and the tools changed before the same message, a regeneration after a block change, a message appended in beforeTurn, and the continuation test counting the reminder once. The last four fail before the fix.
  • The harness-think suite passes (123), the context suite passes (106), and pnpm run check is green.

@changeset-bot

changeset-bot Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 0957f27

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 changesets to release 2 packages
Name Type
agents Minor
@cloudflare/agent-think Patch

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 26, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

agents

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

@cloudflare/ai-chat

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

@cloudflare/codemode

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

hono-agents

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

@cloudflare/shell

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

@cloudflare/think

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

@cloudflare/voice

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

@cloudflare/worker-bundler

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

commit: 0957f27

@agent-think

agent-think Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

✅ agents import sizes: no significant changes (eb626139 → 0957f277, workflow run)

@mattzcarey
mattzcarey marked this pull request as ready for review November 26, 2026 10:08
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@mattzcarey
mattzcarey merged commit 2f1c0f1 into main Nov 26, 2026
26 checks passed
@mattzcarey
mattzcarey deleted the slim/ext-e3c branch November 26, 2026 11:16
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