`@chat-adapter/web` always names itself `web`, so two web adapters share thread IDs
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 76/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- TypeScript
- Stelle
- 2.5k
- Fork
- 355
- Merge medio
- 2g 15h
- PR unite (30g)
- 42
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di vercel/chat
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
X and Twitch: paragraphs inside a block quote are joined with no spaceForse già presa @abhiramshaji-cyber l’ha presa 4 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
bug impact:low Team: SecuritySolution Team:Defend Workflows v9.6.0
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
elastic/kibana#306401 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
agentes-chat/agentes-chat#927 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: Webapp workspace fails to render in Safari — "Can't find variable: requestIdleCallback"Apertacomp/desktop P2 type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
NousResearch/hermes-agent#157702 ·
I maintainer di solito rispondono entro 1 giorno
-
e2e-failure ready-to-code
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
redhat-developer/rhdh-plugin-export-overlays#4794 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno