Skip to content

feat(context): record a turn's tools, and say once when they change - #3219

Merged
mattzcarey merged 5 commits into
mainfrom
slim/context-tools
Nov 25, 2026
Merged

mattzcarey merged 5 commits into
mainfrom
slim/context-tools

Conversation

@mattzcarey

@mattzcarey mattzcarey commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

The context record a session keeps per user message (from #2773) now also holds the tools that turn was sent, as names and hashes. When the next turn sends a different list, the model is told once, right after that turn's user message: what was added, what is gone (not to be called, earlier description to be disregarded), what changed. This is step E3c of extensions (EXTENSIONS.md, "How the change is detected"); the harness passes the list in a follow-up from ext.

  • Context.prepare({ tools }), an internal option: { name, hash }[] for the tools this request sends.
  • No new row. Every record Context writes during such a call carries the fingerprint. A turn whose tools match writes nothing, as before. A turn whose tools differ writes its record with the notice (or adds the notice to the record it was writing anyway).
  • The notice stays where it was delivered, also after a later refresh (no prompt says which tools went away). A continuation or regeneration gets it for that request only, as a block change does; a retry gets nothing new.
  • A session whose records predate the fingerprint records it on its next turn and says nothing; an overlay carries it through compaction (Sessions already copies the newest record onto the summary).

No changeset: the option is internal and nothing changes for users until the harness passes it.

Cost, only when tools is given: one more latest-leaf read per turn, and one record write on the first turn with tools in a session that had records without them. A turn with the same tools writes nothing.

Tests (real Durable Object, real Sessions), each failing on main: the notice is sent once, in place, and not again on the next turn; a continuation gets it in reminder, a retry gets nothing; a session recorded before the fingerprint starts comparing quietly and keeps comparing across a compaction. The context suite (invariants at 60 seeds), ThinkHarness and Think pass.


Devin Review

@changeset-bot

changeset-bot Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: fad68fb

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

devin-ai-integration[bot]

This comment was marked as resolved.

@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@3219

@cloudflare/ai-chat

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

@cloudflare/codemode

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

hono-agents

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

@cloudflare/shell

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

@cloudflare/think

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

@cloudflare/voice

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

@cloudflare/worker-bundler

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

commit: fad68fb

@agent-think

agent-think Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

🔴 agents import sizes: 1 entry point over threshold

Entry point Exports Largest gzip change Size now
🔴 agents/harness/think 1 resized +508 B (+14.21%) 4 KiB
🟡 agents/chat 176 resized, 1 new up to +279 B (+6.52%) 4.4 KiB
Changed exports (178)
Import Gzip change Size now
🔴 agents/harness/think#ThinkChat +508 B (+14.21%) 4 KiB
🟡 agents/chat#ChatFrames +279 B (+6.52%) 4.4 KiB
🆕 agents/chat#frameText — 3.5 KiB
🟢 agents/chat#sanitizeMessage -410 B (-11.28%) 3.1 KiB
🟢 agents/chat#broadcastTransition -410 B (-9.24%) 3.9 KiB
🟢 agents/chat#interceptAgentToolBroadcast -408 B (-11.01%) 3.2 KiB
🟢 agents/chat#isDurableObjectResetError -407 B (-11.47%) 3.1 KiB
🟢 agents/chat#removeEmptyReplyToContinue -407 B (-10.36%) 3.4 KiB
🟢 agents/chat#backoffDelay -406 B (-11.67%) 3 KiB
🟢 agents/chat#truncateProviderToolPayloads -406 B (-11.27%) 3.1 KiB
🟢 agents/chat#isPlatformFailure -406 B (-11.07%) 3.2 KiB
🟢 agents/chat#truncateOlderMessages -406 B (-9.52%) 3.8 KiB
🟢 agents/chat#enforceRowSizeLimit -405 B (-8.82%) 4.1 KiB
🟢 agents/chat#truncateOlderToolResults -405 B (-8.68%) 4.2 KiB
🟢 agents/chat#hasPendingToolInteraction -404 B (-11.17%) 3.1 KiB
🟢 agents/chat#responseSource -404 B (-10.72%) 3.3 KiB
🟢 agents/chat#createAgentToolRunStore -404 B (-8.04%) 4.5 KiB
🟢 agents/chat#REPLAY_CHUNK_BYTES -403 B (-11.92%) 2.9 KiB
🟢 agents/chat#chatRecoveryNames -403 B (-10.56%) 3.3 KiB
🟢 agents/chat#StreamAccumulator -403 B (-10.03%) 3.5 KiB
🟢 agents/chat#persistReconstructedOrphan -403 B (-9.46%) 3.8 KiB
🟢 agents/chat#ReplyStreams -403 B (-7.55%) 4.8 KiB
🟢 agents/chat#MAX_BOUND_PARAMS -402 B (-11.89%) 2.9 KiB
🟢 agents/chat#ROW_VALUE_BYTES -402 B (-11.88%) 2.9 KiB
🟢 agents/chat#byteLength -402 B (-11.46%) 3 KiB
🟢 agents/chat#KV_DELETE_MAX_KEYS -401 B (-11.86%) 2.9 KiB
🟢 agents/chat#replyIsEmpty -401 B (-11.78%) 2.9 KiB
🟢 agents/chat#uiMessageStreamSource -401 B (-11.58%) 3 KiB
🟢 agents/chat#chatRecoveryBackoffSeconds -401 B (-11.41%) 3 KiB
🟢 agents/chat#replyToContinueIsEmpty -401 B (-11.02%) 3.2 KiB
🟢 agents/chat#createAgentToolEventState -400 B (-11.83%) 2.9 KiB
🟢 agents/chat#recordChatTerminal -400 B (-11.74%) 2.9 KiB
🟢 agents/chat#rejectionMessage -400 B (-11.67%) 3 KiB
🟢 agents/chat#resolveToolMergeId -400 B (-11.63%) 3 KiB
🟢 agents/chat#settleContinuationTurn -400 B (-11.49%) 3 KiB
🟢 agents/chat#stripTrailingReasoning -400 B (-11.22%) 3.1 KiB
🟢 agents/chat#handleRecoveryAttemptError -400 B (-10.34%) 3.4 KiB
🟢 agents/chat#LiveReply -399 B (-11.74%) 2.9 KiB
🟢 agents/chat#transcriptEndsInAnswer -399 B (-11.52%) 3 KiB
🟢 agents/chat#MessageType -399 B (-11.5%) 3 KiB
🟢 agents/chat#hasIncompleteToolBatch -399 B (-11.48%) 3 KiB
🟢 agents/chat#settleReplyBeforeRecovery -399 B (-8.35%) 4.3 KiB
🟢 agents/chat#broadcastReachesUnlistedSockets -398 B (-11.86%) 2.9 KiB
🟢 agents/chat#toolPartHasSettledResult -398 B (-11.8%) 2.9 KiB
🟢 agents/chat#drainInteractionApplies -398 B (-11.77%) 2.9 KiB
🟢 agents/chat#TransientChatStreamError -398 B (-11.76%) 2.9 KiB
🟢 agents/chat#isPositionlessAgentToolChunk -398 B (-11.66%) 2.9 KiB
🟢 agents/chat#reconcileOrphanPartial -398 B (-11.59%) 3 KiB
🟢 agents/chat#unsettledToolCallIds -398 B (-11.45%) 3 KiB
🟢 agents/chat#runChatRecoveryExhaustion -398 B (-11.07%) 3.1 KiB

…and 128 more exports in the workflow artifact.

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 0fb5c61f → fad68fb8 · workflow run · reported by agent-think[bot]

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 bbc2c22 into main Nov 25, 2026
26 checks passed
@mattzcarey
mattzcarey deleted the slim/context-tools branch November 25, 2026 22:18
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