cloudflare / cloudflare/agents
Think regeneration includes the previous response in the model prompt
- Dominant language
- TypeScript
- Stars
- 5.6k
- Forks
- 711
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 53
Description
**Describe the bug**
`regenerate()` creates a new response in the UI, but `@cloudflare/think` still sends the previous assistant response to the model.
Think then adds this message:
> Continue your previous response from exactly where it left off. Do not repeat any of it.
As a result, regeneration behaves like “continue” instead of generating a fresh alternative.
Keeping the old response as a stored branch is correct. Including it in the new model request is not.
**To Reproduce**
1. Send a user message and wait for the assistant response.
2. Call `regenerate()`.
3. Inspect the messages sent to the model.
4. The request contains the previous assistant response followed by the continuation instruction above.
This was also reproduced in the upstream Think test suite using a model test double.
**Expected behavior**
Regeneration should create a sibling response using conversation history only up to the user message being answered.
The previous assistant response should remain available as a stored branch, but it should not be included in the new model request.
**Screenshots**
Not applicable. The issue is visible in the model request.
**Version:**
- `@cloudflare/think@0.15.0`
- `agents@0.19.0`
- AI SDK v7
Also reproduced against `cloudflare/agents` main at commit `2b2b5980e1945cf55f5a11626bc395e7c460516f`, where Think is `0.15.1`.
**Additional context**
The existing regeneration tests verify that sibling branches are stored correctly, but they do not inspect the messages sent to the model.
This is different from #1351, which tracks displaying and navigating stored branches in the UI.
It is related to #1012, where the older `@cloudflare/ai-chat` implementation also left the previous assistant response in server-side context during regeneration.
Contributor guide
Assessment
This issue has not been assessed yet.