fix(frontend): create thread on first submit in new-agent page (#2656)

The new-agent page pre-generates a thread UUID and passed it directly
to useThreadStream, which made the LangGraph SDK POST to
/threads/{uuid}/runs/stream against a thread the backend had never
created. After PR #2566 introduced multi-tenant owner checks on the
runs endpoints, that request now 404s with "Thread not found".

Pass threadId: undefined to useThreadStream so the SDK takes the
create-then-run path. The pre-generated UUID is still forwarded via
SubmitOptions.threadId in sendMessage, so the new thread is created
with that exact id and onCreated rebinds the hook to it.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
yangzheli 2026-04-30 06:41:54 +08:00 committed by GitHub
parent 4a9f1d547b
commit f7b10d42e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -102,7 +102,7 @@ export default function NewAgentPage() {
const threadId = useMemo(() => uuid(), []);
const { thread, sendMessage } = useThreadStream({
threadId: step === "chat" ? threadId : undefined,
threadId: undefined,
context: {
mode: "flash",
is_bootstrap: true,