-
Notifications
You must be signed in to change notification settings - Fork 0
🐛 Bug: useCopilotChat reloadMessages and reset not working #1
Description
♻️ Reproduction Steps
- Use LangGraph Python as the backend agent server with Copilotkit and
langgraph upwith port 8123. - Connect to localhost:8123 in CopilotRuntime (route.ts)
const runtime = new CopilotRuntime({
remoteEndpoints: [
langGraphPlatformEndpoint({
deploymentUrl: process.env.LANGGRAPH_DEPLOYMENT_URL || 'http://localhost:8123', // matches langgraph dev port
langsmithApiKey: process.env.LANGSMITH_API_KEY || '',
agents: [{ name: 'demo_agent', description: 'A Demo LLM agent.' }],
}),
],
});- Run reloadMessages and reset in useCopilotChat()
const {
visibleMessages,
appendMessage,
setMessages,
deleteMessage,
stopGeneration,
isLoading,
reloadMessages,
reset,
} = useCopilotChat();
<button onClick={() => reloadMessages(msg.id)}>Reload Message</button>
<button onClick={reset}>Reset</button>✅ Expected Behavior
reloadMessages
Regenerate the target msg and continue chat.
reset
Reset the entire thread.
❌ Actual Behavior
reloadMessages
It doesn't regenerate but only remove the target message. Typing new chat message returns backend error.
ValueError: Message dict must contain 'role' and 'content' keys, got {'lc': 1, 'type': 'constructor', 'id': ['langchain_core', 'messages', 'RemoveMessage'], 'kwargs': {'id': 'ck-dd1f6760-1f39-44da-91f6-af1e0de5b166', 'content': '', 'additional_kwargs': {}, 'response_metadata': {}}}
reset
Typing new chat message returns backend error after resetting the chat. Error returned:
ValueError: Message dict must contain 'role' and 'content' keys, got {'lc': 1, 'type': 'constructor', 'id': ['langchain_core', 'messages', 'RemoveMessage'], 'kwargs': {'id': 'ck-dd1f6760-1f39-44da-91f6-af1e0de5b166', 'content': '', 'additional_kwargs': {}, 'response_metadata': {}}}
𝌚 CopilotKit Version
1.9.1📄 Logs (Optional)
Both errors point to the langchain_core function RemoveMessage.