🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(trace): Improve styling of tool cards for tools with long names (#14688)
Ben Bachem6e013e54c098
diff --git a/.agents/skills/storybook/SKILL.md b/.agents/skills/storybook/SKILL.mdindex ae85f587fb..98b3731b5f 100644--- a/.agents/skills/storybook/SKILL.md+++ b/.agents/skills/storybook/SKILL.md@@ -31,6 +31,7 @@ Keep the existing component, but update it to use the newly created component fo- Use "CSF Next" format by default.- Cover only the relevant component by default.- Avoid custom render functions by default.+- Never use `decorators` to add styling or layout to a story. Stories should render the components as they are.- Use `satisfies` and typed Storybook metadata so invalid args, decorators, and play functions are type-checked.- Use play functions to test user-relevant interactions after render, not to compensate for complex setup or hidden dependencies.- Prefix stories whose primary purpose is interaction test coverage with `(Test)` in the Storybook display name, for example `name: "(Test) Opens Menu"`.diff --git a/web/src/components/trace/components/IOPreview/components/ToolCallDefinitionCard.stories.tsx b/web/src/components/trace/components/IOPreview/components/ToolCallDefinitionCard.stories.tsxnew file mode 100644index 0000000000..dcd85598b9--- /dev/null+++ b/web/src/components/trace/components/IOPreview/components/ToolCallDefinitionCard.stories.tsx@@ -0,0 +1,185 @@+import preview from "../../../../../../.storybook/preview";+import {+ ToolCallDefinitionCard,+ type ToolDefinition,+} from "./ToolCallDefinitionCard";+import type { ToolCallInvocation } from "../hooks/useChatMLParser";++const baseTools: ToolDefinition[] = [+ {+ name: "search_docs",+ description: "Searches product docs for relevant troubleshooting steps.",+ parameters: {+ type: "object",+ properties: {+ query: {+ type: "string",+ description: "What to search for",+ },+ limit: {+ type: "number",+ description: "Maximum number of results",+ },+ },+ required: ["query"],+ },+ },+];++const baseToolCalls = new Map<string, ToolCallInvocation[]>([+ [+ "search_docs",+ [+ {+ id: "call_01HXYZ123",+ name: "search_docs",+ invocationNumber: 1,+ arguments: JSON.stringify({ query: "rate limits", limit: 3 }),+ },+ ],+ ],+]);++const meta = preview.meta({+ component: ToolCallDefinitionCard,+});++export const Default = meta.story({+ args: {+ tools: baseTools,+ toolCallCounts: new Map([["search_docs", 0]]),+ toolCallsByName: new Map(),+ toolNameToDefinitionNumber: new Map([["search_docs", 1]]),+ },+});++export const Called = meta.story({+ args: {+ tools: baseTools,+ toolCallCounts: new Map([["search_docs", 1]]),+ toolCallsByName: baseToolCalls,+ toolNameToDefinitionNumber: new Map([["search_docs", 1]]),+ },+});++export const MultipleTools = meta.story({+ args: {+ tools: [+ ...baseTools,+ {+ name: "create_ticket",+ description: "Creates a support escalation ticket.",+ parameters: {+ type: "object",+ properties: {+ title: { type: "string" },+ priority: { type: "string", enum: ["low", "high"] },+ },+ required: ["title", "priority"],+ },+ },+ {+ name: "notify_team",+ },+ ],+ toolCallCounts: new Map([+ ["search_docs", 2],+ ["create_ticket", 1],+ ["notify_team", 0],+ ]),+ toolCallsByName: new Map<string, ToolCallInvocation[]>([+ [+ "search_docs",+ [+ {+ id: "call_01HXYZ123",+ name: "search_docs",+ invocationNumber: 1,+ arguments: JSON.stringify({ query: "rate limits", limit: 3 }),+ },+ {+ id: "call_01HXYZ124",+ name: "search_docs",+ invocationNumber: 2,+ arguments: JSON.stringify({ query: "retry policy" }),+ },+ ],+ ],+ [+ "create_ticket",+ [+ {+ id: "call_01HXYZ200",+ name: "create_ticket",+ invocationNumber: 1,+ arguments: {+ title: "API requests failing",+ priority: "high",+ },+ },+ ],+ ],+ ]),+ toolNameToDefinitionNumber: new Map([+ ["search_docs", 1],+ ["create_ticket", 2],+ ["notify_team", 3],+ ]),+ },+});++export const WithLongToolNames = meta.story({+ args: {+ tools: [+ {+ name: "search_enterprise_customer_documentation_for_multistep_api_rate_limit_troubleshooting_and_backoff_recommendations",+ description:+ "Looks up long-form support guidance for enterprise API incidents.",+ parameters: {+ type: "object",+ properties: {+ query: { type: "string" },+ },+ required: ["query"],+ },+ },+ {+ name: "create_cross_functional_incident_escalation_ticket_with_customer_context_and_internal_follow_up_requirements",+ description: "Creates a detailed incident escalation ticket.",+ },+ ],+ toolCallCounts: new Map([+ [+ "search_enterprise_customer_documentation_for_multistep_api_rate_limit_troubleshooting_and_backoff_recommendations",+ 1,+ ],+ [+ "create_cross_functional_incident_escalation_ticket_with_customer_context_and_internal_follow_up_requirements",+ 0,+ ],+ ]),+ toolCallsByName: new Map<string, ToolCallInvocation[]>([+ [+ "search_enterprise_customer_documentation_for_multistep_api_rate_limit_troubleshooting_and_backoff_recommendations",+ [+ {+ id: "call_long_01",+ name: "search_enterprise_customer_documentation_for_multistep_api_rate_limit_troubleshooting_and_backoff_recommendations",+ invocationNumber: 1,+ arguments: JSON.stringify({ query: "429 retry guidance" }),+ },+ ],+ ],+ ]),+ toolNameToDefinitionNumber: new Map([+ [+ "search_enterprise_customer_documentation_for_multistep_api_rate_limit_troubleshooting_and_backoff_recommendations",+ 1,+ ],+ [+ "create_cross_functional_incident_escalation_ticket_with_customer_context_and_internal_follow_up_requirements",+ 2,+ ],+ ]),+ },+});diff --git a/web/src/components/trace/components/IOPreview/components/ToolCallDefinitionCard.tsx b/web/src/components/trace/components/IOPreview/components/ToolCallDefinitionCard.tsxindex 7fdf9e6508..310dd6894b 100644--- a/web/src/components/trace/components/IOPreview/components/ToolCallDefinitionCard.tsx+++ b/web/src/components/trace/components/IOPreview/components/ToolCallDefinitionCard.tsx@@ -109,7 +109,7 @@ function ToolCallStatusBadge({<Badgevariant={isCalled ? undefined : "secondary"}className={cn(- "text-xs font-medium",+ "text-xs font-medium whitespace-nowrap",isCalled &&"bg-light-green text-dark-green hover:bg-light-green border-transparent select-none",)}@@ -201,9 +201,12 @@ export function ToolCallDefinitionCard({}}>{/* Left: Tool icon + definition number + name */}- <div className="flex items-center gap-2">- <Wrench className="text-muted-foreground h-3.5 w-3.5" />- <span className="text-foreground font-mono text-xs font-medium">+ <div className="flex min-w-0 items-center gap-2">+ <Wrench className="text-muted-foreground h-3.5 w-3.5 shrink-0" />+ <span+ className="text-foreground block truncate font-mono text-xs font-medium"+ title={tool.name}+ >{toolDefinitionNumber !== undefined && (<span className="mr-1">{toolDefinitionNumber}.</span>)}@@ -212,7 +215,7 @@ export function ToolCallDefinitionCard({</div>{/* Right: Status badge + chevron indicator */}- <div className="flex items-center gap-1.5">+ <div className="flex shrink-0 items-center gap-1.5"><ToolCallStatusBadgeisCalled={isCalled}statusText={statusText}