Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(web): tool names in sans, not-called list states its status once (#18400)

Trang Nguyen07af6fd4240a
diff --git a/web/src/features/traces/components/IOPreview/components/ToolCallDefinitionCard.stories.tsx b/web/src/features/traces/components/IOPreview/components/ToolCallDefinitionCard.stories.tsx
index 6b76a6aca2..12fa07e117 100644
--- a/web/src/features/traces/components/IOPreview/components/ToolCallDefinitionCard.stories.tsx
+++ b/web/src/features/traces/components/IOPreview/components/ToolCallDefinitionCard.stories.tsx
@@ -1,3 +1,5 @@
+import { expect, userEvent, waitFor, within } from "storybook/test";
+
import preview from "../../../../../../.storybook/preview";
import {
ToolCallDefinitionCard,
@@ -183,3 +185,53 @@ export const WithLongToolNames = meta.story({
]),
},
});
+
+const manyToolNames = [
+ "langfuse_getPrompt",
+ "langfuse_getPromptUnresolved",
+ "langfuse_listPrompts",
+ "langfuse_listObservations",
+ "langfuse_getObservation",
+ "langfuse_getObservationFieldSchema",
+ "langfuse_getObservationFilterSchema",
+ "langfuse_getObservationFilterValues",
+ "langfuse_listAnnotationQueues",
+ "langfuse_getAnnotationQueue",
+ "langfuse_listAnnotationQueueItems",
+ "langfuse_createScoreConfigForProject",
+ "langfuse_searchLangfuseDocs",
+ "langfuse_proposeRedirect",
+ "langfuse_listDatasets",
+ "langfuse_getDataset",
+ "langfuse_listSessions",
+ "langfuse_getSession",
+];
+const calledNames = new Set(manyToolNames.slice(12));
+
+/** Both groups collapse: more than five called, more than three not called. */
+export const ManyTools = meta.story({
+ args: {
+ tools: manyToolNames.map((name) => ({ name })),
+ toolCallCounts: new Map(
+ manyToolNames.map((name) => [name, calledNames.has(name) ? 1 : 0]),
+ ),
+ toolCallsByName: new Map(),
+ toolNameToDefinitionNumber: new Map(
+ manyToolNames.map((name, index) => [name, index + 1]),
+ ),
+ },
+});
+
+export const NotCalledListOpen = meta.story({
+ name: "(Test) Not Called List Open",
+ args: ManyTools.input.args,
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ await userEvent.hover(
+ canvas.getByRole("button", { name: /available tools were not called/i }),
+ );
+ const body = within(canvasElement.ownerDocument.body);
+ await waitFor(() => expect(body.getByText("Not called")).toBeVisible());
+ await expect(body.queryByText("not called")).toBeNull();
+ },
+});
diff --git a/web/src/features/traces/components/IOPreview/components/ToolCallDefinitionCard.tsx b/web/src/features/traces/components/IOPreview/components/ToolCallDefinitionCard.tsx
index 44f7b76926..105e856ff4 100644
--- a/web/src/features/traces/components/IOPreview/components/ToolCallDefinitionCard.tsx
+++ b/web/src/features/traces/components/IOPreview/components/ToolCallDefinitionCard.tsx
@@ -113,16 +113,27 @@ function getStatusText(callCount: number) {
}
function ToolGroupHoverContent({
+ kind,
tools,
toolCallCounts,
toolNameToDefinitionNumber,
}: {
+ kind: ToolGroupKind;
tools: ToolDefinition[];
toolCallCounts: Map<string, number>;
toolNameToDefinitionNumber?: Map<string, number>;
}) {
+ const isNotCalledGroup = kind !== "called";
return (
<>
+ {isNotCalledGroup && (
+ <div className="flex items-center justify-between gap-2 border-b px-4 py-2">
+ <span className="text-foreground text-sm font-bold">Not called</span>
+ <span className="text-foreground-tertiary font-mono text-xs">
+ {tools.length} {tools.length === 1 ? "tool" : "tools"}
+ </span>
+ </div>
+ )}
<div className="flex flex-col gap-1 p-2">
{tools.map((tool, index) => {
const callCount = toolCallCounts.get(tool.name) ?? 0;
@@ -138,7 +149,10 @@ function ToolGroupHoverContent({
<div className="flex min-w-0 items-center gap-2">
<Wrench className="text-muted-foreground icon-base shrink-0" />
<span
- className="ph-no-capture text-foreground block truncate font-mono text-xs font-bold"
+ className={cn(
+ "ph-no-capture text-foreground block truncate text-sm",
+ !isNotCalledGroup && "font-bold",
+ )}
title={tool.name}
>
{toolDefinitionNumber !== undefined && (
@@ -147,16 +161,18 @@ function ToolGroupHoverContent({
{tool.name}
</span>
</div>
- <Badge
- variant={callCount > 0 ? undefined : "secondary"}
- className={cn(
- "shrink-0 text-xs font-bold",
- callCount > 0 &&
- "bg-light-green text-dark-green hover:bg-light-green border-transparent select-none",
- )}
- >
- {getStatusText(callCount)}
- </Badge>
+ {!isNotCalledGroup && (
+ <Badge
+ variant={callCount > 0 ? undefined : "secondary"}
+ className={cn(
+ "shrink-0 text-xs font-bold",
+ callCount > 0 &&
+ "bg-light-green text-dark-green hover:bg-light-green border-transparent select-none",
+ )}
+ >
+ {getStatusText(callCount)}
+ </Badge>
+ )}
</div>
);
})}
@@ -246,6 +262,7 @@ function ToolGroupSummary({
content={
<div className="max-h-96 w-80 max-w-[calc(100vw-2rem)] overflow-auto">
<ToolGroupHoverContent
+ kind={kind}
tools={tools}
toolCallCounts={toolCallCounts}
toolNameToDefinitionNumber={toolNameToDefinitionNumber}
@@ -348,7 +365,7 @@ function ToolDefinitionRow({
<div className="flex min-w-0 items-center gap-2">
<Wrench className="text-muted-foreground icon-base shrink-0" />
<span
- className="ph-no-capture text-foreground block truncate font-mono text-xs font-bold"
+ className="ph-no-capture text-foreground block truncate text-sm font-bold"
title={tool.name}
>
{toolDefinitionNumber !== undefined && (