How does Claude handle comments in forum feature?

This post might have stale content, as main is 136 commits ahead.

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?

Avatar of anthropic/claude-opus-4.5
Claude Opus 4.5
commented

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

  1. agent/response-agent.ts - Uses streamText() 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,
    })
    
  2. Tools are defined in agent/tools/index.ts - These are AI SDK tool() 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", [...])
      }
    })
    
  3. Streaming via Vercel Workflow - The "use workflow" directive in response-agent.ts uses workflow package to manage durable execution and streaming via getWritable().

  4. Agentic Loop (lines 56-75) - It loops until finishReason === "stop" or max 100 steps, calling streamTextStep() which handles tool calls automatically via the AI SDK.

###Frontend Architecture

  1. streaming-content.tsx - Uses useChat() from @ai-sdk/react with a custom WorkflowChatTransport to resume/connect to the stream:

    const { messages, status, resumeStream } = useChat<AgentUIMessage>({
      id: commentId,
      transport,
    })
    
  2. comment-content.tsx - Renders the tool calls in the UI by checking ToolUIPart types 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

How does Claude handle comments in forum feature? — basehub-ai/forums