Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(chat): infer descriptive labels for degraded tools\n\n

Steven Enamakel75a70fbff625
diff --git a/app/src/features/conversations/components/ChatToolParts.test.tsx b/app/src/features/conversations/components/ChatToolParts.test.tsx
index 1e6b9283e9..4be0fe60b7 100644
--- a/app/src/features/conversations/components/ChatToolParts.test.tsx
+++ b/app/src/features/conversations/components/ChatToolParts.test.tsx
@@ -88,4 +88,24 @@ describe('ChatToolParts', () => {
expect(screen.getByRole('strong')).toHaveTextContent('Example Domain');
expect(screen.queryByText('Content', { exact: true })).not.toBeInTheDocument();
});
+
+ it('infers web search labels when a persisted tool name degraded to tool', () => {
+ render(
+ <ChatToolFallback
+ type="tool-call"
+ toolName="tool"
+ toolCallId="search-generic"
+ args={{ query: 'latest world news' } as never}
+ argsText={'{"query":"latest world news"}'}
+ result="# Search results\n\n- Headline"
+ status={{ type: 'complete' }}
+ addResult={() => {}}
+ resume={() => {}}
+ respondToApproval={() => {}}
+ />
+ );
+
+ expect(screen.getByTestId('assistant-ui-tool-call')).toHaveTextContent('Searched the web');
+ expect(screen.getByTestId('assistant-ui-tool-call')).not.toHaveTextContent(/^Tool done$/);
+ });
});
diff --git a/app/src/features/conversations/components/ChatToolParts.tsx b/app/src/features/conversations/components/ChatToolParts.tsx
index fef105e5b0..cb6162a6c1 100644
--- a/app/src/features/conversations/components/ChatToolParts.tsx
+++ b/app/src/features/conversations/components/ChatToolParts.tsx
@@ -99,11 +99,31 @@ function friendlyLabel(key: string): string {
.replace(/^./, char => char.toUpperCase());
}
-function toolDisplayName(toolName: string, running: boolean): string {
- if (toolName === 'web_fetch') return running ? 'Fetching from the web' : 'Fetched from the web';
- if (toolName === 'web_search_tool' || toolName === 'web_search') {
+function toolDisplayName(
+ toolName: string,
+ running: boolean,
+ args: unknown,
+ result: unknown
+): string {
+ const lowerName = toolName.toLowerCase();
+ const parsedArgs = parsedValue(args);
+ const argKeys =
+ parsedArgs && typeof parsedArgs === 'object' && !Array.isArray(parsedArgs)
+ ? Object.keys(parsedArgs as object).map(key => key.toLowerCase())
+ : [];
+ const renderedResult = typeof result === 'string' ? result : JSON.stringify(result ?? '');
+ const looksLikeSearch =
+ lowerName.includes('search') ||
+ argKeys.some(key => ['query', 'q', 'search_query'].includes(key)) ||
+ /(?:^|\n)#?\s*search results\b/i.test(renderedResult);
+ const looksLikeFetch =
+ lowerName.includes('fetch') ||
+ argKeys.some(key => ['url', 'uri'].includes(key)) ||
+ /\bstatus=\d{3}\s+url=/i.test(renderedResult);
+ if (looksLikeSearch) {
return running ? 'Searching the web' : 'Searched the web';
}
+ if (looksLikeFetch) return running ? 'Fetching from the web' : 'Fetched from the web';
return formatToolName(toolName);
}
@@ -187,7 +207,7 @@ export const OpenHumanToolCall: ToolCallMessagePartComponent = ({
<CollapsibleTrigger className="group/tool text-muted-foreground hover:text-foreground flex w-full items-center gap-2 px-3 py-2 text-sm transition-colors">
<WrenchIcon className="size-4 shrink-0" />
<span className="text-foreground text-start font-medium">
- {toolDisplayName(toolName, running)}
+ {toolDisplayName(toolName, running, args, result)}
</span>
{running ? (
<span className="bg-muted flex items-center gap-1.5 rounded-full px-2 py-0.5 text-[11px]">
diff --git a/app/src/features/conversations/components/SubagentActivityBlock.tsx b/app/src/features/conversations/components/SubagentActivityBlock.tsx
index d3b4d429d7..6bc5bc6701 100644
--- a/app/src/features/conversations/components/SubagentActivityBlock.tsx
+++ b/app/src/features/conversations/components/SubagentActivityBlock.tsx
@@ -37,12 +37,31 @@ function toolCallTone(status: ToolTimelineEntryStatus): string {
return 'text-coral-700 dark:text-coral-300';
}
-function subagentToolLabel(name: string, status: ToolTimelineEntryStatus): string {
+function subagentToolLabel(
+ name: string,
+ status: ToolTimelineEntryStatus,
+ args: unknown,
+ result: unknown
+): string {
const running = status === 'running';
- if (name === 'web_fetch') return running ? 'Fetching from the web' : 'Fetched from the web';
- if (name === 'web_search_tool' || name === 'web_search') {
+ const lowerName = name.toLowerCase();
+ const argKeys =
+ args && typeof args === 'object' && !Array.isArray(args)
+ ? Object.keys(args as object).map(key => key.toLowerCase())
+ : [];
+ const output = readableToolOutput(result) ?? '';
+ const looksLikeSearch =
+ lowerName.includes('search') ||
+ argKeys.some(key => ['query', 'q', 'search_query'].includes(key)) ||
+ /(?:^|\n)#?\s*search results\b/i.test(output);
+ const looksLikeFetch =
+ lowerName.includes('fetch') ||
+ argKeys.some(key => ['url', 'uri'].includes(key)) ||
+ /\bstatus=\d{3}\s+url=/i.test(output);
+ if (looksLikeSearch) {
return running ? 'Searching the web' : 'Searched the web';
}
+ if (looksLikeFetch) return running ? 'Fetching from the web' : 'Fetched from the web';
return formatToolName(name);
}
@@ -114,11 +133,18 @@ export function ToolCallRow({
detail?: string;
/** Structured why/next explanation for a FAILED child tool call (#4459). */
failure?: ToolFailureExplanation;
+ /** Arguments supplied to the child tool, used for descriptive fallback labels. */
+ args?: unknown;
/** Child tool output, rendered as Markdown when present. */
result?: unknown;
};
}) {
const output = readableToolOutput(call.result);
+ const suppliedLabel = call.displayName?.trim();
+ const label =
+ suppliedLabel && suppliedLabel.toLowerCase() !== 'tool'
+ ? suppliedLabel
+ : subagentToolLabel(call.toolName, call.status, call.args, call.result);
return (
<div className="min-w-0" data-testid="subagent-tool-call">
<div className="flex min-w-0 items-center gap-1.5">
@@ -126,7 +152,7 @@ export function ToolCallRow({
•
</span>
<span className="shrink-0 text-[12px] whitespace-nowrap text-content-secondary">
- {call.displayName ?? subagentToolLabel(call.toolName, call.status)}
+ {label}
</span>
{/* The contextual arg (path / recipient / query) can be long, so it
truncates to a single line and absorbs the row's spare width — the
diff --git a/app/src/features/conversations/components/__tests__/ToolTimelineBlock.test.tsx b/app/src/features/conversations/components/__tests__/ToolTimelineBlock.test.tsx
index f263631005..98cfe6e4a2 100644
--- a/app/src/features/conversations/components/__tests__/ToolTimelineBlock.test.tsx
+++ b/app/src/features/conversations/components/__tests__/ToolTimelineBlock.test.tsx
@@ -119,6 +119,28 @@ describe('SubagentActivityBlock', () => {
expect(screen.queryByText(/"content"/)).not.toBeInTheDocument();
});
+ it('infers a descriptive search label for a degraded subagent tool name', () => {
+ renderInStore(
+ <SubagentActivityBlock
+ subagent={{
+ taskId: 't',
+ agentId: 'researcher',
+ toolCalls: [
+ {
+ callId: 'generic-search',
+ toolName: 'tool',
+ status: 'success',
+ args: { query: 'world news' },
+ result: '# Search results\n\n- Headline',
+ },
+ ],
+ }}
+ />
+ );
+
+ expect(screen.getByTestId('subagent-tool-call')).toHaveTextContent('Searched the web');
+ });
+
it('labels cancelled / awaiting-user calls distinctly (not the green "Done" pill)', () => {
renderInStore(
<SubagentActivityBlock