feat(runs,ui): the trail shows each model request and response, connector calls and delivery attempts
The run trail exposes the model request the journal recorded and its finish reason. Each model and tool step opens a Request and a Response, and each decision lists the connector calls behind it. The composer lists each delivery attempt with its outcome and response.
This commit is contained in:
5 files changed
+115
-18
No files matched your search
+11
-5
@@ -101,11 +101,16 @@ type TrailEntry struct {
|
||||
Reasoning string `json:"reasoning,omitzero"`
|
||||
ToolCalls []ToolCallView `json:"tool_calls,omitzero"`
|
||||
Usage *chat.Usage `json:"usage,omitzero"`
|
||||
Input string `json:"input,omitzero"`
|
||||
Output string `json:"output,omitzero"`
|
||||
Value jsontext.Value `json:"value,omitzero"`
|
||||
Error string `json:"error,omitzero"`
|
||||
Unknown bool `json:"unknown,omitzero"`
|
||||
// Request is the model request exactly as it was sent: the messages, the
|
||||
// tools offered and the sampling settings.
|
||||
Request jsontext.Value `json:"request,omitzero"`
|
||||
// FinishReason is the wire finish reason of a model call.
|
||||
FinishReason string `json:"finish_reason,omitzero"`
|
||||
Input string `json:"input,omitzero"`
|
||||
Output string `json:"output,omitzero"`
|
||||
Value jsontext.Value `json:"value,omitzero"`
|
||||
Error string `json:"error,omitzero"`
|
||||
Unknown bool `json:"unknown,omitzero"`
|
||||
}
|
||||
|
||||
// ToolCallView is a tool call a model asked for.
|
||||
@@ -331,6 +336,7 @@ func entry(s store.Recorded) TrailEntry {
|
||||
if je.Kind == agentloop.EntryCompact {
|
||||
e.Kind = "compaction"
|
||||
}
|
||||
e.Request, e.FinishReason = je.Request, je.FinishReason
|
||||
usage := je.Usage
|
||||
e.Usage = &usage
|
||||
if je.Message != nil {
|
||||
|
||||
@@ -52,6 +52,26 @@ const ceilingTone = (v: Verdict): Tone => (v.failed ? "warn" : "secondary");
|
||||
<CodeBlockContent wrap class="max-h-40">{{ json(decision.action.input) }}</CodeBlockContent>
|
||||
</CodeBlock>
|
||||
|
||||
<details v-if="decision.calls?.length" class="text-caption">
|
||||
<summary class="cursor-pointer text-muted-foreground">Connector calls</summary>
|
||||
<div class="mt-1 flex flex-col gap-2">
|
||||
<div v-for="(c, i) in decision.calls" :key="i" class="flex flex-col gap-1 border-l pl-2">
|
||||
<span class="font-medium">{{ c.connector }} {{ c.method }}</span>
|
||||
<span class="text-muted-foreground">Request</span>
|
||||
<CodeBlock size="sm">
|
||||
<CodeBlockContent wrap class="max-h-40">{{ json(c.request) }}</CodeBlockContent>
|
||||
</CodeBlock>
|
||||
<template v-if="c.response">
|
||||
<span class="text-muted-foreground">Response</span>
|
||||
<CodeBlock size="sm">
|
||||
<CodeBlockContent wrap class="max-h-40">{{ json(c.response) }}</CodeBlockContent>
|
||||
</CodeBlock>
|
||||
</template>
|
||||
<span v-if="c.error" class="text-destructive">{{ c.error }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<ul class="flex flex-col gap-1.5">
|
||||
<li v-for="v in decision.verdicts" :key="v.guard" class="flex flex-col gap-0.5">
|
||||
<span class="flex items-center gap-2">
|
||||
|
||||
@@ -3,6 +3,7 @@ import { computed, onBeforeUnmount, onMounted, ref } from "vue";
|
||||
import { RouterLink } from "vue-router";
|
||||
|
||||
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { ReadError } from "@/components/ui/read-error";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Section } from "@/components/ui/section";
|
||||
@@ -109,6 +110,20 @@ onBeforeUnmount(() => controller.abort());
|
||||
</span>
|
||||
</template>
|
||||
<p class="whitespace-pre-wrap text-label">{{ m.body }}</p>
|
||||
<details v-if="m.attempts?.length" class="mt-2 text-caption">
|
||||
<summary class="cursor-pointer text-muted-foreground">Delivery attempts</summary>
|
||||
<ul class="mt-1 flex flex-col gap-1">
|
||||
<li v-for="a in m.attempts" :key="`${a.channel}:${a.attempt}`" class="flex flex-wrap items-center gap-2">
|
||||
<span class="font-medium">{{ a.channel }}</span>
|
||||
<span class="text-muted-foreground">Attempt {{ a.attempt }}</span>
|
||||
<Badge :variant="a.ok ? 'secondary' : 'danger'">{{ a.ok ? "Delivered" : "Failed" }}</Badge>
|
||||
<span class="tabular-nums text-muted-foreground">{{ a.duration_ms }} ms</span>
|
||||
<Timestamp :at="a.at" />
|
||||
<span v-if="a.response" class="font-mono">{{ a.response }}</span>
|
||||
<span v-if="a.error" class="text-destructive">{{ a.error }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</details>
|
||||
<div v-if="wantsAnswer(m)" class="mt-3 flex items-center gap-2">
|
||||
<Button size="sm" :disabled="answering === m.request_id" @click="answer(m, true)">Approve</Button>
|
||||
<Button variant="outline" size="sm" :disabled="answering === m.request_id" @click="answer(m, false)">Deny</Button>
|
||||
|
||||
+44
-13
@@ -19,7 +19,7 @@ import {
|
||||
TraceTitle,
|
||||
} from "@/components/ui/trace";
|
||||
import ActionTrailView from "./ActionTrailView.vue";
|
||||
import { runTrail, type Trail, type TrailEntry, Unauthorized } from "./api";
|
||||
import { runTrail, type Trail, type TrailEntry, type Usage, Unauthorized } from "./api";
|
||||
import { runTone } from "./state";
|
||||
|
||||
/** A run's decision trail: what started it, every step in order, and how it ended. */
|
||||
@@ -78,6 +78,12 @@ function title(e: TrailEntry): string {
|
||||
}
|
||||
|
||||
const json = (v: unknown) => JSON.stringify(v, null, 2);
|
||||
|
||||
const usageRows = (u: Usage) => [
|
||||
{ label: "Prompt tokens", value: u.prompt_tokens.toLocaleString() },
|
||||
{ label: "Completion tokens", value: u.completion_tokens.toLocaleString() },
|
||||
{ label: "Total tokens", value: u.total_tokens.toLocaleString() },
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -125,21 +131,46 @@ const json = (v: unknown) => JSON.stringify(v, null, 2);
|
||||
</TraceCollapsibleTrigger>
|
||||
<TraceCollapsibleContent>
|
||||
<div class="flex flex-col gap-2 text-label">
|
||||
<p v-if="e.reasoning" class="whitespace-pre-wrap text-muted-foreground">{{ e.reasoning }}</p>
|
||||
<p v-if="e.text" class="whitespace-pre-wrap">{{ e.text }}</p>
|
||||
<CodeBlock v-for="(c, i) in e.tool_calls" :key="i" size="sm">
|
||||
<CodeBlockContent wrap>{{ c.name }} {{ c.input }}</CodeBlockContent>
|
||||
</CodeBlock>
|
||||
<CodeBlock v-if="e.input" size="sm">
|
||||
<CodeBlockContent wrap>{{ e.input }}</CodeBlockContent>
|
||||
</CodeBlock>
|
||||
<CodeBlock v-if="e.output" size="sm">
|
||||
<CodeBlockContent wrap class="max-h-64">{{ e.output }}</CodeBlockContent>
|
||||
</CodeBlock>
|
||||
<details v-if="e.request">
|
||||
<summary class="cursor-pointer text-caption text-muted-foreground">Request</summary>
|
||||
<CodeBlock size="sm" class="mt-1">
|
||||
<CodeBlockContent wrap class="max-h-64">{{ json(e.request) }}</CodeBlockContent>
|
||||
</CodeBlock>
|
||||
</details>
|
||||
<details v-if="e.kind === 'model' || e.kind === 'compaction'">
|
||||
<summary class="cursor-pointer text-caption text-muted-foreground">Response</summary>
|
||||
<div class="mt-1 flex flex-col gap-2">
|
||||
<p v-if="e.reasoning" class="whitespace-pre-wrap text-muted-foreground">{{ e.reasoning }}</p>
|
||||
<p v-if="e.text" class="whitespace-pre-wrap">{{ e.text }}</p>
|
||||
<CodeBlock v-for="(c, i) in e.tool_calls" :key="i" size="sm">
|
||||
<CodeBlockContent wrap>{{ c.name }} {{ c.input }}</CodeBlockContent>
|
||||
</CodeBlock>
|
||||
<p v-if="e.finish_reason" class="text-caption text-muted-foreground">
|
||||
Finish reason {{ e.finish_reason }}
|
||||
</p>
|
||||
<MetadataList v-if="e.usage" :rows="usageRows(e.usage)" />
|
||||
<p v-if="e.error" class="text-destructive">{{ e.error }}</p>
|
||||
</div>
|
||||
</details>
|
||||
<template v-else-if="e.kind === 'tool'">
|
||||
<details v-if="e.input">
|
||||
<summary class="cursor-pointer text-caption text-muted-foreground">Request</summary>
|
||||
<CodeBlock size="sm" class="mt-1">
|
||||
<CodeBlockContent wrap class="max-h-64">{{ e.input }}</CodeBlockContent>
|
||||
</CodeBlock>
|
||||
</details>
|
||||
<details v-if="e.output || e.error">
|
||||
<summary class="cursor-pointer text-caption text-muted-foreground">Response</summary>
|
||||
<p v-if="e.error" class="mt-1 text-destructive">{{ e.error }}</p>
|
||||
<CodeBlock v-if="e.output" size="sm" class="mt-1">
|
||||
<CodeBlockContent wrap class="max-h-64">{{ e.output }}</CodeBlockContent>
|
||||
</CodeBlock>
|
||||
</details>
|
||||
</template>
|
||||
<CodeBlock v-if="e.kind === 'step' && e.value !== undefined" size="sm">
|
||||
<CodeBlockContent wrap class="max-h-64">{{ json(e.value) }}</CodeBlockContent>
|
||||
</CodeBlock>
|
||||
<p v-if="e.error" class="text-destructive">{{ e.error }}</p>
|
||||
<p v-if="e.error && e.kind === 'step'" class="text-destructive">{{ e.error }}</p>
|
||||
</div>
|
||||
</TraceCollapsibleContent>
|
||||
</TraceCollapsible>
|
||||
|
||||
@@ -32,6 +32,18 @@ export interface Message {
|
||||
body: string;
|
||||
expires_at?: string;
|
||||
created_at: string;
|
||||
/** Delivery attempts of the connector rows carrying this message, one per channel. */
|
||||
attempts?: MessageAttempt[];
|
||||
}
|
||||
|
||||
export interface MessageAttempt {
|
||||
channel: string;
|
||||
attempt: number;
|
||||
at: string;
|
||||
ok: boolean;
|
||||
response?: string;
|
||||
error?: string;
|
||||
duration_ms: number;
|
||||
}
|
||||
|
||||
export interface Usage {
|
||||
@@ -72,6 +84,9 @@ export interface TrailEntry {
|
||||
reasoning?: string;
|
||||
tool_calls?: { name: string; input: string }[];
|
||||
usage?: Usage;
|
||||
/** The model request exactly as it was sent: messages, tools offered and sampling settings. */
|
||||
request?: unknown;
|
||||
finish_reason?: string;
|
||||
input?: string;
|
||||
output?: string;
|
||||
value?: unknown;
|
||||
@@ -103,6 +118,14 @@ export interface Verdict {
|
||||
failed?: string;
|
||||
}
|
||||
|
||||
export interface ConnectorCall {
|
||||
connector: string;
|
||||
method: string;
|
||||
request: unknown;
|
||||
response?: unknown;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export interface Decision {
|
||||
id: string;
|
||||
key: string;
|
||||
@@ -121,6 +144,8 @@ export interface Decision {
|
||||
change_request_rule?: string;
|
||||
reason?: string;
|
||||
at: string;
|
||||
/** The connector calls behind the decision: resolve, target facts and invoke. */
|
||||
calls?: ConnectorCall[];
|
||||
}
|
||||
|
||||
export interface ApprovalRequest {
|
||||
|
||||
Reference in new issue
Block a user