I found a bug in @ai-sdk/langchain when using streamMode: ["messages", "values"] with LangGraph’s HITL (Human-in-the-Loop) interrupt().
The problem: Tool calls emitted via messages stream are added to emittedToolCalls but not to emittedToolCallsByKey. When the __interrupt__ handler tries to match by key, it fails and generates a fallback ID — causing orphaned approval cards in the UI.
I’ve submitted an issue and a PR with a fix and tests. The fix is a 5-line else-if branch that registers the key mapping for tool calls already emitted via messages mode.
- Issue: @ai-sdk/langchain: HITL interrupt cannot match tool calls emitted via messages streamMode · Issue #12797 · vercel/ai · GitHub
- PR: fix(langchain): register key mapping for HITL interrupt matching in dual streamMode by domuk-k · Pull Request #12798 · vercel/ai · GitHub
Would appreciate any feedback or a review. Thanks!