Skip to content

fix(langgraph): regenerate first assistant response#2114

Open
prajvalrasik wants to merge 1 commit into
ag-ui-protocol:mainfrom
prajvalrasik:fix/langgraph-first-assistant-regenerate
Open

fix(langgraph): regenerate first assistant response#2114
prajvalrasik wants to merge 1 commit into
ag-ui-protocol:mainfrom
prajvalrasik:fix/langgraph-first-assistant-regenerate

Conversation

@prajvalrasik

Copy link
Copy Markdown

Summary

Fixes #2109.

Regenerating the first assistant response can send the same number of messages as the checkpoint:

  • checkpoint: user message + assistant response
  • incoming request: same user message + empty assistant placeholder

Because the message counts are equal, the existing count-based regenerate heuristic is skipped and prepare_regenerate_stream() is never reached.

This change detects the explicit empty assistant placeholder case and routes regeneration from the preceding checkpointed user message.

Notes

I kept the user only path unchanged because it overlaps with the existing SSE-drop recovery behavior where the client can be behind the checkpoint. This PR handles the unambiguous placeholder signal.

Tests

uv run python -m unittest tests.test_prepare_stream_edited_message
uv run python -m unittest tests.test_oss28_sse_drop_recovery tests.test_prepare_stream_interrupt_resume tests.test_resume_input
uv run python -m unittest discover tests -v

Result:

383 tests passed

@prajvalrasik
prajvalrasik requested a review from a team as a code owner July 3, 2026 21:08
@prajvalrasik

Copy link
Copy Markdown
Author

Hi maintainers, just checking in on this PR when you get a chance.

This fixes the first-assistant-message regenerate case from #2109 and keeps the existing user-only/SSE-drop recovery behavior unchanged. Local LangGraph integration tests pass. Happy to adjust if you want the detection handled differently.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant