How does Claude handle comments in forum feature?
for the claude "comments" in the forum feature, is this using claude code and outputting tool calls from claude code there in the UI or just claude api calls with Tool use and updating UI with those?
Now I have a complete picture. Let me summarize:
##Answer
This is NOT Claude Code — it's using the Vercel AI SDK (ai package) with Claude API calls via tool use, and updating the UI with the results.
Here's how it works:
###Backend Architecture
-
agent/response-agent.ts- UsesstreamText()from the Vercel AI SDK (line 210):const result = streamText({ messages: await convertToModelMessages(allMessages), tools: getTools({ workspace }), system: `You're assisting users in a forum...`, model, }) -
Tools are defined in
agent/tools/index.ts- These are AI SDKtool()definitions (Read, Grep, List, WebSearch, WebExtract, ReadPost) that execute in a Vercel Sandbox environment:Read: tool({ description: "Reads a file...", inputSchema: z.object({...}), outputSchema: z.object({...}), execute: async ({ path, startLine, endLine }) => { // Runs command in sandbox const result = await context.workspace.sandbox.runCommand("bash", [...]) } }) -
Streaming via Vercel Workflow - The
"use workflow"directive inresponse-agent.tsusesworkflowpackage to manage durable execution and streaming viagetWritable(). -
Agentic Loop (lines 56-75) - It loops until
finishReason === "stop"or max 100 steps, callingstreamTextStep()which handles tool calls automatically via the AI SDK.
###Frontend Architecture
-
streaming-content.tsx- UsesuseChat()from@ai-sdk/reactwith a customWorkflowChatTransportto resume/connect to the stream:const { messages, status, resumeStream } = useChat<AgentUIMessage>({ id: commentId, transport, }) -
comment-content.tsx- Renders the tool calls in the UI by checkingToolUIParttypes and displaying formatted tool inputs/outputs (like showing grep results as "pattern" → X matches in Y files).
###Key Insight
The tool definitions in this repo (Read, Grep, List, etc.) are the same tools you see being invoked when you interact with me in this forum! The tools run bash commands in a Vercel Sandbox that has the repo cloned, and the AI SDK handles the tool-use loop automatically.
END OF POST