Skip to content

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

fix(sessions): show tool rows with nested observations (#17826)

Ben Bachemb979116fdcc0
diff --git a/web/src/features/sessions/SessionConversationTimeline/SessionConversationTimeline.stories.tsx b/web/src/features/sessions/SessionConversationTimeline/SessionConversationTimeline.stories.tsx
index 64639b7c06..b18223f124 100644
--- a/web/src/features/sessions/SessionConversationTimeline/SessionConversationTimeline.stories.tsx
+++ b/web/src/features/sessions/SessionConversationTimeline/SessionConversationTimeline.stories.tsx
@@ -1901,7 +1901,7 @@ const nestedObservation = ({
}: {
id: string;
parentObservationId: string | null;
- type: "AGENT" | "GENERATION" | "TOOL";
+ type: "AGENT" | "GENERATION" | "TOOL" | "SPAN";
input: unknown;
output: unknown;
offset: number;
@@ -2746,6 +2746,144 @@ export const ToolObservationDataOnly = meta.story({
},
});
+export const ToolWithNestedObservation = meta.story({
+ name: "(Test) Tool With Nested Observation",
+ args: {
+ ...loadedArgs,
+ traces: [
+ {
+ trace: { ...trace, observationCount: 3 },
+ turnNumber: 1,
+ observations: [
+ nestedObservation({
+ id: "assistant-run",
+ parentObservationId: null,
+ type: "AGENT",
+ input: null,
+ output: null,
+ offset: 0,
+ }),
+ nestedObservation({
+ id: "lookup-record",
+ parentObservationId: "assistant-run",
+ type: "TOOL",
+ input: { recordId: "record-1" },
+ output: { found: true },
+ offset: 1,
+ }),
+ nestedObservation({
+ id: "lookup-log",
+ parentObservationId: "lookup-record",
+ type: "SPAN",
+ input: null,
+ output: null,
+ offset: 2,
+ }),
+ ],
+ },
+ ],
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ await expect(
+ canvasElement.querySelector(
+ '[data-session-observation-id="lookup-record"]',
+ ),
+ ).toBeInTheDocument();
+ await userEvent.click(canvas.getByRole("button", { name: "Show 1 span" }));
+ await expect(canvas.getByText("lookup-log")).toBeInTheDocument();
+ await expect(
+ canvasElement.querySelector(
+ '[data-session-observation-id="lookup-record"]',
+ ),
+ ).toBeInTheDocument();
+ },
+});
+
+export const CodingAgentSubagentTurn = meta.story({
+ name: "(Test) Coding Agent Subagent Turn Inside Tool",
+ args: {
+ ...loadedArgs,
+ traces: [
+ {
+ trace: { ...trace, observationCount: 6 },
+ turnNumber: 1,
+ observations: [
+ nestedObservation({
+ id: "coding-agent-turn",
+ parentObservationId: null,
+ type: "AGENT",
+ input: null,
+ output: null,
+ offset: 0,
+ }),
+ nestedObservation({
+ id: "spawn-reviewer",
+ parentObservationId: "coding-agent-turn",
+ type: "TOOL",
+ input: { task: "Review the new search endpoint" },
+ output: { summary: "Found one missing test" },
+ offset: 1,
+ }),
+ nestedObservation({
+ id: "reviewer-turn",
+ parentObservationId: "spawn-reviewer",
+ type: "AGENT",
+ input: null,
+ output: null,
+ offset: 2,
+ }),
+ nestedObservation({
+ id: "reviewer-analysis",
+ parentObservationId: "reviewer-turn",
+ type: "GENERATION",
+ input: "Review the search endpoint",
+ output: "I will inspect the handler and its tests.",
+ offset: 3,
+ }),
+ nestedObservation({
+ id: "read-search-tests",
+ parentObservationId: "reviewer-turn",
+ type: "TOOL",
+ input: { path: "search.test.ts" },
+ output: { cases: 3 },
+ offset: 4,
+ }),
+ nestedObservation({
+ id: "reviewer-summary",
+ parentObservationId: "reviewer-turn",
+ type: "GENERATION",
+ input: null,
+ output: "Add a test for an empty search query.",
+ offset: 5,
+ }),
+ ],
+ },
+ ],
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ await expect(
+ canvasElement.querySelector(
+ '[data-session-observation-id="spawn-reviewer"]',
+ ),
+ ).toBeInTheDocument();
+
+ await userEvent.click(
+ canvas.getByRole("button", {
+ name: "Show 2 generations, tools: read-search-tests, and 1 agent",
+ }),
+ );
+ await expect(canvas.getByText("reviewer-turn")).toBeInTheDocument();
+ await userEvent.click(
+ canvas.getByRole("button", {
+ name: "Show 2 generations and tools: read-search-tests",
+ }),
+ );
+ await expect(canvas.getByText("read-search-tests")).toBeInTheDocument();
+ },
+});
+
export const GenerationToolDataOnly = meta.story({
name: "(Test) Generation Tool Data Only",
args: toolShapeArgs({
diff --git a/web/src/features/sessions/SessionConversationTimeline/components/SessionConversationTimelineTrace/SessionConversationTimelineTrace.tsx b/web/src/features/sessions/SessionConversationTimeline/components/SessionConversationTimelineTrace/SessionConversationTimelineTrace.tsx
index 236d7e0091..96bce89b65 100644
--- a/web/src/features/sessions/SessionConversationTimeline/components/SessionConversationTimelineTrace/SessionConversationTimelineTrace.tsx
+++ b/web/src/features/sessions/SessionConversationTimeline/components/SessionConversationTimelineTrace/SessionConversationTimelineTrace.tsx
@@ -909,7 +909,8 @@ function LoadedSessionConversationTimeline({
}
onOpenInTraceView={() => onOpenObservation(observation.id)}
/>
- ) : !isToolStart && !isEmptyEnd ? (
+ ) : !isEmptyEnd &&
+ (observation.type !== "TOOL" || phase !== "end") ? (
<SessionTimelineObservation
observation={observation}
parsed={parsed}