assistant-ui icon indicating copy to clipboard operation
assistant-ui copied to clipboard

load isn’t called when using useLangGraphRuntime as runtimeHook of unstable_useRemoteThreadListRuntime; externalId is undefined at mount

Open eladlachmi opened this issue 1 month ago • 2 comments

After v0.7.0 and PR #2439, the guidance in this comment suggests “double wrapping” should work (passing a runtimeHook that itself wraps a remote thread list).

In practice, using useLangGraphRuntime as runtimeHook mounts a second internal thread list. The inner runtime’s mainItem belongs to that inner list, not the outer selection, so mainItem.externalId stays undefined and load never fires.

The inner hook owns its own thread list, so its mainItem isn’t bound to the outer selection. This masks the outer thread and explains the undefined externalId. To get around this, an unwrapped, per-thread, version of the runtime impl should be exported as well.

Independently, with the per-thread hook, externalId is often undefined at first render. A one-time read is racy; you must subscribe to runtime.threads.mainItem and trigger load once externalId becomes defined. This aligns with the direction in PR #2439 (use mainItem as source of truth), but requires a subscription rather than a single read.

I've fixed both issues locally, and from my testing, this seems to restore the functionality from before v0.7.0.

I would like to get your feedback on the analysis above. If we're in agreement about these two issues, I'd be happy to contribute a PR to fix them.

Thanks!

eladlachmi avatar Nov 17 '25 18:11 eladlachmi

Facing the same issue.

@eladlachmi could you share your fix ?

elvenking avatar Nov 22 '25 20:11 elvenking

@elvenking Take a look at this PR #2752 It's basically the same fix.

eladlachmi avatar Nov 23 '25 12:11 eladlachmi