Add (build) indicator next to model name for build mode comments#115
Add (build) indicator next to model name for build mode comments#115julianbenegas wants to merge 1 commit intomainfrom
Conversation
julianbenegas
commented
Jan 19, 2026
- 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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| // 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") |
There was a problem hiding this comment.
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.