From d99c58117937a93cde472ceb9f26c6cda35c60d7 Mon Sep 17 00:00:00 2001 From: simosmik Date: Thu, 12 Feb 2026 12:36:51 +0000 Subject: [PATCH] refactor(tools): improve Task tool display formatting Update Task tool config to show cleaner subagent information in the UI. Simplifies the input display by showing only the prompt when no optional fields are present, reducing visual clutter. Updates title format to "Subagent / {type}" for better categorization. Enhances result display to better handle complex agent response structures with array content types, extracting text blocks for cleaner presentation. --- .../chat/tools/configs/toolConfigs.ts | 54 +++++++++++++------ 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/src/components/chat/tools/configs/toolConfigs.ts b/src/components/chat/tools/configs/toolConfigs.ts index 49b623e..01499f6 100644 --- a/src/components/chat/tools/configs/toolConfigs.ts +++ b/src/components/chat/tools/configs/toolConfigs.ts @@ -381,28 +381,32 @@ export const TOOL_CONFIGS: Record = { title: (input) => { const subagentType = input.subagent_type || 'Agent'; const description = input.description || 'Running task'; - return `${subagentType}: ${description}`; + return `Subagent / ${subagentType}: ${description}`; }, defaultOpen: true, contentType: 'markdown', getContentProps: (input) => { - // Format the subagent task details in a readable way + // If only prompt exists (and required fields), show just the prompt + // Otherwise show all available fields + const hasOnlyPrompt = input.prompt && + !input.model && + !input.resume; + + if (hasOnlyPrompt) { + return { + content: input.prompt || '' + }; + } + + // Format multiple fields const parts = []; - if (input.subagent_type) { - parts.push(`**Agent Type:** ${input.subagent_type}`); - } - - if (input.description) { - parts.push(`**Description:** ${input.description}`); - } - if (input.model) { parts.push(`**Model:** ${input.model}`); } if (input.prompt) { - parts.push(`**Prompt:**\n\`\`\`\n${input.prompt}\n\`\`\``); + parts.push(`**Prompt:**\n${input.prompt}`); } if (input.resume) { @@ -420,12 +424,32 @@ export const TOOL_CONFIGS: Record = { }, result: { type: 'collapsible', - title: 'Agent Response', + title: (result) => { + // Check if result has content with type array (agent results often have this structure) + if (result && result.content && Array.isArray(result.content)) { + return 'Subagent Response'; + } + return 'Subagent Result'; + }, defaultOpen: true, contentType: 'markdown', - getContentProps: (result) => ({ - content: String(result.content || result || '') - }) + getContentProps: (result) => { + // Handle agent results which may have complex structure + if (result && result.content) { + // If content is an array (typical for agent responses with multiple text blocks) + if (Array.isArray(result.content)) { + const textContent = result.content + .filter(item => item.type === 'text') + .map(item => item.text) + .join('\n\n'); + return { content: textContent || 'No response text' }; + } + // If content is already a string + return { content: String(result.content) }; + } + // Fallback to string representation + return { content: String(result || 'No response') }; + } } },