Skip to content

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

fix(assistant-ui): handle missing tool call content

Steven Enamakel1e38a3a23dbf
diff --git a/app/src/components/assistant-ui/elements/tool-call.tsx b/app/src/components/assistant-ui/elements/tool-call.tsx
new file mode 100644
index 0000000000..5ce7d01135
--- /dev/null
+++ b/app/src/components/assistant-ui/elements/tool-call.tsx
@@ -0,0 +1,153 @@
+'use client';
+
+/**
+ * assistant-ui's tool-call element: a disclosure row with a label that
+ * shimmers while the call runs and swaps to its settled form, the call's
+ * primary argument as a chip, and a Request / Result panel.
+ *
+ * Vendored from assistant-ui `packages/ui/src/components/react/assistant-ui/elements/tool-call.tsx`
+ * (commit 1abca347). Changes from upstream:
+ * - Radix collapsible (the app's), so the open-state selectors differ.
+ * - Open state may be uncontrolled (`defaultOpen`).
+ * - `icon`, `outcome` and `meta` slots: an OpenHuman call can fail, be
+ * cancelled or wait on the user, and carries a duration; upstream only
+ * knows running / done.
+ * - `request` / `result` take nodes, and `children` replaces the panel body,
+ * so a call can expand into a richer element (terminal, diff, preview).
+ * - `aside` renders between the row and the panel, always visible: a
+ * decision the turn is blocked on must not sit behind a disclosure.
+ * - The panel headings are props, for translation.
+ */
+import { CheckIcon, ChevronRightIcon, CircleXIcon } from 'lucide-react';
+import type { ReactNode } from 'react';
+
+import { cn } from '@/components/assistant-ui/lib/utils';
+import {
+ Collapsible,
+ CollapsibleContent,
+ CollapsibleTrigger,
+} from '@/components/assistant-ui/ui/collapsible';
+
+import { collapsePanel, field, mono, openRotate, ShimmerLabel, SwapLabel } from './surfaces';
+
+export type ToolCallOutcome = 'success' | 'error' | 'cancelled' | 'awaiting';
+
+export interface ToolCallProps {
+ label: string;
+ activeLabel: string;
+ query?: string;
+ request?: ReactNode;
+ result?: ReactNode;
+ running: boolean;
+ outcome?: ToolCallOutcome;
+ icon?: ReactNode;
+ meta?: ReactNode;
+ aside?: ReactNode;
+ children?: ReactNode;
+ requestLabel?: string;
+ resultLabel?: string;
+ open?: boolean;
+ defaultOpen?: boolean;
+ onOpenChange?: (open: boolean) => void;
+ className?: string;
+ 'data-testid'?: string;
+}
+
+export function ToolCall({
+ label,
+ activeLabel,
+ query,
+ request,
+ result,
+ running,
+ outcome = 'success',
+ icon,
+ meta,
+ aside,
+ children,
+ requestLabel = 'Request',
+ resultLabel = 'Result',
+ open,
+ defaultOpen,
+ onOpenChange,
+ className,
+ ...props
+}: ToolCallProps) {
+ const hasPanel = children != null || request != null || result != null;
+ return (
+ <Collapsible
+ data-slot="tool-call"
+ data-outcome={running ? 'running' : outcome}
+ open={open}
+ defaultOpen={defaultOpen}
+ onOpenChange={onOpenChange}
+ className={cn('w-full max-w-sm min-w-0', className)}
+ {...props}>
+ <CollapsibleTrigger
+ disabled={!hasPanel}
+ className="group/trigger text-foreground/55 hover:text-foreground/90 flex w-full min-w-0 items-center gap-2 rounded-md py-1 text-[13.5px] transition-colors outline-none">
+ <ChevronRightIcon
+ className={cn(
+ 'size-3.5 shrink-0 opacity-60',
+ openRotate,
+ !hasPanel && 'invisible'
+ )}
+ />
+ {icon}
+ <SwapLabel active={running ? 0 : 1} className="shrink-0 text-start">
+ <ShimmerLabel
+ active={running && outcome !== 'awaiting'}
+ className="relative inline-block leading-none">
+ {activeLabel}
+ </ShimmerLabel>
+ <>{label}</>
+ </SwapLabel>
+ {query ? (
+ <span
+ data-slot="tool-call-query"
+ className={cn(
+ mono,
+ 'bg-foreground/[0.06] text-foreground/70 min-w-0 truncate rounded-md px-1.5 py-0.5'
+ )}>
+ {query}
+ </span>
+ ) : null}
+ <span className="ms-auto flex shrink-0 items-center justify-end gap-1.5">
+ {meta}
+ {!running && outcome === 'success' ? (
+ <CheckIcon className="fade-in zoom-in-90 animate-in size-3.5 text-emerald-500 duration-200" />
+ ) : null}
+ {!running && (outcome === 'error' || outcome === 'cancelled') ? (
+ <CircleXIcon className="fade-in zoom-in-90 animate-in size-3.5 text-red-500 duration-200" />
+ ) : null}
+ </span>
+ </CollapsibleTrigger>
+ {aside}
+ {hasPanel ? (
+ <CollapsibleContent className={cn(collapsePanel, 'outline-none')}>
+ {children ?? (
+ <div className={cn(field, 'mt-2 overflow-hidden rounded-2xl text-xs')}>
+ {request != null ? (
+ <div className="px-3.5 pt-2.5 pb-2">
+ <p className={cn(mono, 'text-foreground/35 mb-1')}>{requestLabel}</p>
+ <div className="text-foreground/55 max-h-48 overflow-auto font-mono">
+ {request}
+ </div>
+ </div>
+ ) : null}
+ {request != null && result != null ? (
+ <div className="bg-foreground/[0.06] mx-3.5 h-px" />
+ ) : null}
+ {result != null ? (
+ <div className="px-3.5 pt-2 pb-2.5">
+ <p className={cn(mono, 'text-foreground/35 mb-1')}>{resultLabel}</p>
+ <div className="text-foreground/90 max-h-64 overflow-auto">{result}</div>
+ </div>
+ ) : null}
+ </div>
+ )}
+ </CollapsibleContent>
+ ) : null}
+ </Collapsible>
+ );
+}