load function not called when switching threads with AssistantCloud + useLangGraphRuntime
I'm using AssistantCloud with useLangGraphRuntime following the official documentation for Chat History for LangGraph Cloud. Thread switching works (the UI updates), but the load function is never called when clicking on existing threads, resulting in empty thread views.
@assistant-ui/react: 0.11.28 @assistant-ui/react-langgraph: 0.7.0 Using Clerk for authentication
When clicking on an existing thread:
- Thread switches (mainThreadId updates correctly)
- load function is never called
- Thread view remains empty Console shows: [ThreadList Debug] mainThreadId: "thread_0Hu6ut0RytWdxiyEgZdclDF0" (thread ID changes) But no [Load] Called for: log appears
export function MyRuntimeProvider({ children }) {
const { getToken } = useAuth();
const cloud = useMemo(
() =>
new AssistantCloud({
baseUrl: process.env.NEXT_PUBLIC_ASSISTANT_BASE_URL!,
authToken: async () => getToken({ template: "assistant-ui" }),
}),
[getToken],
);
const runtime = useLangGraphRuntime({
cloud,
stream: async function* (messages, { initialize }) {
const { externalId } = await initialize();
if (!externalId) throw new Error("Thread not found");
return sendMessage({ threadId: externalId, messages });
},
create: async () => {
console.log("[Create] Called");
const { thread_id } = await createThread();
return { externalId: thread_id };
},
load: async (externalId) => {
console.log("[Load] Called for:", externalId);
const state = await getThreadState(externalId);
return {
messages: state.values.messages ?? [],
};
},
});
return (
<AssistantRuntimeProvider runtime={runtime}>
{children}
</AssistantRuntimeProvider>
);
}
HELP!
I've been trying to make my own integration, using useLangGraphRuntime as reference. This code seems to be responsible for calling load, but I don't see how the dependencies would trigger the effect beyond the initial load.
https://github.com/assistant-ui/assistant-ui/blob/3b1358fa3b7ce002028c9b5e180854c0e03e078b/packages/react-langgraph/src/useLangGraphRuntime.ts#L311-L324