Repository navigation
fix(chat): continue a tool result only while its message is the latest - #2865
Open
mattzcarey wants to merge 4 commits into
Open
mattzcarey wants to merge 4 commits into
mattzcarey wants to merge 4 commits into
Conversation
🦋 Changeset detectedLatest commit: 6ebf34a The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
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 |
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
Contributor
🟡 agents import sizes: 1 entry point grew
Changed exports (106)
…and 56 more exports in the workflow artifact. How this worksEach 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 |
mattzcarey
force-pushed
the
fv/chat-continuation-core
branch
from
November 11, 2026 14:39
a793006 to
356fdeb
Compare
mattzcarey
force-pushed
the
fv/chat-continuation-core
branch
2 times, most recently
from
November 18, 2026 16:44
3c32d14 to
c318378
Compare
The decision moves into agents/chat so AIChatAgent and Think share it: - AutoContinuationController.afterInteraction schedules a continuation only for a result that settled its tool part, targeted at that part's message - ContinuationState carries targetMessageId; continuationTargetIsLatest skips a continuation once a newer message follows the target (a newer question or reply, a regenerate, a clear), like pi's continue() settling nothing_to_answer Think's _applyToolUpdateToMessages now reports the outcome, and Think gets the changed-only scheduling ai-chat got in the previous commit. Tests that built the old order on purpose now keep the tool call's message latest.
A later result for an older reply used to replace the target of a pending continuation, so the latest-message check then skipped the newer reply's continuation. Pending and deferred continuations now keep every message their coalesced results target; the continuation runs while any of them is the last message. A result without a target turns the check off. Also fix a test's type narrowing that broke the typecheck.
Scheduling now happens once the result is applied, so idle and stable checks count an apply in flight as a pending continuation decision. The check moves into AutoContinuationController.hasPendingDecision, shared by both hosts. Think keeps the live reply as the changed message when a stored row also holds the call.
…ult's continuation
mattzcarey
force-pushed
the
fv/chat-continuation-core
branch
from
November 19, 2026 13:53
c318378 to
6ebf34a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An auto-continuation now runs only for a tool result that settled its call, and only while the conversation has not moved past that call's message. The rule lives in
agents/chat(AutoContinuationController.afterInteraction,continuationTargetIsLatest), andAIChatAgentandThinkboth use it.Why:
_applyToolUpdateToMessagesdid not report whether it changed anythingThe conversation has moved past a message once a user message follows it, or once a later turn stored a reply after it. Both hosts record the id of the last reply a turn stored (
lastTurnReplyId, durable). A message appended without a turn, such as a narrated milestone or a status message an app stores withpersistMessages, does not count, so the tool result is still answered. InAIChatAgentthe answer is a new reply after the appended message.Follows #2860, whose expected-fail replay is now a passing test. Tests ran:
agents/chat, ai-chat workers and the full Think suite, pluspnpm run check.