Skip to content

Automate browser based workflows with AI

feat(copilot): render chat block rows from the recorded run outcome verdict (SKY-10873) (#6532)

Andrew Neilsonda9870abfc77
diff --git a/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.tsx b/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.tsx
index b64bf9363..4fc55909d 100644
--- a/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.tsx
+++ b/skyvern-frontend/src/routes/workflows/copilot/NarrativeView.tsx
@@ -5,6 +5,7 @@ import {
BlockState,
TurnNarrativeState,
effectiveMode,
+ isBlockOk,
parseUtcIsoMs,
toolActivityDisplayLabel,
} from "./narrativeState";
@@ -207,13 +208,21 @@ function useSecondTick(active: boolean): void {
interface FBlockRunProps {
block: BlockState;
+ turnEnded: boolean;
onSelect?: (label: string) => void;
}
-function FBlockRun({ block, onSelect }: FBlockRunProps) {
+function FBlockRun({ block, turnEnded, onSelect }: FBlockRunProps) {
const palette = paletteFor(block.blockType);
const isRunning = block.state === "running";
- const isOk = block.state === "completed";
+ const isCompleted = block.state === "completed";
+ const isEvaluating = isCompleted && block.outcome === "evaluating";
+ // A row stuck in `evaluating` at turn end (dropped stream) renders the
+ // neutral "ran" treatment — never the live verifying beat, never green.
+ const isVerifying = isEvaluating && !turnEnded;
+ const isRanNeutral = isEvaluating && turnEnded;
+ const isOutcomeNotShown = isCompleted && block.outcome === "not_demonstrated";
+ const isOk = isBlockOk(block);
const isFail = block.state === "failed";
const isDraft = block.state === "drafted";
@@ -221,28 +230,36 @@ function FBlockRun({ block, onSelect }: FBlockRunProps) {
? "border-blue-400/60"
: isOk
? "border-emerald-400/60"
- : isFail
- ? "border-rose-400/60"
- : "border-slate-500/60";
+ : isOutcomeNotShown
+ ? "border-amber-400/60"
+ : isFail
+ ? "border-rose-400/60"
+ : "border-slate-500/60";
const accentText = isRunning
? "text-blue-300"
: isOk
? "text-emerald-300"
- : isFail
- ? "text-rose-300"
- : "text-slate-400";
+ : isOutcomeNotShown
+ ? "text-amber-300"
+ : isFail
+ ? "text-rose-300"
+ : isVerifying || isRanNeutral
+ ? "text-slate-300"
+ : "text-slate-400";
const puckBg = isRunning
? "bg-blue-500/15"
: isOk
? "bg-emerald-500/15"
- : isFail
- ? "bg-rose-500/15"
- : "bg-slate-elevation3";
+ : isOutcomeNotShown
+ ? "bg-amber-500/15"
+ : isFail
+ ? "bg-rose-500/15"
+ : "bg-slate-elevation3";
const [userOpen, setUserOpen] = useState<boolean | null>(null);
const defaultOpen = isRunning || isFail;
const open = userOpen === null ? defaultOpen : userOpen;
- const toggleable = isOk;
+ const toggleable = isOk || isOutcomeNotShown || isVerifying || isRanNeutral;
useSecondTick(isRunning);
const elapsed = formatElapsed(block.startedAt, block.endedAt);
const live = isRunning ? liveElapsed(block.startedAt) : null;
@@ -250,11 +267,15 @@ function FBlockRun({ block, onSelect }: FBlockRunProps) {
? (elapsed ?? "done")
: isRunning
? `working${live ? ` · ${live}` : ""}`
- : isFail
- ? "halted"
- : isDraft
- ? "drafted"
- : "queued";
+ : isVerifying
+ ? "ran · verifying outcome…"
+ : isRanNeutral || isOutcomeNotShown
+ ? `ran${elapsed ? ` · ${elapsed}` : ""}`
+ : isFail
+ ? "halted"
+ : isDraft
+ ? "drafted"
+ : "queued";
return (
<div className="flex flex-col">
@@ -275,7 +296,19 @@ function FBlockRun({ block, onSelect }: FBlockRunProps) {
className={`flex h-6 w-6 shrink-0 items-center justify-center rounded-full border text-[11px] font-bold ${accentBorder} ${accentText} ${puckBg}`}
aria-hidden="true"
>
- {isOk ? "✓" : isFail ? "✕" : isRunning ? <Spinner /> : palette.glyph}
+ {isOk ? (
+ "✓"
+ ) : isOutcomeNotShown ? (
+ "!"
+ ) : isVerifying ? (
+ "…"
+ ) : isFail ? (
+ "✕"
+ ) : isRunning ? (
+ <Spinner />
+ ) : (
+ palette.glyph
+ )}
</span>
<div className="flex min-w-0 flex-1 flex-col">
<div className="flex flex-wrap items-baseline gap-x-1.5 gap-y-0.5">
@@ -295,6 +328,12 @@ function FBlockRun({ block, onSelect }: FBlockRunProps) {
{block.activity[block.activity.length - 1]!.text}
</div>
) : null}
+ {!open && isOutcomeNotShown ? (
+ <div className="mt-0.5 text-[12px] leading-[1.5] text-amber-200/80">
+ Outcome not confirmed — the run finished without showing the goal
+ was met.
+ </div>
+ ) : null}
</div>
{toggleable ? (
<span
@@ -333,6 +372,15 @@ function FBlockRun({ block, onSelect }: FBlockRunProps) {
</div>
</div>
) : null}
+ {isOutcomeNotShown ? (
+ <div className="mt-1 flex items-start gap-2 rounded-md border border-amber-400/30 bg-amber-500/10 px-2.5 py-1.5">
+ <span className="text-[11px] font-bold text-amber-300">!</span>
+ <div className="text-[12px] leading-[1.5] text-amber-200/90">
+ {block.outcomeReason ??
+ "The step ran, but the run did not demonstrate the goal was met."}
+ </div>
+ </div>
+ ) : null}
</div>
) : null}
</div>
@@ -499,7 +547,7 @@ function computeTurnSummary(turn: TurnNarrativeState): TurnSummary {
const turnElapsed = formatElapsed(turn.startedAt, turn.endedAt);
if (turnElapsed) stats.push(turnElapsed);
if (!isQA) {
- const ok = rollupBlocks.filter((b) => b.state === "completed").length;
+ const ok = rollupBlocks.filter((b) => isBlockOk(b)).length;
const failed = rollupBlocks.filter((b) => b.state === "failed").length;
const newBlocks = hasEdited ? 0 : (turn.draft?.blockCount ?? 0);
if (ok) stats.push(`${ok} block${ok === 1 ? "" : "s"} ran`);
@@ -602,7 +650,7 @@ function RollupCard({ turn, summary, onExpand }: RollupCardProps) {
const closing =
turn.narrativeSummary?.trim() || turn.terminalMessage?.trim() || "";
const rollupBlocks = latestBlocksByLabel(turn.blocks);
- const completed = rollupBlocks.filter((b) => b.state === "completed");
+ const completed = rollupBlocks.filter((b) => isBlockOk(b));
const failed = rollupBlocks.filter((b) => b.state === "failed");
const showCommit = !summary.isQA && completed.length > 0;
@@ -743,6 +791,7 @@ function DetailView({ turn, onCollapse, onBlockSelect }: DetailViewProps) {
<FBlockRun
key={b.workflowRunBlockId || b.label}
block={b}
+ turnEnded={turn.terminal !== null}
onSelect={onBlockSelect}
/>
))}
diff --git a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsx b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsx
index 50f9869c2..03844d5ce 100644
--- a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsx
+++ b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsx
@@ -35,6 +35,7 @@ import {
WorkflowCopilotCondensingUpdate,
WorkflowCopilotNarrationUpdate,
WorkflowCopilotBlockProgressUpdate,
+ WorkflowCopilotRunOutcomeUpdate,
WorkflowCopilotTurnStartUpdate,
WorkflowCopilotWorkflowDraftUpdate,
WorkflowCopilotChatSender,
@@ -234,6 +235,7 @@ type WorkflowCopilotSsePayload =
| WorkflowCopilotCondensingUpdate
| WorkflowCopilotNarrationUpdate
| WorkflowCopilotBlockProgressUpdate
+ | WorkflowCopilotRunOutcomeUpdate
| WorkflowCopilotTurnStartUpdate
| WorkflowCopilotDesignStartUpdate
| WorkflowCopilotDesignEndUpdate
@@ -1370,6 +1372,7 @@ export function WorkflowCopilotChat({
case "tool_result":
case "narration":
case "block_progress":
+ case "run_outcome":
applyStoredNarrativeEvent(payload);
return false;
case "turn_start": {
diff --git a/skyvern-frontend/src/routes/workflows/copilot/narrativeState.runOutcome.test.ts b/skyvern-frontend/src/routes/workflows/copilot/narrativeState.runOutcome.test.ts
new file mode 100644
index 000000000..a17b3900b
--- /dev/null
+++ b/skyvern-frontend/src/routes/workflows/copilot/narrativeState.runOutcome.test.ts
@@ -0,0 +1,323 @@
+import { describe, expect, it } from "vitest";
+
+import {
+ EMPTY_NARRATIVE,
+ TurnNarrativeState,
+ applyNarrativeEvent,
+ hydrateNarrativeFromPayload,
+ isBlockOk,
+} from "./narrativeState";
+import {
+ WorkflowCopilotBlockProgressUpdate,
+ WorkflowCopilotRunOutcomeUpdate,
+ WorkflowCopilotStreamErrorUpdate,
+ WorkflowCopilotStreamResponseUpdate,
+ WorkflowCopilotTurnStartUpdate,
+} from "./workflowCopilotTypes";
+
+const turnStart = (): WorkflowCopilotTurnStartUpdate => ({
+ type: "turn_start",
+ turn_id: "turn-1",
+ turn_index: 0,
+ mode: "build",
+ timestamp: "2026-06-10T00:00:00Z",
+});
+
+const blockProgress = (
+ overrides: Partial<WorkflowCopilotBlockProgressUpdate> &
+ Pick<WorkflowCopilotBlockProgressUpdate, "block_label" | "status">,
+): WorkflowCopilotBlockProgressUpdate => ({
+ type: "block_progress",
+ workflow_run_block_id: `wrb_${overrides.block_label}`,
+ block_type: "code",
+ iteration: 0,
+ timestamp: "2026-06-10T00:00:04Z",
+ ...overrides,
+});
+
+const runOutcome = (
+ overrides: Partial<WorkflowCopilotRunOutcomeUpdate> &
+ Pick<WorkflowCopilotRunOutcomeUpdate, "verdict">,
+): WorkflowCopilotRunOutcomeUpdate => ({
+ type: "run_outcome",
+ workflow_run_id: "wr_1",
+ workflow_run_block_ids: ["wrb_open_search", "wrb_search_person"],
+ block_labels: ["open_search", "search_person"],
+ reason_code: null,
+ display_reason: null,
+ iteration: 0,
+ timestamp: "2026-06-10T00:01:00Z",
+ ...overrides,
+});
+
+const response = (): WorkflowCopilotStreamResponseUpdate => ({
+ type: "response",
+ workflow_copilot_chat_id: "chat-1",
+ message: "Done.",
+ response_time: "2026-06-10T00:02:00Z",
+ proposal_disposition: "auto_applicable",
+});
+
+const errorUpdate = (): WorkflowCopilotStreamErrorUpdate => ({
+ type: "error",
+ error: "Something broke.",
+});
+
+function reduce(events: Parameters<typeof applyNarrativeEvent>[1][]) {
+ return events.reduce(
+ (state: TurnNarrativeState, event) => applyNarrativeEvent(state, event),
+ EMPTY_NARRATIVE,
+ );
+}
+
+const bothBlocksRan = [
+ turnStart(),
+ blockProgress({ block_label: "open_search", status: "running" }),
+ blockProgress({ block_label: "open_search", status: "completed" }),
+ blockProgress({ block_label: "search_person", status: "running" }),
+ blockProgress({ block_label: "search_person", status: "completed" }),
+];
+
+describe("applyNarrativeEvent — run_outcome", () => {
+ it("negative verdict withholds the success affordance from completed rows", () => {
+ const s = reduce([
+ ...bothBlocksRan,
+ runOutcome({ verdict: "evaluating" }),
+ runOutcome({
+ verdict: "not_demonstrated",
+ reason_code: "blocker_reported",
+ display_reason: "The search stayed gated by a verification challenge.",
+ }),
+ ]);
+ expect(s.blocks).toHaveLength(2);
+ for (const b of s.blocks) {
+ expect(b.state).toBe("completed");
+ expect(b.outcome).toBe("not_demonstrated");
+ expect(b.outcomeReason).toBe(
+ "The search stayed gated by a verification challenge.",
+ );
+ expect(isBlockOk(b)).toBe(false);
+ }
+ });
+
+ it("evaluating hold withholds the success affordance until the final frame", () => {
+ const s = reduce([...bothBlocksRan, runOutcome({ verdict: "evaluating" })]);
+ for (const b of s.blocks) {
+ expect(b.outcome).toBe("evaluating");
+ expect(isBlockOk(b)).toBe(false);
+ }
+ });
+
+ it("response-terminal sweep cannot resurrect success on a negative-verdict row", () => {
+ const s = reduce([
+ turnStart(),
+ blockProgress({ block_label: "open_search", status: "running" }),
+ blockProgress({ block_label: "open_search", status: "completed" }),
+ // search_person never gets its terminal block_progress.
+ blockProgress({ block_label: "search_person", status: "running" }),
+ runOutcome({ verdict: "evaluating" }),
+ runOutcome({
+ verdict: "not_demonstrated",
+ reason_code: "blocker_reported",
+ }),
+ response(),
+ ]);
+ const swept = s.blocks.find((b) => b.label === "search_person")!;
+ expect(swept.state).toBe("completed");
+ expect(swept.outcome).toBe("not_demonstrated");
+ expect(isBlockOk(swept)).toBe(false);
+ expect(s.blocks.some((b) => isBlockOk(b))).toBe(false);
+ });
+
+ it("a row stuck in evaluating at terminal never satisfies isBlockOk", () => {
+ const s = reduce([
+ ...bothBlocksRan,
+ runOutcome({ verdict: "evaluating" }),
+ response(),
+ ]);
+ for (const b of s.blocks) {
+ expect(b.state).toBe("completed");
+ expect(b.outcome).toBe("evaluating");
+ expect(isBlockOk(b)).toBe(false);
+ }
+ });
+
+ it("error-terminal sweep changes lifecycle state only, never the verdict", () => {
+ const s = reduce([
+ turnStart(),
+ blockProgress({ block_label: "search_person", status: "running" }),
+ runOutcome({
+ verdict: "not_demonstrated",
+ workflow_run_block_ids: ["wrb_search_person"],
+ block_labels: ["search_person"],
+ }),
+ errorUpdate(),
+ ]);
+ const b = s.blocks[0]!;
+ expect(b.state).toBe("failed");
+ expect(b.outcome).toBe("not_demonstrated");
+ expect(isBlockOk(b)).toBe(false);
+ });
+
+ it("a late block_progress upsert cannot wipe a recorded verdict", () => {
+ const s = reduce([
+ ...bothBlocksRan,
+ runOutcome({ verdict: "evaluating" }),
+ runOutcome({
+ verdict: "not_demonstrated",
+ reason_code: "blocker_reported",
+ display_reason: "The search stayed gated by a verification challenge.",
+ }),
+ blockProgress({
+ block_label: "search_person",
+ status: "completed",
+ timestamp: "2026-06-10T00:01:30Z",
+ }),
+ ]);
+ const late = s.blocks.find((b) => b.label === "search_person")!;
+ expect(late.state).toBe("completed");
+ expect(late.outcome).toBe("not_demonstrated");
+ expect(late.outcomeReason).toBe(
+ "The search stayed gated by a verification challenge.",
+ );
+ expect(isBlockOk(late)).toBe(false);
+ });
+
+ it("applies by run-block id only; other rows keep their own verdict", () => {
+ const s = reduce([
+ ...bothBlocksRan,
+ runOutcome({
+ verdict: "not_demonstrated",
+ workflow_run_block_ids: ["wrb_search_person"],
+ block_labels: ["search_person"],
+ }),
+ runOutcome({
+ verdict: "demonstrated",
+ workflow_run_id: "wr_2",
+ workflow_run_block_ids: ["wrb_open_search"],
+ block_labels: ["open_search"],
+ }),
+ ]);
+ const open = s.blocks.find((b) => b.label === "open_search")!;
+ const search = s.blocks.find((b) => b.label === "search_person")!;
+ expect(open.outcome).toBe("demonstrated");
+ expect(isBlockOk(open)).toBe(true);
+ expect(search.outcome).toBe("not_demonstrated");
+ expect(isBlockOk(search)).toBe(false);
+ });
+
+ it("demonstrated and not_evaluated verdicts keep the success affordance", () => {
+ for (const verdict of ["demonstrated", "not_evaluated"] as const) {
+ const s = reduce([
+ ...bothBlocksRan,
+ runOutcome({ verdict: "evaluating" }),
+ runOutcome({ verdict }),
+ response(),
+ ]);
+ for (const b of s.blocks) {
+ expect(b.outcome).toBe(verdict);
+ expect(isBlockOk(b)).toBe(true);
+ }
+ }
+ });
+
+ it("without run_outcome frames (old backend) rendering state is unchanged", () => {
+ const s = reduce([...bothBlocksRan, response()]);
+ for (const b of s.blocks) {
+ expect(b.outcome).toBeUndefined();
+ expect(b.outcomeReason).toBeUndefined();
+ expect(isBlockOk(b)).toBe(true);
+ }
+ });
+});
+
+describe("hydrateNarrativeFromPayload — outcome", () => {
+ const payloadBlock = (overrides: Record<string, unknown>) => ({
+ label: "search_person",
+ blockType: "code",
+ state: "completed",
+ lastSeenIteration: 0,
+ activity: [],
+ startedAt: "2026-06-10T00:00:04Z",
+ endedAt: "2026-06-10T00:01:00Z",
+ ...overrides,
+ });
+
+ const payload = (blocks: Record<string, unknown>[]) => ({
+ turnId: "turn-1",
+ turnIndex: 0,
+ mode: "build",
+ terminal: "response",
+ terminalMessage: "Done.",
+ startedAt: "2026-06-10T00:00:00Z",
+ endedAt: "2026-06-10T00:02:00Z",
+ blocks,
+ });
+
+ it("round-trips outcome/outcomeReason so reload renders like the live stream", () => {
+ const live = reduce([
+ turnStart(),
+ blockProgress({ block_label: "search_person", status: "running" }),
+ blockProgress({ block_label: "search_person", status: "completed" }),
+ runOutcome({
+ verdict: "not_demonstrated",
+ workflow_run_block_ids: ["wrb_search_person"],
+ block_labels: ["search_person"],
+ reason_code: "blocker_reported",
+ display_reason: "The search stayed gated by a verification challenge.",
+ }),
+ response(),
+ ]);
+ const liveRow = live.blocks[0]!;
+
+ const hydrated = hydrateNarrativeFromPayload(
+ payload([
+ payloadBlock({
+ outcome: "not_demonstrated",
+ outcomeReason: "The search stayed gated by a verification challenge.",
+ }),
+ ]),
+ )!;
+ const hydratedRow = hydrated.blocks[0]!;
+
+ expect(hydratedRow.state).toBe(liveRow.state);
+ expect(hydratedRow.outcome).toBe(liveRow.outcome);
+ expect(hydratedRow.outcomeReason).toBe(liveRow.outcomeReason);
+ expect(isBlockOk(hydratedRow)).toBe(false);
+ expect(isBlockOk(liveRow)).toBe(false);
+ });
+
+ it("hydrates rows without outcome keys exactly as before", () => {
+ const hydrated = hydrateNarrativeFromPayload(payload([payloadBlock({})]))!;
+ const row = hydrated.blocks[0]!;
+ expect(row.outcome).toBeUndefined();
+ expect(row.outcomeReason).toBeUndefined();
+ expect(isBlockOk(row)).toBe(true);
+ });
+
+ it("ignores unknown outcome values", () => {
+ const hydrated = hydrateNarrativeFromPayload(
+ payload([payloadBlock({ outcome: "maybe", outcomeReason: 7 })]),
+ )!;
+ const row = hydrated.blocks[0]!;
+ expect(row.outcome).toBeUndefined();
+ expect(row.outcomeReason).toBeUndefined();
+ expect(isBlockOk(row)).toBe(true);
+ });
+
+ it("hydrate sweep promotes a stuck-running row without inventing a verdict", () => {
+ const hydrated = hydrateNarrativeFromPayload(
+ payload([
+ payloadBlock({
+ state: "running",
+ outcome: "not_demonstrated",
+ endedAt: null,
+ }),
+ ]),
+ )!;
+ const row = hydrated.blocks[0]!;
+ expect(row.state).toBe("completed");
+ expect(row.outcome).toBe("not_demonstrated");
+ expect(isBlockOk(row)).toBe(false);
+ });
+});
diff --git a/skyvern-frontend/src/routes/workflows/copilot/narrativeState.ts b/skyvern-frontend/src/routes/workflows/copilot/narrativeState.ts
index acbe12c2c..f4a05777b 100644
--- a/skyvern-frontend/src/routes/workflows/copilot/narrativeState.ts
+++ b/skyvern-frontend/src/routes/workflows/copilot/narrativeState.ts
@@ -10,6 +10,7 @@ import {
WorkflowCopilotDesignEndUpdate,
WorkflowCopilotDesignStartUpdate,
WorkflowCopilotNarrationUpdate,
+ WorkflowCopilotRunOutcomeUpdate,
WorkflowCopilotStreamErrorUpdate,
WorkflowCopilotStreamResponseUpdate,
WorkflowCopilotToolCallUpdate,
@@ -26,6 +27,7 @@ export type NarrativeEvent =
| WorkflowCopilotDesignEndUpdate
| WorkflowCopilotWorkflowDraftUpdate
| WorkflowCopilotBlockProgressUpdate
+ | WorkflowCopilotRunOutcomeUpdate
| WorkflowCopilotStreamResponseUpdate
| WorkflowCopilotStreamErrorUpdate
| WorkflowCopilotNarrationUpdate
@@ -43,11 +45,22 @@ export type BlockUIState =
| "failed"
| "skipped";
+// Recorded per-run outcome verdict, distinct from lifecycle state: a row can
+// be `completed` (it ran) yet carry a `not_demonstrated` verdict.
+export type BlockOutcome =
+ | "evaluating"
+ | "demonstrated"
+ | "not_demonstrated"
+ | "not_evaluated";
+
export interface BlockState {
workflowRunBlockId: string;
label: string;
blockType: string;
state: BlockUIState;
+ // Undefined when no verdict was recorded (older backend or unadjudicated run).
+ outcome?: BlockOutcome;
+ outcomeReason?: string;
lastSeenIteration: number;
// Tool calls and results emitted while this block was running are
// appended here so the expanded card shows what the agent did.
@@ -271,6 +284,19 @@ export function mapBlockStatus(raw: string): BlockUIState {
}
}
+// A completed row claims the success affordance only when no recorded verdict
+// contradicts it; `evaluating` and `not_demonstrated` both withhold the check.
+export function isBlockOk(
+ block: Pick<BlockState, "state" | "outcome">,
+): boolean {
+ if (block.state !== "completed") return false;
+ return (
+ block.outcome === undefined ||
+ block.outcome === "demonstrated" ||
+ block.outcome === "not_evaluated"
+ );
+}
+
export function applyNarrativeEvent(
prev: TurnNarrativeState,
event: NarrativeEvent,
@@ -365,6 +391,10 @@ export function applyNarrativeEvent(
label: event.block_label,
blockType: event.block_type,
state: incomingState,
+ // A late or replayed block_progress must not wipe a recorded verdict;
+ // lifecycle frames never carry outcome, so always keep the prior one.
+ outcome: previousBlock?.outcome,
+ outcomeReason: previousBlock?.outcomeReason,
lastSeenIteration: event.iteration,
activity: previousBlock?.activity ?? [],
startedAt,
@@ -378,6 +408,22 @@ export function applyNarrativeEvent(
return { ...prev, blocks: [...prev.blocks, baseEntry] };
}
+ case "run_outcome": {
+ // Apply the recorded verdict by run-block id only — no label fallback, so
+ // a prior run's rows in the same turn keep their own verdict.
+ const ids = new Set(event.workflow_run_block_ids);
+ const blocks = prev.blocks.map((b) =>
+ ids.has(b.workflowRunBlockId)
+ ? {
+ ...b,
+ outcome: event.verdict,
+ outcomeReason: event.display_reason ?? undefined,
+ }
+ : b,
+ );
+ return { ...prev, blocks };
+ }
+
case "tool_call": {
const entry = buildActivityFromToolCall(event);
if (!entry) return prev;
@@ -563,6 +609,17 @@ export function hydrateNarrativeFromPayload(
const blocksRaw = Array.isArray(payload.blocks) ? payload.blocks : [];
const blocks: BlockState[] = blocksRaw.map((b) => {
const obj = b as Record<string, unknown>;
+ const outcome = ((): BlockOutcome | undefined => {
+ const o = obj.outcome;
+ if (
+ o === "evaluating" ||
+ o === "demonstrated" ||
+ o === "not_demonstrated" ||
+ o === "not_evaluated"
+ )
+ return o;
+ return undefined;
+ })();
return {
workflowRunBlockId:
typeof obj.workflowRunBlockId === "string"
@@ -570,6 +627,9 @@ export function hydrateNarrativeFromPayload(
: "",
label: typeof obj.label === "string" ? obj.label : "",
blockType: typeof obj.blockType === "string" ? obj.blockType : "task",
+ outcome,
+ outcomeReason:
+ typeof obj.outcomeReason === "string" ? obj.outcomeReason : undefined,
state: ((): BlockState["state"] => {
const s = obj.state;
if (
diff --git a/skyvern-frontend/src/routes/workflows/copilot/workflowCopilotTypes.ts b/skyvern-frontend/src/routes/workflows/copilot/workflowCopilotTypes.ts
index 7afd68ffa..e31e40ce8 100644
--- a/skyvern-frontend/src/routes/workflows/copilot/workflowCopilotTypes.ts
+++ b/skyvern-frontend/src/routes/workflows/copilot/workflowCopilotTypes.ts
@@ -87,6 +87,7 @@ export type WorkflowCopilotStreamMessageType =
| "condensing"
| "narration"
| "block_progress"
+ | "run_outcome"
| "turn_start"
| "design_start"
| "design_end"
@@ -197,6 +198,24 @@ export interface WorkflowCopilotBlockProgressUpdate {
timestamp: string;
}
+export type WorkflowCopilotRunOutcomeVerdict =
+ | "evaluating"
+ | "demonstrated"
+ | "not_demonstrated"
+ | "not_evaluated";
+
+export interface WorkflowCopilotRunOutcomeUpdate {
+ type: "run_outcome";
+ workflow_run_id: string;
+ workflow_run_block_ids: string[];
+ block_labels: string[];
+ verdict: WorkflowCopilotRunOutcomeVerdict;
+ reason_code?: string | null;
+ display_reason?: string | null;
+ iteration: number;
+ timestamp: string;
+}
+
export interface WorkflowYAMLConversionRequest {
workflow_definition_yaml: string;
workflow_id: string;