Skip to content

Add (build) indicator next to model name for build mode comments#115

Open
julianbenegas wants to merge 1 commit intomainfrom
forums/build-mode-indicator-a3613
Open

Add (build) indicator next to model name for build mode comments#115
julianbenegas wants to merge 1 commit intomainfrom
forums/build-mode-indicator-a3613

Conversation

@julianbenegas
Copy link
Member

  • Check if comment contains build mode metadata in AgentUIMessage
  • Display subtle '(build)' text next to LLM author name
  • Uses muted foreground color and normal font weight for subtlety

- Check if comment contains build mode metadata in AgentUIMessage
- Display subtle '(build)' text next to LLM author name
- Uses muted foreground color and normal font weight for subtlety
@vercel
Copy link
Contributor

vercel bot commented Jan 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
forums Ready Ready Preview, Comment Jan 19, 2026 6:28am

// Check if this is a build mode comment (only relevant for LLM comments)
const isBuildMode =
author.isLlm &&
(comment.content as AgentUIMessage[]).some((m) => m.metadata?.mode === "build")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build mode indicator fails to display for subsequent messages in multi-turn conversations because mode metadata is only added to the first message of the first step

View Details
📝 Patch Details
diff --git a/agent/response-agent.ts b/agent/response-agent.ts
index 2f8d0d1..a61fc52 100644
--- a/agent/response-agent.ts
+++ b/agent/response-agent.ts
@@ -366,7 +366,7 @@ async function streamTextStep({
               ...m,
               id: nanoid(),
               metadata:
-                isFirstStep && index === 0 && mode === "build" ? { mode } : {},
+                mode === "build" ? { mode } : {},
             } satisfies AgentUIMessage
           })
         )

Analysis

Bug Explanation

In agent/response-agent.ts around line 367, the code conditionally adds mode metadata only when three conditions are met simultaneously:

  • isFirstStep && index === 0 && mode === "build"

The problem manifests in two scenarios:

Scenario 1: Multiple messages in first step
When the AI generates multiple messages (e.g., text + tool use), only the first message (index === 0) gets the mode metadata. Subsequent messages in the same first step won't have it.

Scenario 2: Multi-turn conversations
When stepCount > 0 (happens in the while loop in responseAgent lines 71-86), isFirstStep = newMessages.length === 0 becomes false. This means NO messages in steps 2 and beyond receive the mode metadata, even though they were generated in build mode.

In comment-thread.tsx line 84, the code checks:

const isBuildMode =
  author.isLlm &&
  (comment.content as AgentUIMessage[]).some((m) => m.metadata?.mode === "build")

This check uses .some(), which needs at least ONE message with the mode metadata. The current logic in response-agent makes this unreliable because:

  • First step, second+ messages: Won't have mode metadata
  • Any messages in steps 2+: Won't have mode metadata

Result: The build mode indicator "(build)" fails to display for real-world multi-turn conversations or when the first response generates multiple messages.

The Fix

Changed line 367 in agent/response-agent.ts from:

metadata: isFirstStep && index === 0 && mode === "build" ? { mode } : {}

To:

metadata: mode === "build" ? { mode } : {}

This ensures that EVERY message generated when mode="build" receives the mode metadata, regardless of step number or message index. Now the .some() check in comment-thread.tsx will reliably find the build mode indication, guaranteeing the indicator displays correctly in all cases.

The fix is minimal, non-breaking, and doesn't require database migrations because it only changes how existing metadata is populated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant