Skip to content

Bug Report: Message Edit (Time Travel) causes duplicate messages and tool_use validation errors #204

@ava6969

Description

@ava6969

Description

When using the edit feature on a human message to branch/time-travel, the current implementation causes:

  1. Duplicate messages appearing in the conversation
  2. Anthropic validation error: tool_use ids were found without tool_result blocks

Current Implementation (Broken)

In components/thread/messages/human.tsx, handleSubmitEdit passes the new message as input alongside a checkpoint:

thread.submit(
{ messages: [newMessage] }, // ← Problem: passing message as input
{
checkpoint: parentCheckpoint,
// ...
}
);

Expected Behavior (Per LangGraph Docs)

The correct time-travel pattern per https://langchain-ai.github.io/langgraph/how-tos/time-travel/ is:

// Step 1: Update state at checkpoint to add the new message
const newConfig = await client.threads.updateState(threadId, {
values: { messages: [...checkpointMessages, newMessage] },
checkpoint: parentCheckpoint,
});

// Step 2: Resume with null input from the NEW checkpoint
thread.submit(null, { config: newConfig });

Why This Matters

  • updateState creates a NEW checkpoint with valid message history
  • Passing null as input means no conflicting message injection
  • The checkpoint state already contains the new message, so the backend processes it correctly
  • Tool use/result pairing is preserved from the parent checkpoint

Steps to Reproduce

  1. Start a conversation that triggers tool calls (e.g., search, code execution)
  2. After receiving an AI response, hover over an earlier human message
  3. Click the Edit (pencil) icon
  4. Modify the message and submit
  5. Observe duplicate messages and/or tool_use validation error

Environment

  • @langchain/langgraph-sdk version: (check your package.json)
  • Browser: Chrome/Firefox/etc.

Additional Context

This works correctly in LangSmith Studio's chat interface, suggesting the issue is specific to the useStream hook's submit implementation or how the checkpoint option is handled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions