fix: deduplicate agent response text from task history

Task history contains multiple status-update messages that may
reference the same A2UI surface. Use only the last non-empty
agent response to avoid duplicate text in Chat output.
This commit is contained in:
Adam Weidman
2026-02-12 11:20:32 -05:00
parent 470228e7a0
commit d1ca874dd1

View File

@@ -81,10 +81,13 @@ export function renderResponse(
responseTexts.push(`_${thought.subject}_: ${thought.description}`);
}
// Add agent response text (from A2UI surfaces)
for (const agentResponse of agentResponses) {
if (agentResponse.text) {
responseTexts.push(agentResponse.text);
// Add agent response text (from A2UI surfaces).
// Use only the last non-empty response since later updates supersede earlier
// ones for the same surface (history contains multiple status-update messages).
for (let i = agentResponses.length - 1; i >= 0; i--) {
if (agentResponses[i].text) {
responseTexts.push(agentResponses[i].text);
break;
}
}