`@chat-adapter/web` always names itself `web`, so two web adapters share thread IDs
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
Research direction
Read packages/adapter-web/src/adapter.ts, especially the WebAdapter name and thread ID methods cited in the issue, then trace how Chat resolves adapter keys from thread ID prefixes. Check the adapter's existing tests for naming and thread ID behavior. Done when separate web adapters produce IDs that chat.thread() can resolve independently, including IDs returned by threadIdFor.
Written by the indexing model from the issue text.
Description
Bug Description
WebAdapter hard-codes name = "web" and the web: thread ID prefix. Chat resolves a thread by the part of its ID before the first colon and looks that up in the keys of adapters. So a web adapter registered under any key other than web gets thread IDs that chat.thread() can't resolve. Two web adapters, say a support chat and a sales chat, also get the same thread ID for the same user and conversation, so they share subscriptions, locks, and history.
threadIdFor doesn't help, because decodeThreadId throws for any prefix other than web:.
Steps to Reproduce
- Register two web adapters under the keys
supportandsales. - Send the same conversation ID from the same user to each webhook.
- Look at
thread.idin the handler, then callchat.thread(thread.id).
Expected Behavior
Each adapter has its own name and thread prefix, and chat.thread() resolves its thread IDs.
Actual Behavior
Both handlers see web:u1:c1. chat.thread("web:u1:c1") throws Adapter "web" not found for thread ID "web:u1:c1". With threadIdFor returning sales:u1:c1, decodeThreadId throws Invalid web thread id: sales:u1:c1.
Code Sample
import { Chat } from "chat";
import { createMemoryState } from "@chat-adapter/state-memory";
import { createWebAdapter } from "@chat-adapter/web";
const getUser = () => ({ id: "u1" });
const support = createWebAdapter({ userName: "bot", getUser });
const sales = createWebAdapter({ userName: "bot", getUser });
const chat = new Chat({ userName: "bot", state: createMemoryState(), adapters: { support, sales } });
await chat.initialize();
chat.onDirectMessage(async (thread) => console.log(thread.id)); // "web:u1:c1" for both
for (const key of ["support", "sales"] as const) {
const body = { id: "c1", messages: [{ id: `m-${key}`, role: "user", parts: [{ type: "text", text: "hi" }] }] };
await chat.webhooks[key](new Request("https://app.example/api/chat", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body) }));
}
chat.thread("web:u1:c1"); // Adapter "web" not found for thread ID "web:u1:c1"
Chat SDK Version
4.45.0
Node.js Version
24.21.0
Platform Adapter
Other
Operating System
Linux
Additional Context
A name option on createWebAdapter, defaulting to "web", would fix it. The adapter would use it for name, the default threadIdFor, encodeThreadId, and decodeThreadId. We do this today by overriding name and wrapping both thread ID methods. I can open a PR if you want it.
- Dominant language
- TypeScript
- Stars
- 2.5k
- Forks
- 355
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 42
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vercel/chat
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
X and Twitch: paragraphs inside a block quote are joined with no spacePossibly taken @abhiramshaji-cyber claimed this 4 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 1/5 1-3 hours Newbie friendliness 87/100
Maintainers usually reply within 1 day
-
🛠️ dette technique
Difficulty 2/5 1-3 hours Newbie friendliness 61/100
betagouv/mon-entreprise#4752 · 1 comment ·
Maintainers usually reply within 5 days
-
type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
franciscoBSalgueiro/en-croissant#1111 ·
Maintainers usually reply within 2 days
-
area/providers type/feature version/v2
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
anomalyco/opencode#64845 · 1 comment ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day