Repository navigation
fix(think): regenerate answers the parent user message instead of continuing (#2028) - #2413
Merged
Merged
Conversation
…tinuing the replaced response (#2028) Co-authored-by: Cursor <cursoragent@cursor.com>
…-from-parent Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # packages/think/src/tests/agents/client-tools.ts
Co-authored-by: Cursor <cursoragent@cursor.com>
🦋 Changeset detectedLatest commit: 1297a72 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 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 |
25 of 46 tasks
Contributor
|
✅ agents import sizes: no significant changes ( |
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
…generated path (#2028) Co-authored-by: Cursor <cursoragent@cursor.com>
Merged
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.
Fixes #2028.
The problem
Regenerating a response in Think behaved like "continue". The regenerated response was already saved as a new branch beside the one it replaces (as the parent user message's child), but the model prompt was assembled from
this.messages, which follows the latest leaf. That path still contained the response being replaced, so the model saw it and continued it.What changed (
packages/think/src/think.ts)_assembleModelMessagesbuilds the prompt from the history up to and including that message (_turnHistory()), so neither the replaced response nor anything after it reaches the model. If that message is off the cached path, it's read from storage and repaired for this request only.session.compact(leafId)), not the active branch.regeneratedLeafId). A regeneration interrupted before its first chunk, live or after eviction, is retried as a new branch from the same user message, and only while the replaced response is still the leaf.Tests
Five new Think tests, all failing without the fix:
Think's full Workers suite passes (1,218 tests), and
pnpm run checkis clean.Known gap
A regeneration interrupted after partial output takes the existing "continue" recovery path, which extends the partial response on the new branch. That's the right branch, but it continues rather than restarting. Left for a follow-up.