The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Assist: Claude replies stream with room for long thinking (32k, 64k at Extra/Max effort)
Claude26e7fe1be951
diff --git a/src/server/assist/agent.ts b/src/server/assist/agent.tsindex 8ae46b1f..a204f3e5 100644--- a/src/server/assist/agent.ts+++ b/src/server/assist/agent.ts@@ -511,17 +511,26 @@ Skills, memory and projects (your context below lists them):/** Models that take server-side fallbacks on a refusal ("default" routing). */const FALLBACK_MODELS = new Set(["claude-opus-5-5", "claude-sonnet-5-5", "claude-fable-5-1"]);+/**+ * Output room per reply: thinking plus a large generate or studio call. Extra and Max effort think+ * longest, so they get the most; the cap only bounds a reply, it isn't spent.+ */+export const maxTokensFor = (effort: AssistEffort): number => (effort === "xhigh" || effort === "max" ? 64_000 : 32_000);+export const claude: ModelCall = async ({ system, messages, tools, settings }) => {const client = new Anthropic({ apiKey: getSetting("anthropicKey") });const model = settings?.model && CLAUDE_MODELS.some((m) => m.id === settings.model) ? settings.model : DEFAULT_CLAUDE_MODEL;const fallback = FALLBACK_MODELS.has(model);- return client.beta.messages.create({+ const effort = settings?.effort ?? DEFAULT_EFFORT;+ // Streamed, so long thinking at high effort never runs into an HTTP timeout; only the final+ // message is used (the UI shows the reply once it's complete).+ const stream = client.beta.messages.stream({model,- max_tokens: 16000,+ max_tokens: maxTokensFor(effort),// drop_block: a thinking block the API can't replay (a chat that switched models, or one from// before contexts were frozen) is dropped instead of failing the request.thinking: { type: "adaptive", block_binding: { prefix_mismatch_behavior: "drop_block" } },- output_config: { effort: settings?.effort ?? DEFAULT_EFFORT },+ output_config: { effort },betas: [...(fallback ? (["server-side-fallback-2026-07-01"] as const) : []), "thinking-binding-controls-2026-08-01"],...(fallback && { fallbacks: "default" as const }),// The fixed instructions and the chat's frozen context are cached; so is the conversation so far.@@ -533,6 +542,7 @@ export const claude: ModelCall = async ({ system, messages, tools, settings }) =tools,messages: await hydrate(messages),});+ return stream.finalMessage();};type OllamaMessage = { role: "system" | "user" | "assistant" | "tool"; content: string; tool_calls?: { function: { name: string; arguments: unknown } }[]; tool_name?: string };diff --git a/tests/assist-context.test.ts b/tests/assist-context.test.tsindex 819f0d77..345b264e 100644--- a/tests/assist-context.test.ts+++ b/tests/assist-context.test.ts@@ -183,12 +183,21 @@ describe("modes", () => {agent.addMessage(t.id, "Hi");const sent: { headers: Headers; body: Record<string, unknown> }[] = [];const realFetch = globalThis.fetch;+ // The reply streams (server-sent events); the agent keeps the final message.+ const sse = (events: Record<string, unknown>[]) => events.map((e) => `event: ${e.type}\ndata: ${JSON.stringify(e)}\n\n`).join("");globalThis.fetch = (async (_url: string, init: RequestInit) => {- sent.push({ headers: new Headers(init.headers), body: JSON.parse(String(init.body)) });- return new Response(JSON.stringify({ id: "msg_1", type: "message", role: "assistant", model: "claude-haiku-5-5", stop_sequence: null, stop_details: null, usage: { input_tokens: 1, output_tokens: 1 }, content: [{ type: "text", text: "Hello" }], stop_reason: "end_turn" }), {- status: 200,- headers: { "content-type": "application/json" },- });+ const body = JSON.parse(String(init.body)) as Record<string, unknown>;+ sent.push({ headers: new Headers(init.headers), body });+ const events = [+ { type: "message_start", message: { id: "msg_1", type: "message", role: "assistant", model: body.model, content: [], stop_reason: null, stop_sequence: null, stop_details: null, usage: { input_tokens: 1, output_tokens: 0 } } },+ { type: "content_block_start", index: 0, content_block: { type: "text", text: "", citations: null } },+ { type: "content_block_delta", index: 0, delta: { type: "text_delta", text: "Hel" } },+ { type: "content_block_delta", index: 0, delta: { type: "text_delta", text: "lo" } },+ { type: "content_block_stop", index: 0 },+ { type: "message_delta", delta: { stop_reason: "end_turn", stop_sequence: null, stop_details: null }, usage: { output_tokens: 2 } },+ { type: "message_stop" },+ ];+ return new Response(sse(events), { status: 200, headers: { "content-type": "text/event-stream" } });}) as typeof fetch;try {await agent.run(t.id);@@ -206,6 +215,10 @@ describe("modes", () => {expect(b.body).toMatchObject({ model: "claude-opus-5-5", output_config: { effort: "max" }, fallbacks: "default" });expect(b.headers.get("anthropic-beta")).toContain("server-side-fallback-2026-07-01");expect(b.body.system).toEqual(a.body.system);+ // Streamed, with more room at Extra/Max effort.+ expect(a.body).toMatchObject({ stream: true, max_tokens: 32_000 });+ expect(b.body).toMatchObject({ stream: true, max_tokens: 64_000 });+ expect(agent.getThread(t.id)!.thread.items.filter((i) => i.role === "assistant").map((i) => (i as { text: string }).text)).toEqual(["Hello", "Hello"]);const v = agent.getThread(t.id)!.thread;expect(v).toMatchObject({ mode: "manual", agent: "claude", model: "claude-opus-5-5", effort: "max" });} finally {