ag-ui-protocol / ag-ui-protocol/ag-ui

[Bug]: [ag-ui-langgraph] Time-travel is not triggered when regenerating the first assistant message

Đang mở
#2,109 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
Python
Star
15.9k
Fork
1.4k
Merge trung bình
1 ngày 17 giờ
Pull request đã merge (30 ngày)
163

Mô tả

### Pre-flight Checklist

- [x] I have searched [existing issues](https://github.com/ag-ui-protocol/ag-ui/issues) and this hasn't been reported yet.
- [x] I am using the **latest** version AG-UI.

### Describe the Bug

Regenerating the first assistant response in a conversation never enters the time-travel path.
Instead, the request is treated as a continuation and prepare_regenerate_stream() is never called.

### Steps to Reproduce

1. Start a new conversation.

Frontend:

User(id=u1): "Hello"

2. The assistant responds.

Checkpoint:

User(id=u1)
Assistant(id=a1)

3. Click "Regenerate" on that first assistant response.

The frontend sends the conversation truncated to the last user message (or user + empty assistant placeholder).

4. Observe that the backend never enters prepare_regenerate_stream().

### Expected Behavior

The first assistant response should be regenerated by performing a time-travel from the user message.

### Environment

```text
ag-ui-langgraph 0.0.42
deepagents 0.6.3

python 3.11.0
```

### Screenshots

_No response_

### Logs & Errors

```shell

```

### Additional Context

In prepare_stream(), regenerate detection only starts when:

```
non_system_messages = [
msg for msg in langchain_messages
if not isinstance(msg, SystemMessage)
]

if len(agent_state.values.get("messages", [])) > len(non_system_messages):
```

Consider the first assistant response in a conversation.

The checkpoint contains:

Human(id=u1)
AI(id=a1)

so the checkpoint has 2 messages.

When the frontend triggers a regenerate request, it sends:

Human(id=u1)
AI(id="")

After converting to LangChain messages, this still results in:

Human
AI

which also contains 2 messages.

Therefore, the condition evaluates to:

2 > 2 // false

As a result, the regenerate detection logic is skipped entirely, and prepare_regenerate_stream() is never reached.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.