Skip to content

Automate browser based workflows with AI

Report a draft test's repair against the snapshot the run executed (SKY-15658) (#8493)

Andrew Neilson3098ea04feb9
diff --git a/skyvern-frontend/src/components/AgentMarkdown.test.tsx b/skyvern-frontend/src/components/AgentMarkdown.test.tsx
new file mode 100644
index 000000000..aaa01ba1b
--- /dev/null
+++ b/skyvern-frontend/src/components/AgentMarkdown.test.tsx
@@ -0,0 +1,209 @@
+// @vitest-environment jsdom
+
+import { cleanup, render } from "@testing-library/react";
+import { afterEach, describe, expect, it } from "vitest";
+
+import { BlockMarkdown, InlineMarkdown } from "./AgentMarkdown";
+
+afterEach(cleanup);
+
+// Callers render agent prose inside a <button> and, for the timeline row, on one truncated line. A
+// block element breaks the line box, and an anchor or form control nested in a button is invalid
+// HTML the browser may reparent. Untrusted model prose has to land inside this set either way.
+const FORBIDDEN_TAGS = [
+ "a",
+ "blockquote",
+ "div",
+ "form",
+ "h1",
+ "h2",
+ "h3",
+ "h4",
+ "h5",
+ "h6",
+ "hr",
+ "img",
+ "input",
+ "li",
+ "ol",
+ "p",
+ "pre",
+ "section",
+ "table",
+ "tbody",
+ "td",
+ "th",
+ "thead",
+ "tr",
+ "ul",
+];
+
+const HOSTILE_INPUTS: Array<[string, string]> = [
+ ["raw html anchor", '<a href="javascript:alert(1)">click</a> tail'],
+ ["raw html img with handler", '<img src=x onerror="alert(1)"> tail'],
+ ["raw script tag", "<script>alert(1)</script> tail"],
+ ["raw div", "<div>block</div> tail"],
+ ["markdown link to a javascript uri", "[click](javascript:alert(1)) tail"],
+ ["reference link", "[click][r] tail\n\n[r]: javascript:alert(1)"],
+ ["image", "![beacon](https://example.com/x.png) tail"],
+ ["bare url", "see https://example.com/a?b=1 now"],
+ ["table", "| a | b |\n| - | - |\n| 1 | 2 |"],
+ ["task list", "- [ ] one\n- [x] two"],
+ ["nested list", "- a\n - b\n - c"],
+ ["fenced code block", "before\n```js\nconst x = 1;\n```\nafter"],
+ ["thematic break", "a\n\n---\n\nb"],
+ ["heading", "# Big heading\n\nbody"],
+ ["blockquote", "> quoted\n\nafter"],
+ ["footnote", "text[^1]\n\n[^1]: note"],
+ ["multiple paragraphs", "line one\n\nline two"],
+];
+
+// The safety property is structural, not textual: escaped source legitimately contains the literal
+// characters "javascript:" or "onerror=" as inert text, so assert that nothing live survived - no
+// URL-bearing or event-handler attribute anywhere, and no unescaped script/iframe in the markup.
+function expectInert(container: HTMLElement) {
+ for (const node of Array.from(container.querySelectorAll("*"))) {
+ for (const attribute of Array.from(node.attributes)) {
+ expect(attribute.name).not.toMatch(/^on/i);
+ expect([
+ "href",
+ "src",
+ "srcset",
+ "formaction",
+ "xlink:href",
+ ]).not.toContain(attribute.name);
+ }
+ }
+ expect(container.innerHTML).not.toMatch(/<(?:script|iframe|object|embed)\b/i);
+}
+
+function tagsIn(container: HTMLElement): Array<string> {
+ return [
+ ...new Set(
+ Array.from(container.querySelectorAll("*")).map((node) =>
+ node.tagName.toLowerCase(),
+ ),
+ ),
+ ];
+}
+
+describe("InlineMarkdown", () => {
+ it("renders emphasis as bold rather than its source syntax", () => {
+ const { container } = render(
+ <InlineMarkdown text="**Navigating account details** then the table" />,
+ );
+
+ expect(container.querySelector("strong")?.textContent).toBe(
+ "Navigating account details",
+ );
+ expect(container.textContent).not.toContain("**");
+ });
+
+ // react-markdown's skipHtml *deletes* raw HTML rather than escaping it, so reasoning that names a
+ // tag would silently lose those words - and a whole paragraph, for a block-level tag.
+ it.each([
+ ["Clicking the <button> inside the <form> to submit"],
+ ["Reasoning: use x<y and y>z"],
+ ["<script>alert(1)</script> tail"],
+ ])("keeps every word of %s", (source) => {
+ const { container } = render(<InlineMarkdown text={source} />);
+
+ expect(container.textContent).toBe(source);
+ });
+
+ it.each(HOSTILE_INPUTS)("keeps %s inline and inert", (_name, source) => {
+ const { container } = render(<InlineMarkdown text={source} />);
+
+ expect(tagsIn(container).filter((t) => FORBIDDEN_TAGS.includes(t))).toEqual(
+ [],
+ );
+ expectInert(container);
+ });
+
+ // Prose that renders to nothing puts the row back to a bare icon and index - the bug this
+ // renderer exists to fix - so no construct is allowed to disappear.
+ it.each([
+ ["image only", "![the invoices table](https://example.com/x.png)"],
+ ["rule only", "---"],
+ ["image and rule", "![a chart](https://example.com/c.png)\n\n---"],
+ ["image with no alt", "![](https://example.com/x.png)"],
+ ["bare reference definition", "[r]: https://example.com"],
+ ["html comment only", "<!-- nothing to see -->"],
+ ])("renders visible content for %s", (_name, source) => {
+ const { container } = render(<InlineMarkdown text={source} />);
+
+ expect(container.textContent?.trim()).not.toBe("");
+ });
+
+ it.each([
+ ["image with no alt", "![](https://example.com/x.png)"],
+ ["bare reference definition", "[r]: https://example.com"],
+ ])(
+ "shows the caller's fallback when %s renders to nothing",
+ (_name, source) => {
+ const { container } = render(
+ <InlineMarkdown text={source} fallback={<span>Click</span>} />,
+ );
+
+ expect(container.textContent?.trim()).toBe("Click");
+ },
+ );
+
+ it("does not use the fallback when the prose does render", () => {
+ const { container } = render(
+ <InlineMarkdown
+ text="**Opened** the invoice"
+ fallback={<span>Click</span>}
+ />,
+ );
+
+ expect(container.textContent).toContain("Opened the invoice");
+ expect(container.textContent).not.toContain("Click");
+ });
+
+ it("keeps an image's alt text, which is the only readable part of it", () => {
+ const { container } = render(
+ <InlineMarkdown text="![the invoices table](https://example.com/x.png)" />,
+ );
+
+ expect(container.textContent).toContain("the invoices table");
+ });
+
+ it("keeps a link's visible text without making it clickable", () => {
+ const { container } = render(
+ <InlineMarkdown text="[the invoices page](https://example.com)" />,
+ );
+
+ expect(container.textContent).toContain("the invoices page");
+ expect(container.querySelector("a")).toBeNull();
+ });
+});
+
+describe("BlockMarkdown", () => {
+ it.each(HOSTILE_INPUTS)("keeps %s inert", (_name, source) => {
+ const { container } = render(<BlockMarkdown text={source} />);
+
+ expect(tagsIn(container).filter((t) => FORBIDDEN_TAGS.includes(t))).toEqual(
+ [],
+ );
+ expectInert(container);
+ });
+
+ it("separates a heading from the paragraph after it", () => {
+ const { container } = render(<BlockMarkdown text={"# Plan\n\nBody"} />);
+
+ const blocks = Array.from(container.querySelectorAll("span")).filter(
+ (node) => node.className.includes("block"),
+ );
+ expect(blocks.map((node) => node.textContent)).toEqual(["Plan", "Body"]);
+ });
+
+ it("separates paragraphs instead of running them together", () => {
+ const { container } = render(<BlockMarkdown text={"first\n\nsecond"} />);
+
+ const blocks = Array.from(container.querySelectorAll("span")).filter(
+ (node) => node.className.includes("block"),
+ );
+ expect(blocks.map((node) => node.textContent)).toEqual(["first", "second"]);
+ });
+});
diff --git a/skyvern-frontend/src/components/AgentMarkdown.tsx b/skyvern-frontend/src/components/AgentMarkdown.tsx
new file mode 100644
index 000000000..33bed686f
--- /dev/null
+++ b/skyvern-frontend/src/components/AgentMarkdown.tsx
@@ -0,0 +1,110 @@
+import { memo, useLayoutEffect, useRef, useState, type ReactNode } from "react";
+import ReactMarkdown, { type Components } from "react-markdown";
+
+// Agent prose (a Task V3 turn's text, a v1 action's reasoning, an observer thought) is markdown,
+// and it is untrusted: the model writes it while reading an arbitrary page. Two constraints follow.
+//
+// It has to stay phrasing content. Callers render it inside a <button> or a single truncated line,
+// where a block element breaks the line box and an anchor or form control is invalid nesting the
+// browser may reparent. So every construct collapses to inline content and links lose their href.
+//
+// No `skipHtml`: react-markdown *deletes* raw HTML rather than escaping it, so reasoning that names
+// a tag ("clicked the <button> inside the <form>") would silently lose those words. Without
+// rehype-raw the same input is escaped and rendered as the literal text the model wrote, which is
+// both lossless and inert.
+const passthrough = ({ children }: { children?: ReactNode }) => <>{children}</>;
+
+const sharedComponents: Components = {
+ ul: passthrough,
+ ol: passthrough,
+ pre: passthrough,
+ li: ({ children }) => <span>{children} </span>,
+ a: ({ children }) => <span>{children}</span>,
+ br: () => <> </>,
+ // Nothing may render to nothing: prose that is only an image or only a rule would otherwise leave
+ // the row blank again, which is the bug this renderer exists to fix.
+ hr: () => <span> — </span>,
+ img: ({ alt }) => <>{alt}</>,
+ code: ({ children }) => (
+ <code className="rounded bg-slate-500/15 px-1 font-mono text-[0.92em]">
+ {children}
+ </code>
+ ),
+};
+
+const HEADING_KEYS = ["h1", "h2", "h3", "h4", "h5", "h6"] as const;
+
+function withKeys(
+ keys: ReadonlyArray<string>,
+ component: Components[keyof Components],
+): Components {
+ return Object.fromEntries(keys.map((key) => [key, component]));
+}
+
+const inlineComponents: Components = {
+ ...sharedComponents,
+ ...withKeys([...HEADING_KEYS, "blockquote", "p"], passthrough),
+};
+
+// A span that displays as a block: paragraph separation without leaving phrasing content.
+const asBlock = ({ children }: { children?: ReactNode }) => (
+ <span className="block [&:not(:first-child)]:mt-2">{children}</span>
+);
+
+const blockComponents: Components = {
+ ...sharedComponents,
+ ...withKeys([...HEADING_KEYS, "blockquote", "p"], asBlock),
+};
+
+// Some valid markdown renders to nothing at all - an image with an empty alt, a bare link
+// reference definition - and a caller cannot tell from the source string, which is non-empty. Rather
+// than enumerate those constructs, measure the output: if it carries no text, show `fallback`
+// instead. Without this a timeline row is back to a bare icon and index, the bug this all exists to
+// fix. The default fallback is the source itself, so the reader still sees what the model wrote.
+function Rendered({
+ text,
+ components,
+ fallback,
+}: {
+ text: string;
+ components: Components;
+ fallback?: ReactNode;
+}) {
+ const rendered = useRef<HTMLSpanElement>(null);
+ const [isEmpty, setIsEmpty] = useState(false);
+
+ useLayoutEffect(() => {
+ setIsEmpty((rendered.current?.textContent ?? "").trim() === "");
+ }, [text]);
+
+ return (
+ <>
+ <span ref={rendered} className={isEmpty ? "hidden" : undefined}>
+ <ReactMarkdown components={components}>{text}</ReactMarkdown>
+ </span>
+ {isEmpty ? (fallback ?? text) : null}
+ </>
+ );
+}
+
+/** Agent prose on one line — a timeline row. All markdown collapses to inline content. */
+export const InlineMarkdown = memo(function InlineMarkdown({
+ text,
+ fallback,
+}: {
+ text: string;
+ fallback?: ReactNode;
+}) {
+ return (
+ <Rendered text={text} components={inlineComponents} fallback={fallback} />
+ );
+});
+
+/** Agent prose in a card or detail pane, where paragraphs should stay apart. */
+export const BlockMarkdown = memo(function BlockMarkdown({
+ text,
+}: {
+ text: string;
+}) {
+ return <Rendered text={text} components={blockComponents} />;
+});
diff --git a/skyvern-frontend/src/routes/tasks/detail/ScrollableActionList.tsx b/skyvern-frontend/src/routes/tasks/detail/ScrollableActionList.tsx
index 6a71240c7..979a812d5 100644
--- a/skyvern-frontend/src/routes/tasks/detail/ScrollableActionList.tsx
+++ b/skyvern-frontend/src/routes/tasks/detail/ScrollableActionList.tsx
@@ -1,5 +1,6 @@
import { getClient } from "@/api/AxiosClient";
import { Action, ActionTypes } from "@/api/types";
+import { BlockMarkdown } from "@/components/AgentMarkdown";
import { StatusPill } from "@/components/ui/status-pill";
import {
Tooltip,
@@ -119,7 +120,9 @@ function ScrollableActionList({
)}
</div>
</div>
- <div className="text-xs text-slate-400">{action.reasoning}</div>
+ <div className="text-xs text-slate-400">
+ <BlockMarkdown text={action.reasoning} />
+ </div>
{action.type === ActionTypes.InputText && (
<>
<Separator />
diff --git a/skyvern-frontend/src/routes/workflows/studio/runProjections.test.ts b/skyvern-frontend/src/routes/workflows/studio/runProjections.test.ts
index 296517efc..003b27036 100644
--- a/skyvern-frontend/src/routes/workflows/studio/runProjections.test.ts
+++ b/skyvern-frontend/src/routes/workflows/studio/runProjections.test.ts
@@ -13,6 +13,7 @@ import {
} from "@/routes/workflows/types/workflowRunTypes";
import capturedRun from "./__fixtures__/completed-code-block-run.json";
import {
+ actionLabel,
buildActionIndex,
buildBlockStatusMap,
buildFilmstrip,
@@ -687,3 +688,39 @@ describe("formatRunTimesTooltip", () => {
expect(title).not.toContain("Finished");
});
});
+
+describe("actionLabel", () => {
+ // Task V3 stamps every action's description with its tool call, so a description-first fallback
+ // labelled every v3 frame with machine syntax instead of what the agent said it was doing.
+ test("prefers the action's own prose over a Task V3 tool-call stamp", () => {
+ expect(
+ actionLabel(
+ action({
+ description: "task_v3 click #sign-in",
+ reasoning: "Submitting the sign-in form",
+ }),
+ ),
+ ).toBe("Submitting the sign-in form");
+ });
+
+ test("falls back to the readable type when a v3 action carries no prose", () => {
+ expect(
+ actionLabel(
+ action({
+ action_type: "click",
+ description: "task_v3 click #sign-in",
+ reasoning: null,
+ intention: null,
+ }),
+ ),
+ ).toBe("Click");
+ });
+
+ test("still uses a non-v3 description", () => {
+ expect(
+ actionLabel(
+ action({ description: "Open the billing page", reasoning: null }),
+ ),
+ ).toBe("Open the billing page");
+ });
+});
diff --git a/skyvern-frontend/src/routes/workflows/studio/runProjections.ts b/skyvern-frontend/src/routes/workflows/studio/runProjections.ts
index 46d734815..5cec2f19c 100644
--- a/skyvern-frontend/src/routes/workflows/studio/runProjections.ts
+++ b/skyvern-frontend/src/routes/workflows/studio/runProjections.ts
@@ -11,6 +11,7 @@ import {
WorkflowRunBlock,
WorkflowRunTimelineItem,
} from "@/routes/workflows/types/workflowRunTypes";
+import { taskV3CallText } from "@/routes/workflows/workflowBlockUtils";
import { flattenTimelineChronologically } from "@/routes/workflows/workflowRun/workflowTimelineUtils";
import { isRecord } from "@/util/utils";
import { basicLocalTimeFormat, normalizeUtcTimestamp } from "@/util/timeFormat";
@@ -237,10 +238,14 @@ export type FilmstripFrame = {
};
export function actionLabel(action: ActionsApiResponse): string {
+ // A Task V3 description is a machine tool-call stamp ("task_v3 click #sign-in"), not a label, so
+ // the action's own prose outranks it and the readable type is the floor.
+ const description =
+ taskV3CallText(action.description) === null
+ ? action.description?.trim()
+ : undefined;
const candidate =
- action.intention?.trim() ||
- action.description?.trim() ||
- action.reasoning?.trim();
+ action.intention?.trim() || description || action.reasoning?.trim();
if (candidate) {
// Goto actions surface as "page.goto <url>"; show just the URL.
return candidate.replace(/^page\.goto\s+/i, "");
diff --git a/skyvern-frontend/src/routes/workflows/workflowBlockUtils.test.ts b/skyvern-frontend/src/routes/workflows/workflowBlockUtils.test.ts
index 327d9c803..aa71a56c7 100644
--- a/skyvern-frontend/src/routes/workflows/workflowBlockUtils.test.ts
+++ b/skyvern-frontend/src/routes/workflows/workflowBlockUtils.test.ts
@@ -5,6 +5,7 @@ import {
describeRecordedAction,
findCodeStepForLine,
getCodeStepPlainText,
+ taskV3CallText,
visitWorkflowBlocks,
} from "./workflowBlockUtils";
import type { ActionsApiResponse } from "@/api/types";
@@ -332,3 +333,25 @@ describe("describeRecordedAction", () => {
).toBe("Download invoice.pdf");
});
});
+
+describe("taskV3CallText", () => {
+ it("returns the tool call a Task V3 action row was stamped with", () => {
+ expect(taskV3CallText("task_v3 click #sign-in")).toBe("click #sign-in");
+ });
+
+ it("keeps a selector that contains spaces whole", () => {
+ expect(taskV3CallText('task_v3 click [data-tv3="7"] button')).toBe(
+ 'click [data-tv3="7"] button',
+ );
+ });
+
+ it("returns the bare tool name when the call carried no argument", () => {
+ expect(taskV3CallText("task_v3 scroll")).toBe("scroll");
+ });
+
+ it("ignores descriptions that are not Task V3 tool calls", () => {
+ expect(taskV3CallText("locator.click #sign-in")).toBeNull();
+ expect(taskV3CallText("Click the sign-in button")).toBeNull();
+ expect(taskV3CallText(null)).toBeNull();
+ });
+});
diff --git a/skyvern-frontend/src/routes/workflows/workflowBlockUtils.ts b/skyvern-frontend/src/routes/workflows/workflowBlockUtils.ts
index b9a049728..457ec5c66 100644
--- a/skyvern-frontend/src/routes/workflows/workflowBlockUtils.ts
+++ b/skyvern-frontend/src/routes/workflows/workflowBlockUtils.ts
@@ -168,6 +168,22 @@ export function isRecorderCallText(
return text !== null && RECORDER_CALL_TEXT.test(text);
}
+// Task V3 stamps every persisted action's `description` as "task_v3 <tool> <argument>", where the
+// argument is usually a model-authored CSS selector (skyvern/webeye/actions/actions.py
+// TASK_V3_ACTION_DESCRIPTION_PREFIX). Like the recorder trace above it is machine syntax, so it
+// belongs on hover and in the inspector, never on a row's main line.
+const TASK_V3_CALL_PREFIX = "task_v3 ";
+
+export function taskV3CallText(
+ description: string | null | undefined,
+): string | null {
+ const text = normalizeInlineText(description);
+ if (text === null || !text.startsWith(TASK_V3_CALL_PREFIX)) {
+ return null;
+ }
+ return normalizeInlineText(text.slice(TASK_V3_CALL_PREFIX.length));
+}
+
/**
* Reader-facing text for one recorded action, in descending order of specificity: the definition
* step it fired from, whatever prose the action carries, the author's own prompt, then the one
diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/ThoughtCard.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/ThoughtCard.tsx
index de78eead8..71e0f703a 100644
--- a/skyvern-frontend/src/routes/workflows/workflowRun/ThoughtCard.tsx
+++ b/skyvern-frontend/src/routes/workflows/workflowRun/ThoughtCard.tsx
@@ -1,5 +1,6 @@
import { QuestionMarkIcon } from "@radix-ui/react-icons";
import { BrainIcon } from "@/components/icons/BrainIcon";
+import { BlockMarkdown } from "@/components/AgentMarkdown";
import { cn } from "@/util/utils";
import { ObserverThought } from "../types/workflowRunTypes";
@@ -40,8 +41,8 @@ function ThoughtCard({ thought, onClick, active, cardClassName }: Props) {
</span>
</div>
{body && (
- <div className="whitespace-pre-wrap break-words text-xs text-foreground dark:text-slate-200">
- {body}
+ <div className="break-words text-xs text-foreground dark:text-slate-200">
+ <BlockMarkdown text={body} />
</div>
)}
</button>
diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.test.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.test.tsx
index 652ed1fa4..1165f92d4 100644
--- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.test.tsx
+++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.test.tsx
@@ -1402,4 +1402,142 @@ describe("WorkflowRunTimelineBlockItem", () => {
expect(screen.getByText("Extract Data")).toBeDefined();
expect(screen.queryByText(/A step on another line/)).toBeNull();
});
+
+ it("renders markdown in an action's reasoning instead of its source syntax", () => {
+ const block = buildBlock({
+ workflow_run_block_id: "wrb_markdown_reasoning",
+ block_type: "task",
+ label: "extract_invoices",
+ actions: [
+ {
+ action_id: "act_markdown",
+ action_type: ActionTypes.Click,
+ status: Status.Completed,
+ reasoning: "**Navigating account details** then reading the table",
+ created_by: null,
+ confidence_float: null,
+ },
+ ] as unknown as WorkflowRunBlock["actions"],
+ });
+
+ const { container } = render(
+ <WorkflowRunTimelineBlockItem
+ activeItem={null}
+ block={block}
+ subItems={[]}
+ onActionClick={noop}
+ onBlockItemClick={noop}
+ />,
+ );
+
+ expect(screen.getByText("Navigating account details").tagName).toBe(
+ "STRONG",
+ );
+ expect(container.textContent).not.toContain("**");
+ });
+
+ it("renders a typed value verbatim, since only the model's prose is markdown", () => {
+ const block = buildBlock({
+ workflow_run_block_id: "wrb_literal_value",
+ block_type: "login",
+ label: "login",
+ actions: [
+ {
+ action_id: "act_typed",
+ action_type: ActionTypes.InputText,
+ status: Status.Completed,
+ reasoning: null,
+ text: "a*b*c_d_e",
+ created_by: null,
+ confidence_float: null,
+ },
+ ] as unknown as WorkflowRunBlock["actions"],
+ });
+
+ render(
+ <WorkflowRunTimelineBlockItem
+ activeItem={null}
+ block={block}
+ subItems={[]}
+ onActionClick={noop}
+ onBlockItemClick={noop}
+ />,
+ );
+
+ expect(screen.getByText(/a\*b\*c_d_e/)).toBeDefined();
+ });
+
+ it("falls back to the action's intention when it carries no other prose", () => {
+ const block = buildBlock({
+ workflow_run_block_id: "wrb_intention",
+ block_type: "task",
+ label: "answer",
+ actions: [
+ {
+ action_id: "act_intention",
+ action_type: ActionTypes.Click,
+ status: Status.Completed,
+ reasoning: null,
+ text: null,
+ response: null,
+ intention: "Answer **which** plan is active",
+ created_by: null,
+ confidence_float: null,
+ },
+ ] as unknown as WorkflowRunBlock["actions"],
+ });
+
+ render(
+ <WorkflowRunTimelineBlockItem
+ activeItem={null}
+ block={block}
+ subItems={[]}
+ onActionClick={noop}
+ onBlockItemClick={noop}
+ />,
+ );
+
+ expect(screen.getByText("which").tagName).toBe("STRONG");
+ expect(screen.getByText(/plan is active/)).toBeDefined();
+ });
+
+ // A Task V3 turn that emits only tool calls persists every action of that round with no prose at
+ // all, which used to leave the row as a bare icon and index.
+ it("falls back to a visible action type when an action carries no prose", () => {
+ const block = buildBlock({
+ workflow_run_block_id: "wrb_no_prose",
+ block_type: "login",
+ label: "login",
+ actions: [
+ {
+ action_id: "act_no_prose",
+ action_type: ActionTypes.Click,
+ status: Status.Completed,
+ reasoning: null,
+ text: null,
+ response: null,
+ intention: null,
+ description: "task_v3 click #sign-in",
+ created_by: null,
+ confidence_float: null,
+ },
+ ] as unknown as WorkflowRunBlock["actions"],
+ });
+
+ render(
+ <WorkflowRunTimelineBlockItem
+ activeItem={null}
+ block={block}
+ subItems={[]}
+ onActionClick={noop}
+ onBlockItemClick={noop}
+ />,
+ );
+
+ const summary = screen.getByText(`${TIMELINE_DESCRIPTOR_SEPARATOR} Click`);
+ expect(summary.className).not.toContain("sr-only");
+ expect(
+ screen.getByRole("button", { name: /Click/ }).getAttribute("title"),
+ ).toBe("click #sign-in");
+ });
});
diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.tsx
index c6ac88e2e..64b77ecc2 100644
--- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.tsx
+++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.tsx
@@ -15,6 +15,7 @@ import {
Status,
} from "@/api/types";
import { Collapsible, CollapsibleContent } from "@/components/ui/collapsible";
+import { InlineMarkdown } from "@/components/AgentMarkdown";
import { formatDuration, toDuration } from "@/routes/workflows/utils";
import { cn } from "@/util/utils";
import { workflowBlockTitle } from "../editor/nodes/types";
@@ -38,6 +39,7 @@ import {
findCodeStepForLine,
isRecorderCallText,
normalizeInlineText,
+ taskV3CallText,
} from "../workflowBlockUtils";
import {
ActionItem,
@@ -191,12 +193,27 @@ function StatusDot({
);
}
-function getActionSummary(action: ActionsApiResponse): string | null {
- return (
- normalizeInlineText(action.reasoning) ??
- normalizeInlineText(action.text) ??
- normalizeInlineText(action.response)
- );
+type ActionSummary = {
+ text: string;
+ // Only the model's own prose is markdown. A typed value or a recorder trace is literal text and
+ // must render verbatim — a password containing "*" is not emphasis.
+ isProse: boolean;
+};
+
+function getActionSummary(action: ActionsApiResponse): ActionSummary | null {
+ const candidates: Array<[string | null | undefined, boolean]> = [
+ [action.reasoning, true],
+ [action.text, false],
+ [action.response, false],
+ [action.intention, true],
+ ];
+ for (const [value, isProse] of candidates) {
+ const text = normalizeInlineText(value);
+ if (text !== null) {
+ return { text, isProse };
+ }
+ }
+ return null;
}
function getRecordedActionMeta(action: ActionsApiResponse): {
@@ -226,8 +243,8 @@ function formatActionDurationMs(durationMs: number): string {
type ActionRowPresentation = {
icon: ReactNode;
label: string;
- summary: string | null;
- // Raw recorder text (a Playwright selector); shown on hover, never as the primary line.
+ summary: ActionSummary | null;
+ // Machine syntax (a Playwright call or a Task V3 tool call); shown on hover, never as the primary line.
detail: string | null;
tone: "default" | "error";
};
@@ -260,7 +277,7 @@ function getCodeActionRowPresentation(
// This row hides its label from sighted users, so it falls back to the readable type
// where the chat, which always shows the label, prints nothing.
isCodeError
- ? getActionSummary(action)
+ ? (getActionSummary(action)?.text ?? null)
: (describeRecordedAction(action, matchedStep) ??
getReadableActionType(action.action_type, { nullActionLabel: "Step" })),
codeLine !== null ? `line ${codeLine}` : null,
@@ -269,7 +286,10 @@ function getCodeActionRowPresentation(
return {
icon,
label,
- summary: parts.length > 0 ? parts.join(" · ") : null,
+ // Literal even when the leading part came from prose: the row's text is that part joined with
+ // machine suffixes (line N, duration), and half-markdown-half-not would render as neither.
+ summary:
+ parts.length > 0 ? { text: parts.join(" · "), isProse: false } : null,
detail:
!isCodeError && isRecorderCallText(action.description)
? normalizeInlineText(action.description)
@@ -567,7 +587,7 @@ function TimelineActionRows({
icon: timelineActionIcons[action.action_type],
label: getReadableActionType(action.action_type),
summary: getActionSummary(action),
- detail: null,
+ detail: taskV3CallText(action.description),
tone: "default" as const,
};
@@ -616,10 +636,33 @@ function TimelineActionRows({
) : (
<span className="sr-only">{label}</span>
)}
- {summary && (
+ {summary !== null ? (
<span className="min-w-0 flex-1 truncate text-muted-foreground dark:text-slate-500">
- · {summary}
+ ·{" "}
+ {summary.isProse ? (
+ <InlineMarkdown
+ text={summary.text}
+ // Prose that renders to nothing must not blank the row; the sr-only
+ // label above already names it, so this copy is decorative.
+ fallback={<span aria-hidden="true">{label}</span>}
+ />
+ ) : (
+ summary.text
+ )}
</span>
+ ) : (
+ // A Task V3 turn that emitted only tool calls leaves every action of that round
+ // with no prose, which used to render as a bare icon and index. Show the type
+ // label sighted readers were missing; it duplicates the sr-only label above, so
+ // assistive tech must not read it twice. Error rows already show theirs.
+ tone !== "error" && (
+ <span
+ aria-hidden="true"
+ className="min-w-0 flex-1 truncate text-muted-foreground dark:text-slate-500"
+ >
+ · {label}
+ </span>
+ )
)}
</button>
</div>
diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/blockDetail/BlockInspector.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/blockDetail/BlockInspector.tsx
index e5f3418b8..eaa1f7692 100644
--- a/skyvern-frontend/src/routes/workflows/workflowRun/blockDetail/BlockInspector.tsx
+++ b/skyvern-frontend/src/routes/workflows/workflowRun/blockDetail/BlockInspector.tsx
@@ -12,7 +12,11 @@ import {
getReadableActionType,
type ActionsApiResponse,
} from "@/api/types";
-import { isRecorderCallText } from "@/routes/workflows/workflowBlockUtils";
+import {
+ isRecorderCallText,
+ taskV3CallText,
+} from "@/routes/workflows/workflowBlockUtils";
+import { BlockMarkdown } from "@/components/AgentMarkdown";
import { CopyButton } from "@/components/CopyButton";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
@@ -30,7 +34,9 @@ type InspectorField = {
label: string;
value: unknown;
// "mono": an identifier or enum token, set like every other id in the pane.
- kind?: "json" | "text" | "mono";
+ // "prose": agent-authored text, which is markdown (a Task V3 turn's reasoning is emitted with
+ // **bold** headings) and reads as escaped punctuation unless it is rendered as markdown.
+ kind?: "json" | "text" | "mono" | "prose";
};
type JsonExplorerProps = {
@@ -126,6 +132,13 @@ function FieldValue({ field }: { field: InspectorField }) {
</code>
);
}
+ if (field.kind === "prose") {
+ return (
+ <div className="break-words text-sm text-foreground">
+ <BlockMarkdown text={String(field.value)} />
+ </div>
+ );
+ }
return (
<div className="whitespace-pre-wrap break-words text-sm text-foreground">
{String(field.value)}
@@ -451,13 +464,13 @@ function getActionSummaryFields(
? `${Math.round(action.confidence_float * 100)}%`
: null,
);
- pushField(fields, "Reasoning", action.reasoning);
- pushField(fields, "Intention", action.intention);
- // The row demotes this to a hover title, which keyboard and screen-reader users never get;
- // this panel is the reachable home for it.
+ pushField(fields, "Reasoning", action.reasoning, "prose");
+ pushField(fields, "Intention", action.intention, "prose");
+ // A hover title is unreachable by keyboard and easy to miss; this panel is its stable home.
if (isRecorderCallText(action.description)) {
pushField(fields, "Recorded call", action.description);
}
+ pushField(fields, "Tool call", taskV3CallText(action.description), "mono");
return fields;
}
diff --git a/skyvern/forge/sdk/copilot/build_test_outcome.py b/skyvern/forge/sdk/copilot/build_test_outcome.py
index 4ab712019..46c4bcb45 100644
--- a/skyvern/forge/sdk/copilot/build_test_outcome.py
+++ b/skyvern/forge/sdk/copilot/build_test_outcome.py
@@ -1124,8 +1124,8 @@ def unresolved_runtime_block_failure_with_disposition(
)
if executed_snapshot_disposition is not None:
return None, executed_snapshot_disposition
- # Clearance reads the workflow the user can actually run, or -- when nothing is saved yet --
- # the snapshot a run proved above. A draft neither of those covers clears nothing.
+ # Absence answers a different question per caller: the run-level carrier reads the snapshot
+ # the run executed, the terminal reads what is saved. reported_workflow_is_persisted says which.
delivered_yaml = reported_workflow_yaml
code = _code_blocks_by_label(delivered_yaml).get(label) if delivered_yaml else None
if not (label and run_id and later_runs and code):
diff --git a/skyvern/forge/sdk/copilot/tools/run_execution.py b/skyvern/forge/sdk/copilot/tools/run_execution.py
index 46f6dc5a7..f7cedbdbe 100644
--- a/skyvern/forge/sdk/copilot/tools/run_execution.py
+++ b/skyvern/forge/sdk/copilot/tools/run_execution.py
@@ -5141,11 +5141,16 @@ def _carry_unresolved_failure_into_result(copilot_ctx: Any, result: dict[str, An
_carry_prior_attempt_change_identity_into_result(copilot_ctx, data, tool_name)
return
this_run_id = data.get("workflow_run_id") if isinstance(data, dict) else None
+ # Clearance compares block signatures, so it needs the authored bytes the signature was taken
+ # from: only the snapshot's own yaml, never _RunExecution's re-serialized fallback, whose
+ # model dump drops authoring-only fields and reads as a changed signature.
+ execution = result.execution if isinstance(result, _ExecutionResult) else None
+ executed_workflow_yaml = execution.snapshot.workflow_yaml if execution is not None else None
unresolved, disposition = unresolved_runtime_block_failure_with_disposition(
copilot_ctx,
- reported_workflow_yaml=copilot_ctx.persisted_workflow_yaml,
+ reported_workflow_yaml=executed_workflow_yaml or copilot_ctx.persisted_workflow_yaml,
pending_later_run_id=this_run_id if isinstance(this_run_id, str) else None,
- reported_workflow_is_persisted=True,
+ reported_workflow_is_persisted=executed_workflow_yaml is None,
)
# This seam is load-bearing for repair: a failure it fails to carry is one the model decides
# without. One bounded event per successful hand-back, so a miss is attributable rather than
diff --git a/skyvern/webeye/actions/actions.py b/skyvern/webeye/actions/actions.py
index e7c37d87a..40d89b74a 100644
--- a/skyvern/webeye/actions/actions.py
+++ b/skyvern/webeye/actions/actions.py
@@ -130,7 +130,9 @@ class ClickContext(BaseModel):
# Stamp on Task V3-persisted action rows. Their `reasoning` is the whole TURN's text, shared by
# every action of the round — readers that assume per-action reasoning (cached-script prompt
-# inference) must key off this stamp and skip it.
+# inference) must key off this stamp and skip it. The literal prefix is also parsed by the frontend
+# (skyvern-frontend/src/routes/workflows/workflowBlockUtils.ts `taskV3CallText`), which cannot import
+# it across the OSS boundary, so changing the string is a cross-repo change.
TASK_V3_ACTION_DESCRIPTION_PREFIX = "task_v3 "
diff --git a/tests/unit/fixtures/copilot/unresolved_failure_clearance/captured_repair_then_completed_run.json b/tests/unit/fixtures/copilot/unresolved_failure_clearance/captured_repair_then_completed_run.json
index bc42b51a1..1cc8f98d4 100644
--- a/tests/unit/fixtures/copilot/unresolved_failure_clearance/captured_repair_then_completed_run.json
+++ b/tests/unit/fixtures/copilot/unresolved_failure_clearance/captured_repair_then_completed_run.json
@@ -4,6 +4,7 @@
"source": "sky-15308-base-20260831-194437/run2-repeat-failure-then-clean/call-0026.json + backend.log.capture-slice",
"notes": "Verbatim from the capture: two runtime block failures on one code block, then a run that completed and registered its output over changed code. The two failure signatures replay byte-equal to the ones the backend logged, which is what binds these YAMLs to that session."
},
+ "baseline_rev": "c94737ead5^",
"steps": [
{
"workflow_yaml": "title: Retrieve deferred freight quote total\nworkflow_definition:\n parameters: []\n blocks:\n - block_type: code\n label: calculate_and_extract_quote_total\n prompt: Open quote QF-4821, calculate its shipping-inclusive order total, and return the page-displayed total as a number.\n code: |\n await page.goto(\"http://localhost:8900/deferred_total_quote/\")\n quote_heading = page.get_by_text(\"Quote QF-4821\", exact=True)\n await quote_heading.wait_for(state=\"visible\", timeout=10000)\n total_panel = page.locator(\"div.totals\")\n await total_panel.wait_for(state=\"visible\", timeout=10000)\n await page.locator(\"#calculate-total\").click()\n await total_panel.locator(\"strong\").wait_for(state=\"visible\", timeout=10000)\n total_text = (await total_panel.locator(\"strong\").inner_text()).strip()\n normalized_total = total_text.replace(\"$\", \"\").replace(\",\", \"\").strip()\n order_total = float(normalized_total)\n return {\n \"quote_id\": \"QF-4821\",\n \"order_total\": order_total,\n \"displayed_total\": total_text,\n \"evidence_text\": (await total_panel.inner_text()).strip()\n }\n",
diff --git a/tests/unit/fixtures/copilot/unresolved_failure_clearance/progress_observed_call_removed.json b/tests/unit/fixtures/copilot/unresolved_failure_clearance/progress_observed_call_removed.json
index dd5df5d83..d740ff6b3 100644
--- a/tests/unit/fixtures/copilot/unresolved_failure_clearance/progress_observed_call_removed.json
+++ b/tests/unit/fixtures/copilot/unresolved_failure_clearance/progress_observed_call_removed.json
@@ -4,6 +4,7 @@
"source": "sky-15308-base-20260831-194437/run2-repeat-failure-then-clean/call-0026.json + backend.log.capture-slice",
"notes": "Captured first failure, which named a locator, followed by a verified success over a snapshot that no longer contains it."
},
+ "baseline_rev": "c94737ead5^",
"steps": [
{
"workflow_yaml": "title: Retrieve deferred freight quote total\nworkflow_definition:\n parameters: []\n blocks:\n - block_type: code\n label: calculate_and_extract_quote_total\n prompt: Open quote QF-4821, calculate its shipping-inclusive order total, and return the page-displayed total as a number.\n code: |\n await page.goto(\"http://localhost:8900/deferred_total_quote/\")\n quote_heading = page.get_by_text(\"Quote QF-4821\", exact=True)\n await quote_heading.wait_for(state=\"visible\", timeout=10000)\n total_panel = page.locator(\"div.totals\")\n await total_panel.wait_for(state=\"visible\", timeout=10000)\n await page.locator(\"#calculate-total\").click()\n await total_panel.locator(\"strong\").wait_for(state=\"visible\", timeout=10000)\n total_text = (await total_panel.locator(\"strong\").inner_text()).strip()\n normalized_total = total_text.replace(\"$\", \"\").replace(\",\", \"\").strip()\n order_total = float(normalized_total)\n return {\n \"quote_id\": \"QF-4821\",\n \"order_total\": order_total,\n \"displayed_total\": total_text,\n \"evidence_text\": (await total_panel.inner_text()).strip()\n }\n",
diff --git a/tests/unit/fixtures/copilot/unresolved_failure_clearance/progress_observed_signature_changed.json b/tests/unit/fixtures/copilot/unresolved_failure_clearance/progress_observed_signature_changed.json
index d81302719..d47eea62f 100644
--- a/tests/unit/fixtures/copilot/unresolved_failure_clearance/progress_observed_signature_changed.json
+++ b/tests/unit/fixtures/copilot/unresolved_failure_clearance/progress_observed_signature_changed.json
@@ -4,6 +4,7 @@
"source": "sky-15308-base-20260831-194437/run2-repeat-failure-then-clean/call-0026.json + backend.log.capture-slice",
"notes": "Captured trio with the final run recorded as a verified success; only its verdict differs from the capture."
},
+ "baseline_rev": "c94737ead5^",
"steps": [
{
"workflow_yaml": "title: Retrieve deferred freight quote total\nworkflow_definition:\n parameters: []\n blocks:\n - block_type: code\n label: calculate_and_extract_quote_total\n prompt: Open quote QF-4821, calculate its shipping-inclusive order total, and return the page-displayed total as a number.\n code: |\n await page.goto(\"http://localhost:8900/deferred_total_quote/\")\n quote_heading = page.get_by_text(\"Quote QF-4821\", exact=True)\n await quote_heading.wait_for(state=\"visible\", timeout=10000)\n total_panel = page.locator(\"div.totals\")\n await total_panel.wait_for(state=\"visible\", timeout=10000)\n await page.locator(\"#calculate-total\").click()\n await total_panel.locator(\"strong\").wait_for(state=\"visible\", timeout=10000)\n total_text = (await total_panel.locator(\"strong\").inner_text()).strip()\n normalized_total = total_text.replace(\"$\", \"\").replace(\",\", \"\").strip()\n order_total = float(normalized_total)\n return {\n \"quote_id\": \"QF-4821\",\n \"order_total\": order_total,\n \"displayed_total\": total_text,\n \"evidence_text\": (await total_panel.inner_text()).strip()\n }\n",
diff --git a/tests/unit/fixtures/copilot/unresolved_failure_clearance/staged_repair_over_persisted_source.json b/tests/unit/fixtures/copilot/unresolved_failure_clearance/staged_repair_over_persisted_source.json
new file mode 100644
index 000000000..d047c4fe8
--- /dev/null
+++ b/tests/unit/fixtures/copilot/unresolved_failure_clearance/staged_repair_over_persisted_source.json
@@ -0,0 +1,59 @@
+{
+ "provenance": {
+ "kind": "branch_local_witness",
+ "source": "derived from captured_repair_then_completed_run.json",
+ "notes": "A workflow is saved and still carries the failing block while the proposal that just ran carries the repair. This packet pins the run-level half only: the carrier clears against the executed proposal. Its terminal leg declines as no_later_run because the packet records no run after the failure, so it does not exercise the saved-workflow terminal; that half is pinned by test_the_terminal_judges_the_saved_workflow_while_the_run_reports_the_snapshot_that_ran. Ordering taken from the SKY-15658 production fingerprint on successful hand-backs wr_570538698832229610, wr_570540378164441128, wr_570559591083343744, wr_570559917500856932 and wr_570560299752946268: the run being reported has not reached the history yet. Bodies are the captured ones; those run ids are fingerprint provenance, not reruns."
+ },
+ "steps": [
+ {
+ "workflow_yaml": "title: Retrieve deferred freight quote total\nworkflow_definition:\n parameters: []\n blocks:\n - block_type: code\n label: calculate_and_extract_quote_total\n prompt: Open quote QF-4821, calculate its shipping-inclusive order total, and return the page-displayed total as a number.\n code: |\n await page.goto(\"http://localhost:8900/deferred_total_quote/\")\n quote_heading = page.get_by_text(\"Quote QF-4821\", exact=True)\n await quote_heading.wait_for(state=\"visible\", timeout=10000)\n total_panel = page.locator(\"div.totals\")\n await total_panel.wait_for(state=\"visible\", timeout=10000)\n await page.locator(\"#calculate-total\").click()\n await total_panel.locator(\"strong\").wait_for(state=\"visible\", timeout=10000)\n total_text = (await total_panel.locator(\"strong\").inner_text()).strip()\n normalized_total = total_text.replace(\"$\", \"\").replace(\",\", \"\").strip()\n order_total = float(normalized_total)\n return {\n \"quote_id\": \"QF-4821\",\n \"order_total\": order_total,\n \"displayed_total\": total_text,\n \"evidence_text\": (await total_panel.inner_text()).strip()\n }\n",
+ "staged_workflow_yaml": "title: Retrieve deferred freight quote total\nworkflow_definition:\n parameters: []\n blocks:\n - block_type: code\n label: calculate_and_extract_quote_total\n prompt: Open quote QF-4821, calculate its shipping-inclusive order total, and return the page-displayed total as a number.\n code: |\n await page.goto(\"http://localhost:8900/deferred_total_quote/\")\n quote_heading = page.get_by_text(\"Quote QF-4821\", exact=True)\n await quote_heading.wait_for(state=\"visible\", timeout=10000)\n total_panel = page.locator(\"div.totals\")\n await total_panel.wait_for(state=\"visible\", timeout=10000)\n await page.locator(\"#calculate-total\").click()\n await total_panel.locator(\"strong\").wait_for(state=\"visible\", timeout=10000)\n total_text = (await total_panel.locator(\"strong\").inner_text()).strip()\n normalized_total = total_text.replace(\"$\", \"\").replace(\",\", \"\").strip()\n order_total = float(normalized_total)\n return {\n \"quote_id\": \"QF-4821\",\n \"order_total\": order_total,\n \"displayed_total\": total_text,\n \"evidence_text\": (await total_panel.inner_text()).strip()\n }\n",
+ "outcome": {
+ "phase": "persisted_block_run",
+ "attempted_tool": "update_and_run_blocks",
+ "attempted_block_label": "calculate_and_extract_quote_total",
+ "attempted_call_ref": "locator:div.totals",
+ "verdict": "repairable_failure",
+ "reason_code": "runtime_block_failure",
+ "workflow_run_id": "wr_569288173990568574",
+ "block_labels": [
+ "calculate_and_extract_quote_total"
+ ],
+ "executed_block_labels": [
+ "calculate_and_extract_quote_total"
+ ],
+ "structural_failure_identity": "code-block-exception:wr_569288173990568574"
+ }
+ },
+ {
+ "workflow_yaml": "title: Retrieve deferred freight quote total\nworkflow_definition:\n parameters: []\n blocks:\n - block_type: code\n label: calculate_and_extract_quote_total\n prompt: Open quote QF-4821, calculate its shipping-inclusive order total, and return the page-displayed total as a number.\n code: |\n await page.goto(\"http://localhost:8900/deferred_total_quote/\")\n quote_heading = page.get_by_text(\"Quote QF-4821\", exact=True)\n await quote_heading.wait_for(state=\"visible\", timeout=10000)\n total_panel = page.locator(\"div.totals\")\n await total_panel.wait_for(state=\"visible\", timeout=10000)\n await page.locator(\"#calculate-total\").click()\n page_total = page.locator(\"#order-total\")\n await page_total.wait_for(state=\"visible\", timeout=10000)\n total_text = (await page_total.inner_text()).strip()\n normalized_total = total_text.replace(\"$\", \"\").replace(\",\", \"\").strip()\n order_total = float(normalized_total)\n return {\n \"quote_id\": \"QF-4821\",\n \"order_total\": order_total,\n \"displayed_total\": total_text,\n \"evidence_text\": (await total_panel.inner_text()).strip()\n }\n",
+ "staged_workflow_yaml": "title: Retrieve deferred freight quote total\nworkflow_definition:\n parameters: []\n blocks:\n - block_type: code\n label: calculate_and_extract_quote_total\n prompt: Open quote QF-4821, calculate its shipping-inclusive order total, and return the page-displayed total as a number.\n code: |\n await page.goto(\"http://localhost:8900/deferred_total_quote/\")\n quote_heading = page.get_by_text(\"Quote QF-4821\", exact=True)\n await quote_heading.wait_for(state=\"visible\", timeout=10000)\n total_panel = page.locator(\"div.totals\")\n await total_panel.wait_for(state=\"visible\", timeout=10000)\n await page.locator(\"#calculate-total\").click()\n page_total = page.locator(\"#order-total\")\n await page_total.wait_for(state=\"visible\", timeout=10000)\n total_text = (await page_total.inner_text()).strip()\n normalized_total = total_text.replace(\"$\", \"\").replace(\",\", \"\").strip()\n order_total = float(normalized_total)\n return {\n \"quote_id\": \"QF-4821\",\n \"order_total\": order_total,\n \"displayed_total\": total_text,\n \"evidence_text\": (await total_panel.inner_text()).strip()\n }\n",
+ "outcome": {
+ "phase": "persisted_block_run",
+ "attempted_tool": "update_and_run_blocks",
+ "attempted_block_label": "calculate_and_extract_quote_total",
+ "attempted_call_ref": "",
+ "verdict": "repairable_failure",
+ "reason_code": "runtime_block_failure",
+ "workflow_run_id": "wr_569288324314423984",
+ "block_labels": [
+ "calculate_and_extract_quote_total"
+ ],
+ "executed_block_labels": [
+ "calculate_and_extract_quote_total"
+ ],
+ "structural_failure_identity": "code-block-exception:wr_569288324314423984"
+ }
+ }
+ ],
+ "reported_workflow_yaml": "title: Retrieve deferred freight quote total\nworkflow_definition:\n parameters: []\n blocks:\n - block_type: code\n label: calculate_and_extract_quote_total\n prompt: Open quote QF-4821, calculate its shipping-inclusive order total, and return the page-displayed total as a number.\n code: |\n await page.goto(\"http://localhost:8900/deferred_total_quote/\")\n quote_heading = page.get_by_text(\"Quote QF-4821\", exact=True)\n await quote_heading.wait_for(state=\"visible\", timeout=10000)\n total_panel = page.locator(\"div.totals\")\n await total_panel.wait_for(state=\"visible\", timeout=10000)\n await page.locator(\"#calculate-total\").click()\n page_total = page.locator(\"#order-total\")\n await page_total.wait_for(state=\"visible\", timeout=10000)\n total_text = (await page_total.inner_text()).strip()\n normalized_total = total_text.replace(\"$\", \"\").replace(\",\", \"\").strip()\n order_total = float(normalized_total)\n return {\n \"quote_id\": \"QF-4821\",\n \"order_total\": order_total,\n \"displayed_total\": total_text,\n \"evidence_text\": (await total_panel.inner_text()).strip()\n }\n",
+ "final_staged_workflow_yaml": "title: Retrieve deferred freight quote total\nworkflow_definition:\n parameters: []\n blocks:\n - block_type: code\n label: calculate_and_extract_quote_total\n prompt: Open quote QF-4821, calculate its shipping-inclusive order total, and return the page-displayed total as a number.\n code: |\n await page.goto(\"http://localhost:8900/deferred_total_quote/\")\n quote_heading = page.get_by_text(\"Quote QF-4821\", exact=True)\n await quote_heading.wait_for(state=\"visible\", timeout=10000)\n total_panel = page.locator(\"div.totals\")\n await total_panel.wait_for(state=\"visible\", timeout=10000)\n await page.locator(\"#calculate-total\").click()\n page_total = page.locator(\"#order-total\")\n await page_total.wait_for(state=\"visible\", timeout=10000)\n total_text = \"\"\n for _ in range(20):\n total_text = (await page_total.inner_text()).strip()\n if total_text.startswith(\"$\"):\n break\n await page.wait_for_timeout(500)\n if not total_text.startswith(\"$\"):\n raise ValueError(\"The calculated page total did not become available\")\n normalized_total = total_text.replace(\"$\", \"\").replace(\",\", \"\").strip()\n order_total = float(normalized_total)\n return {\n \"quote_id\": \"QF-4821\",\n \"order_total\": order_total,\n \"displayed_total\": total_text,\n \"evidence_text\": (await total_panel.inner_text()).strip()\n }\n",
+ "handback_run_id": "wr_569288397328868066",
+ "expect": {
+ "carrier_disposition": "block_signature_changed:wr_569288324314423984:calculate_and_extract_quote_total",
+ "tool_result_attachment": null,
+ "disposition": "no_later_run",
+ "attached": false,
+ "history_retains_failure": true
+ }
+}
diff --git a/tests/unit/fixtures/copilot/unresolved_failure_clearance/successful_draft_handback_empty_persisted.json b/tests/unit/fixtures/copilot/unresolved_failure_clearance/successful_draft_handback_empty_persisted.json
new file mode 100644
index 000000000..49d078dde
--- /dev/null
+++ b/tests/unit/fixtures/copilot/unresolved_failure_clearance/successful_draft_handback_empty_persisted.json
@@ -0,0 +1,57 @@
+{
+ "provenance": {
+ "kind": "branch_local_witness",
+ "source": "derived from captured_repair_then_completed_run.json",
+ "notes": "The draft was never saved and the proposal that just ran carries the repair. Ordering taken from the SKY-15658 production fingerprint on successful hand-backs wr_570538698832229610, wr_570540378164441128, wr_570559591083343744, wr_570559917500856932 and wr_570560299752946268: the run being reported has not reached the history yet, and no workflow is saved. Bodies are the captured ones; those run ids are fingerprint provenance, not reruns."
+ },
+ "steps": [
+ {
+ "workflow_yaml": "title: Retrieve deferred freight quote total\nworkflow_definition:\n parameters: []\n blocks:\n - block_type: code\n label: calculate_and_extract_quote_total\n prompt: Open quote QF-4821, calculate its shipping-inclusive order total, and return the page-displayed total as a number.\n code: |\n await page.goto(\"http://localhost:8900/deferred_total_quote/\")\n quote_heading = page.get_by_text(\"Quote QF-4821\", exact=True)\n await quote_heading.wait_for(state=\"visible\", timeout=10000)\n total_panel = page.locator(\"div.totals\")\n await total_panel.wait_for(state=\"visible\", timeout=10000)\n await page.locator(\"#calculate-total\").click()\n await total_panel.locator(\"strong\").wait_for(state=\"visible\", timeout=10000)\n total_text = (await total_panel.locator(\"strong\").inner_text()).strip()\n normalized_total = total_text.replace(\"$\", \"\").replace(\",\", \"\").strip()\n order_total = float(normalized_total)\n return {\n \"quote_id\": \"QF-4821\",\n \"order_total\": order_total,\n \"displayed_total\": total_text,\n \"evidence_text\": (await total_panel.inner_text()).strip()\n }\n",
+ "staged_workflow_yaml": "title: Retrieve deferred freight quote total\nworkflow_definition:\n parameters: []\n blocks:\n - block_type: code\n label: calculate_and_extract_quote_total\n prompt: Open quote QF-4821, calculate its shipping-inclusive order total, and return the page-displayed total as a number.\n code: |\n await page.goto(\"http://localhost:8900/deferred_total_quote/\")\n quote_heading = page.get_by_text(\"Quote QF-4821\", exact=True)\n await quote_heading.wait_for(state=\"visible\", timeout=10000)\n total_panel = page.locator(\"div.totals\")\n await total_panel.wait_for(state=\"visible\", timeout=10000)\n await page.locator(\"#calculate-total\").click()\n await total_panel.locator(\"strong\").wait_for(state=\"visible\", timeout=10000)\n total_text = (await total_panel.locator(\"strong\").inner_text()).strip()\n normalized_total = total_text.replace(\"$\", \"\").replace(\",\", \"\").strip()\n order_total = float(normalized_total)\n return {\n \"quote_id\": \"QF-4821\",\n \"order_total\": order_total,\n \"displayed_total\": total_text,\n \"evidence_text\": (await total_panel.inner_text()).strip()\n }\n",
+ "outcome": {
+ "phase": "persisted_block_run",
+ "attempted_tool": "update_and_run_blocks",
+ "attempted_block_label": "calculate_and_extract_quote_total",
+ "attempted_call_ref": "locator:div.totals",
+ "verdict": "repairable_failure",
+ "reason_code": "runtime_block_failure",
+ "workflow_run_id": "wr_569288173990568574",
+ "block_labels": [
+ "calculate_and_extract_quote_total"
+ ],
+ "executed_block_labels": [
+ "calculate_and_extract_quote_total"
+ ],
+ "structural_failure_identity": "code-block-exception:wr_569288173990568574"
+ }
+ },
+ {
+ "workflow_yaml": "title: Retrieve deferred freight quote total\nworkflow_definition:\n parameters: []\n blocks:\n - block_type: code\n label: calculate_and_extract_quote_total\n prompt: Open quote QF-4821, calculate its shipping-inclusive order total, and return the page-displayed total as a number.\n code: |\n await page.goto(\"http://localhost:8900/deferred_total_quote/\")\n quote_heading = page.get_by_text(\"Quote QF-4821\", exact=True)\n await quote_heading.wait_for(state=\"visible\", timeout=10000)\n total_panel = page.locator(\"div.totals\")\n await total_panel.wait_for(state=\"visible\", timeout=10000)\n await page.locator(\"#calculate-total\").click()\n page_total = page.locator(\"#order-total\")\n await page_total.wait_for(state=\"visible\", timeout=10000)\n total_text = (await page_total.inner_text()).strip()\n normalized_total = total_text.replace(\"$\", \"\").replace(\",\", \"\").strip()\n order_total = float(normalized_total)\n return {\n \"quote_id\": \"QF-4821\",\n \"order_total\": order_total,\n \"displayed_total\": total_text,\n \"evidence_text\": (await total_panel.inner_text()).strip()\n }\n",
+ "staged_workflow_yaml": "title: Retrieve deferred freight quote total\nworkflow_definition:\n parameters: []\n blocks:\n - block_type: code\n label: calculate_and_extract_quote_total\n prompt: Open quote QF-4821, calculate its shipping-inclusive order total, and return the page-displayed total as a number.\n code: |\n await page.goto(\"http://localhost:8900/deferred_total_quote/\")\n quote_heading = page.get_by_text(\"Quote QF-4821\", exact=True)\n await quote_heading.wait_for(state=\"visible\", timeout=10000)\n total_panel = page.locator(\"div.totals\")\n await total_panel.wait_for(state=\"visible\", timeout=10000)\n await page.locator(\"#calculate-total\").click()\n page_total = page.locator(\"#order-total\")\n await page_total.wait_for(state=\"visible\", timeout=10000)\n total_text = (await page_total.inner_text()).strip()\n normalized_total = total_text.replace(\"$\", \"\").replace(\",\", \"\").strip()\n order_total = float(normalized_total)\n return {\n \"quote_id\": \"QF-4821\",\n \"order_total\": order_total,\n \"displayed_total\": total_text,\n \"evidence_text\": (await total_panel.inner_text()).strip()\n }\n",
+ "outcome": {
+ "phase": "persisted_block_run",
+ "attempted_tool": "update_and_run_blocks",
+ "attempted_block_label": "calculate_and_extract_quote_total",
+ "attempted_call_ref": "",
+ "verdict": "repairable_failure",
+ "reason_code": "runtime_block_failure",
+ "workflow_run_id": "wr_569288324314423984",
+ "block_labels": [
+ "calculate_and_extract_quote_total"
+ ],
+ "executed_block_labels": [
+ "calculate_and_extract_quote_total"
+ ],
+ "structural_failure_identity": "code-block-exception:wr_569288324314423984"
+ }
+ }
+ ],
+ "reported_workflow_yaml": null,
+ "final_staged_workflow_yaml": "title: Retrieve deferred freight quote total\nworkflow_definition:\n parameters: []\n blocks:\n - block_type: code\n label: calculate_and_extract_quote_total\n prompt: Open quote QF-4821, calculate its shipping-inclusive order total, and return the page-displayed total as a number.\n code: |\n await page.goto(\"http://localhost:8900/deferred_total_quote/\")\n quote_heading = page.get_by_text(\"Quote QF-4821\", exact=True)\n await quote_heading.wait_for(state=\"visible\", timeout=10000)\n total_panel = page.locator(\"div.totals\")\n await total_panel.wait_for(state=\"visible\", timeout=10000)\n await page.locator(\"#calculate-total\").click()\n page_total = page.locator(\"#order-total\")\n await page_total.wait_for(state=\"visible\", timeout=10000)\n total_text = \"\"\n for _ in range(20):\n total_text = (await page_total.inner_text()).strip()\n if total_text.startswith(\"$\"):\n break\n await page.wait_for_timeout(500)\n if not total_text.startswith(\"$\"):\n raise ValueError(\"The calculated page total did not become available\")\n normalized_total = total_text.replace(\"$\", \"\").replace(\",\", \"\").strip()\n order_total = float(normalized_total)\n return {\n \"quote_id\": \"QF-4821\",\n \"order_total\": order_total,\n \"displayed_total\": total_text,\n \"evidence_text\": (await total_panel.inner_text()).strip()\n }\n",
+ "handback_run_id": "wr_569288397328868066",
+ "expect": {
+ "carrier_disposition": "block_signature_changed:wr_569288324314423984:calculate_and_extract_quote_total",
+ "tool_result_attachment": null,
+ "history_retains_failure": true
+ }
+}
diff --git a/tests/unit/fixtures/copilot/unresolved_failure_clearance/unrepaired_draft_handback_empty_persisted.json b/tests/unit/fixtures/copilot/unresolved_failure_clearance/unrepaired_draft_handback_empty_persisted.json
new file mode 100644
index 000000000..8bd089e5a
--- /dev/null
+++ b/tests/unit/fixtures/copilot/unresolved_failure_clearance/unrepaired_draft_handback_empty_persisted.json
@@ -0,0 +1,62 @@
+{
+ "provenance": {
+ "kind": "branch_local_witness",
+ "source": "derived from captured_repair_then_completed_run.json",
+ "notes": "Same ordering, but the proposal that ran is the one that failed, so the failure has to survive into the hand-back under the older run's own id. Ordering taken from the SKY-15658 production fingerprint on successful hand-backs wr_570538698832229610, wr_570540378164441128, wr_570559591083343744, wr_570559917500856932 and wr_570560299752946268: the run being reported has not reached the history yet, and no workflow is saved. Bodies are the captured ones; those run ids are fingerprint provenance, not reruns."
+ },
+ "steps": [
+ {
+ "workflow_yaml": "title: Retrieve deferred freight quote total\nworkflow_definition:\n parameters: []\n blocks:\n - block_type: code\n label: calculate_and_extract_quote_total\n prompt: Open quote QF-4821, calculate its shipping-inclusive order total, and return the page-displayed total as a number.\n code: |\n await page.goto(\"http://localhost:8900/deferred_total_quote/\")\n quote_heading = page.get_by_text(\"Quote QF-4821\", exact=True)\n await quote_heading.wait_for(state=\"visible\", timeout=10000)\n total_panel = page.locator(\"div.totals\")\n await total_panel.wait_for(state=\"visible\", timeout=10000)\n await page.locator(\"#calculate-total\").click()\n await total_panel.locator(\"strong\").wait_for(state=\"visible\", timeout=10000)\n total_text = (await total_panel.locator(\"strong\").inner_text()).strip()\n normalized_total = total_text.replace(\"$\", \"\").replace(\",\", \"\").strip()\n order_total = float(normalized_total)\n return {\n \"quote_id\": \"QF-4821\",\n \"order_total\": order_total,\n \"displayed_total\": total_text,\n \"evidence_text\": (await total_panel.inner_text()).strip()\n }\n",
+ "staged_workflow_yaml": "title: Retrieve deferred freight quote total\nworkflow_definition:\n parameters: []\n blocks:\n - block_type: code\n label: calculate_and_extract_quote_total\n prompt: Open quote QF-4821, calculate its shipping-inclusive order total, and return the page-displayed total as a number.\n code: |\n await page.goto(\"http://localhost:8900/deferred_total_quote/\")\n quote_heading = page.get_by_text(\"Quote QF-4821\", exact=True)\n await quote_heading.wait_for(state=\"visible\", timeout=10000)\n total_panel = page.locator(\"div.totals\")\n await total_panel.wait_for(state=\"visible\", timeout=10000)\n await page.locator(\"#calculate-total\").click()\n await total_panel.locator(\"strong\").wait_for(state=\"visible\", timeout=10000)\n total_text = (await total_panel.locator(\"strong\").inner_text()).strip()\n normalized_total = total_text.replace(\"$\", \"\").replace(\",\", \"\").strip()\n order_total = float(normalized_total)\n return {\n \"quote_id\": \"QF-4821\",\n \"order_total\": order_total,\n \"displayed_total\": total_text,\n \"evidence_text\": (await total_panel.inner_text()).strip()\n }\n",
+ "outcome": {
+ "phase": "persisted_block_run",
+ "attempted_tool": "update_and_run_blocks",
+ "attempted_block_label": "calculate_and_extract_quote_total",
+ "attempted_call_ref": "locator:div.totals",
+ "verdict": "repairable_failure",
+ "reason_code": "runtime_block_failure",
+ "workflow_run_id": "wr_569288173990568574",
+ "block_labels": [
+ "calculate_and_extract_quote_total"
+ ],
+ "executed_block_labels": [
+ "calculate_and_extract_quote_total"
+ ],
+ "structural_failure_identity": "code-block-exception:wr_569288173990568574"
+ }
+ },
+ {
+ "workflow_yaml": "title: Retrieve deferred freight quote total\nworkflow_definition:\n parameters: []\n blocks:\n - block_type: code\n label: calculate_and_extract_quote_total\n prompt: Open quote QF-4821, calculate its shipping-inclusive order total, and return the page-displayed total as a number.\n code: |\n await page.goto(\"http://localhost:8900/deferred_total_quote/\")\n quote_heading = page.get_by_text(\"Quote QF-4821\", exact=True)\n await quote_heading.wait_for(state=\"visible\", timeout=10000)\n total_panel = page.locator(\"div.totals\")\n await total_panel.wait_for(state=\"visible\", timeout=10000)\n await page.locator(\"#calculate-total\").click()\n page_total = page.locator(\"#order-total\")\n await page_total.wait_for(state=\"visible\", timeout=10000)\n total_text = (await page_total.inner_text()).strip()\n normalized_total = total_text.replace(\"$\", \"\").replace(\",\", \"\").strip()\n order_total = float(normalized_total)\n return {\n \"quote_id\": \"QF-4821\",\n \"order_total\": order_total,\n \"displayed_total\": total_text,\n \"evidence_text\": (await total_panel.inner_text()).strip()\n }\n",
+ "staged_workflow_yaml": "title: Retrieve deferred freight quote total\nworkflow_definition:\n parameters: []\n blocks:\n - block_type: code\n label: calculate_and_extract_quote_total\n prompt: Open quote QF-4821, calculate its shipping-inclusive order total, and return the page-displayed total as a number.\n code: |\n await page.goto(\"http://localhost:8900/deferred_total_quote/\")\n quote_heading = page.get_by_text(\"Quote QF-4821\", exact=True)\n await quote_heading.wait_for(state=\"visible\", timeout=10000)\n total_panel = page.locator(\"div.totals\")\n await total_panel.wait_for(state=\"visible\", timeout=10000)\n await page.locator(\"#calculate-total\").click()\n page_total = page.locator(\"#order-total\")\n await page_total.wait_for(state=\"visible\", timeout=10000)\n total_text = (await page_total.inner_text()).strip()\n normalized_total = total_text.replace(\"$\", \"\").replace(\",\", \"\").strip()\n order_total = float(normalized_total)\n return {\n \"quote_id\": \"QF-4821\",\n \"order_total\": order_total,\n \"displayed_total\": total_text,\n \"evidence_text\": (await total_panel.inner_text()).strip()\n }\n",
+ "outcome": {
+ "phase": "persisted_block_run",
+ "attempted_tool": "update_and_run_blocks",
+ "attempted_block_label": "calculate_and_extract_quote_total",
+ "attempted_call_ref": "",
+ "verdict": "repairable_failure",
+ "reason_code": "runtime_block_failure",
+ "workflow_run_id": "wr_569288324314423984",
+ "block_labels": [
+ "calculate_and_extract_quote_total"
+ ],
+ "executed_block_labels": [
+ "calculate_and_extract_quote_total"
+ ],
+ "structural_failure_identity": "code-block-exception:wr_569288324314423984"
+ }
+ }
+ ],
+ "reported_workflow_yaml": null,
+ "final_staged_workflow_yaml": "title: Retrieve deferred freight quote total\nworkflow_definition:\n parameters: []\n blocks:\n - block_type: code\n label: calculate_and_extract_quote_total\n prompt: Open quote QF-4821, calculate its shipping-inclusive order total, and return the page-displayed total as a number.\n code: |\n await page.goto(\"http://localhost:8900/deferred_total_quote/\")\n quote_heading = page.get_by_text(\"Quote QF-4821\", exact=True)\n await quote_heading.wait_for(state=\"visible\", timeout=10000)\n total_panel = page.locator(\"div.totals\")\n await total_panel.wait_for(state=\"visible\", timeout=10000)\n await page.locator(\"#calculate-total\").click()\n page_total = page.locator(\"#order-total\")\n await page_total.wait_for(state=\"visible\", timeout=10000)\n total_text = (await page_total.inner_text()).strip()\n normalized_total = total_text.replace(\"$\", \"\").replace(\",\", \"\").strip()\n order_total = float(normalized_total)\n return {\n \"quote_id\": \"QF-4821\",\n \"order_total\": order_total,\n \"displayed_total\": total_text,\n \"evidence_text\": (await total_panel.inner_text()).strip()\n }\n",
+ "handback_run_id": "wr_569288397328868066",
+ "expect": {
+ "carrier_disposition": "unresolved",
+ "tool_result_attachment": {
+ "workflow_run_id": "wr_569288324314423984",
+ "block_label": "calculate_and_extract_quote_total",
+ "failure_kind": "runtime_block_failure",
+ "note": "this run passing does not establish that the earlier failure was resolved"
+ },
+ "history_retains_failure": true
+ }
+}
diff --git a/tests/unit/test_copilot_build_test_outcome.py b/tests/unit/test_copilot_build_test_outcome.py
index 2859f6ad4..89cee6474 100644
--- a/tests/unit/test_copilot_build_test_outcome.py
+++ b/tests/unit/test_copilot_build_test_outcome.py
@@ -92,7 +92,7 @@ from skyvern.forge.sdk.schemas.copilot_turn_outcome import ResponseKind, TurnOut
from skyvern.forge.sdk.schemas.persistent_browser_sessions import PersistentBrowserSession
from skyvern.forge.sdk.workflow.models.block import CodeBlock
from skyvern.forge.sdk.workflow.models.parameter import OutputParameter, ParameterType
-from skyvern.forge.sdk.workflow.models.workflow import WorkflowRunStatus
+from skyvern.forge.sdk.workflow.models.workflow import Workflow, WorkflowDefinition, WorkflowRunStatus
from skyvern.services import workflow_service as workflow_service_module
from skyvern.webeye.actions.action_types import ActionType
from skyvern.webeye.actions.actions import ActionStatus
@@ -5596,6 +5596,145 @@ def test_the_tool_result_and_the_terminal_agree_once_the_executed_snapshot_clear
assert terminal.narrative_payload["terminalMessage"] == "Built it and tested it."
+# Hand-backs whose logs carry the reported ordering: the run being reported has not reached the
+# history yet, and no workflow is saved.
+_SUCCESSFUL_DRAFT_HANDBACK_RUN_IDS = (
+ "wr_570538698832229610",
+ "wr_570540378164441128",
+ "wr_570559591083343744",
+ "wr_570559917500856932",
+ "wr_570560299752946268",
+)
+
+
+def _executed_run_result(
+ workflow_run_id: str, executed_workflow_yaml: str, snapshot_workflow_yaml: str | None = ""
+) -> dict[str, Any]:
+ """A hand-back shaped like the run path's: it carries the snapshot the run dispatched.
+
+ ``snapshot_workflow_yaml`` defaults to the executed text; pass None for the snapshots that
+ carry no authored bytes, where _RunExecution falls back to a re-serialized definition."""
+ now = datetime.now(UTC)
+ workflow = Workflow(
+ workflow_id="wf_test",
+ organization_id="org_test",
+ title="Test",
+ workflow_permanent_id="wpid_test",
+ version=1,
+ is_saved_task=False,
+ workflow_definition=WorkflowDefinition(parameters=[], blocks=[]),
+ created_at=now,
+ modified_at=now,
+ )
+ execution = run_execution_module._RunExecution(
+ snapshot=run_execution_module.CopilotExecutionSnapshot(
+ provenance="staged",
+ workflow=workflow,
+ workflow_parameters=(),
+ output_parameters=(),
+ workflow_yaml=executed_workflow_yaml if snapshot_workflow_yaml == "" else snapshot_workflow_yaml,
+ ),
+ workflow_yaml=executed_workflow_yaml,
+ metadata={},
+ associations={},
+ source_at_start=None,
+ unbound_keys=[],
+ explicit_blank=False,
+ )
+ return run_execution_module._ExecutionResult(
+ {"ok": True, "data": {"workflow_run_id": workflow_run_id, "overall_status": "completed"}},
+ execution,
+ )
+
+
+def _never_saved_draft_ctx() -> CopilotContext:
+ ctx = make_copilot_ctx(workflow_yaml=two_page_login_yaml())
+ ctx.persisted_workflow_yaml = None
+ ctx.staged_workflow_yaml = two_page_login_yaml()
+ record_build_test_outcome(ctx, failed_second_factor_run("wr_1"))
+ return ctx
+
+
+def test_a_run_reports_the_snapshot_it_executed_when_nothing_is_saved() -> None:
+ """Nothing is saved, so the snapshot the run executed is the only candidate the failure can be
+ read against; reading persistence here reports a repaired run as having no candidate at all."""
+ ctx = _never_saved_draft_ctx()
+ result = _executed_run_result(
+ _SUCCESSFUL_DRAFT_HANDBACK_RUN_IDS[0], two_page_login_yaml(submit_selector="Continue")
+ )
+
+ run_execution_module._carry_unresolved_failure_into_result(ctx, result, "update_and_run_blocks")
+
+ assert "unresolved_earlier_failure" not in result["data"]
+ assert [entry["workflow_run_id"] for entry in ctx.recorded_build_test_outcome_history] == ["wr_1"]
+
+
+def test_a_run_that_executed_the_unrepaired_snapshot_carries_the_older_run_id() -> None:
+ ctx = _never_saved_draft_ctx()
+ result = _executed_run_result(_SUCCESSFUL_DRAFT_HANDBACK_RUN_IDS[1], two_page_login_yaml())
+
+ run_execution_module._carry_unresolved_failure_into_result(ctx, result, "update_and_run_blocks")
+
+ carried = result["data"]["unresolved_earlier_failure"]
+ assert carried["workflow_run_id"] == "wr_1"
+ assert carried["workflow_run_id"] != result["data"]["workflow_run_id"]
+ assert carried["block_label"] == "sign_in_and_read"
+
+
+def test_a_repair_staged_after_the_run_cannot_clear_the_snapshot_that_ran() -> None:
+ """A proposal staged between the run and the hand-back was never executed, so crediting it
+ would clear a failure on the strength of code no run has tried."""
+ ctx = _never_saved_draft_ctx()
+ result = _executed_run_result(_SUCCESSFUL_DRAFT_HANDBACK_RUN_IDS[2], two_page_login_yaml())
+ ctx.staged_workflow_yaml = two_page_login_yaml(submit_selector="Continue")
+
+ run_execution_module._carry_unresolved_failure_into_result(ctx, result, "update_and_run_blocks")
+
+ assert result["data"]["unresolved_earlier_failure"]["workflow_run_id"] == "wr_1"
+
+
+def test_a_snapshot_without_authored_bytes_is_not_compared_against_a_re_serialization() -> None:
+ """Signatures are taken from authored yaml. A re-serialized definition drops authoring-only
+ fields, so comparing it would read every block as changed and clear the failure."""
+ ctx = _never_saved_draft_ctx()
+ result = _executed_run_result(
+ _SUCCESSFUL_DRAFT_HANDBACK_RUN_IDS[0],
+ two_page_login_yaml(submit_selector="Continue"),
+ snapshot_workflow_yaml=None,
+ )
+
+ run_execution_module._carry_unresolved_failure_into_result(ctx, result, "run_blocks_and_collect_debug")
+
+ assert result["data"]["unresolved_earlier_failure"]["workflow_run_id"] == "wr_1"
+
+
+def test_the_terminal_judges_the_saved_workflow_while_the_run_reports_the_snapshot_that_ran() -> None:
+ ctx = make_copilot_ctx(workflow_yaml=two_page_login_yaml())
+ ctx.persisted_workflow_yaml = two_page_login_yaml()
+ ctx.staged_workflow_yaml = two_page_login_yaml()
+ record_build_test_outcome(ctx, failed_second_factor_run("wr_1"))
+ record_build_test_outcome(ctx, _executing_run("wr_2", ["sign_in_and_read"]))
+ result = _executed_run_result(
+ _SUCCESSFUL_DRAFT_HANDBACK_RUN_IDS[3], two_page_login_yaml(submit_selector="Continue")
+ )
+
+ run_execution_module._carry_unresolved_failure_into_result(ctx, result, "update_and_run_blocks")
+ terminal = _make_agent_result(
+ ctx,
+ user_response="Built it and tested it.",
+ updated_workflow=object(),
+ global_llm_context=None,
+ turn_outcome=TurnOutcome(response_kind=ResponseKind.BUILD),
+ narrative_payload={"terminalMessage": "Built it and tested it.", "narrativeSummary": "Built it and tested it."},
+ )
+
+ assert "unresolved_earlier_failure" not in result["data"]
+ assert terminal.turn_outcome is not None
+ assert terminal.turn_outcome.unresolved_runtime_failure == UnresolvedRuntimeFailure(
+ workflow_run_id="wr_1", block_label="sign_in_and_read"
+ )
+
+
def _many_literal_selectors_yaml(selector_count: int) -> str:
calls = "".join(f' await page.locator("#field-{index}").click()\n' for index in range(selector_count))
return (