Files
Benjamin Taylor d8f9190f03 fix(examples): map Channel thread ids onto UUIDs for the LangGraph starters
As shipped, neither LangGraph starter could answer a single Channel turn.

A Channel's thread id identifies a conversation on the provider, so it is a
provider-shaped string (channels-core sets it from
`adapter.getCanonicalThreadId?.(replyTarget) ?? conversationKey`). Both
starters assigned it to `agent.threadId` verbatim. But `LangGraphAgent` is the
platform client: it calls `client.threads.get` then `client.threads.create`
with that id, and both UUID-validate, so every turn died inside
`getOrCreateThread` with `422 Invalid thread ID: must be a UUID` before the
model was reached. The user saw only the host's generic catch-block apology.

This is not LangGraph Cloud only — `AGENT_URL` defaults to localhost:8123, so
a local `langgraph dev` fails identically.

`toPlatformThreadId` derives a deterministic RFC 4122 v5 UUID under a fixed
namespace. Deterministic rather than random because the same conversation must
always resolve to the same LangGraph thread, or checkpointed history is lost on
every turn and again on every restart. Ids that are already UUIDs pass through
untouched, so the web path — whose clients mint UUIDs — is unaffected.

The namespace constant is a compatibility contract: it decides where every
checkpointed conversation is filed. It must be reused verbatim when this moves
upstream (OSS-771), which is where it belongs — this patch duplicates the
helper across two starters and does nothing for anyone writing their own host
over `@copilotkit/runtime/langgraph`.

Refs OSS-770.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-06 10:23:29 -05:00
..