Skip to content

Think regeneration includes the previous response in the model prompt #2028

Closed

Description

@urjitc

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.

Activity

  1. urjitc commented on Aug 3, 2026

    @urjitc
    Author

    basically what happens is that a user tries to regen a response, the ai thinks that whatever it did in the old response already happened, the user can see it, etc. not sure this is intentional but in my usecase (and how other ai apps handle) a clean slate regen makes more sense

  2. urjitc commented on Aug 5, 2026

    @urjitc
    Author

    @ben-reitz perfect exactly what i was looking for thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions