added logic to skip rendering pending tool (#1250)

This commit is contained in:
Neha Prasad 2026-02-04 18:20:07 +05:30 committed by GitHub
parent 2d16d73ba1
commit b065ce75b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View file

@ -67,6 +67,7 @@ export class MessageList extends LitElement {
.pendingToolCalls=${this.pendingToolCalls}
.toolResultsById=${resultByCallId}
.hideToolCalls=${false}
.hidePendingToolCalls=${this.isStreaming}
.onCostClick=${this.onCostClick}
></assistant-message>`,
});

View file

@ -89,6 +89,7 @@ export class AssistantMessage extends LitElement {
@property({ type: Boolean }) hideToolCalls = false;
@property({ type: Object }) toolResultsById?: Map<string, ToolResultMessageType>;
@property({ type: Boolean }) isStreaming: boolean = false;
@property({ type: Boolean }) hidePendingToolCalls = false;
@property({ attribute: false }) onCostClick?: () => void;
protected override createRenderRoot(): HTMLElement | DocumentFragment {
@ -116,6 +117,11 @@ export class AssistantMessage extends LitElement {
const tool = this.tools?.find((t) => t.name === chunk.name);
const pending = this.pendingToolCalls?.has(chunk.id) ?? false;
const result = this.toolResultsById?.get(chunk.id);
// Skip rendering pending tool calls when hidePendingToolCalls is true
// (used to prevent duplication when StreamingMessageContainer is showing them)
if (this.hidePendingToolCalls && pending && !result) {
continue;
}
// A tool call is aborted if the message was aborted and there's no result for this tool call
const aborted = this.message.stopReason === "aborted" && !result;
orderedParts.push(