Skip to content

Automate browser based workflows with AI

Record who started each workflow run and show it on the Runs page (#8677)

Shuchang Zheng0f2395e5f2dc
diff --git a/alembic/versions/2026_09_27_0234-adf6f1f2e672_add_created_by_to_workflow_runs.py b/alembic/versions/2026_09_27_0234-adf6f1f2e672_add_created_by_to_workflow_runs.py
new file mode 100644
index 000000000..716801d44
--- /dev/null
+++ b/alembic/versions/2026_09_27_0234-adf6f1f2e672_add_created_by_to_workflow_runs.py
@@ -0,0 +1,29 @@
+"""add created_by to workflow_runs
+
+Revision ID: adf6f1f2e672
+Revises: 762d72647b18
+Create Date: 2026-09-27T02:34:31.800080+00:00
+
+"""
+
+from typing import Sequence, Union
+
+import sqlalchemy as sa
+
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision: str = "adf6f1f2e672"
+down_revision: Union[str, None] = "762d72647b18"
+branch_labels: Union[str, Sequence[str], None] = None
+depends_on: Union[str, Sequence[str], None] = None
+
+
+def upgrade() -> None:
+ op.execute("SET LOCAL lock_timeout = '5s'")
+ op.add_column("workflow_runs", sa.Column("created_by", sa.String(), nullable=True))
+
+
+def downgrade() -> None:
+ op.execute("SET LOCAL lock_timeout = '5s'")
+ op.drop_column("workflow_runs", "created_by")
diff --git a/docs/api-reference/openapi.json b/docs/api-reference/openapi.json
index 93d54822c..20373575a 100644
--- a/docs/api-reference/openapi.json
+++ b/docs/api-reference/openapi.json
@@ -24841,6 +24841,18 @@
"type": "null"
}
]
+ },
+ "created_by": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Created By",
+ "description": "ID of the user who started the run"
}
},
"type": "object",
@@ -31032,6 +31044,18 @@
],
"title": "Copilot Session Id"
},
+ "created_by": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Created By",
+ "description": "ID of the user who started the run"
+ },
"credits_used": {
"type": "integer",
"title": "Credits Used",
diff --git a/skyvern-frontend/src/api/types.ts b/skyvern-frontend/src/api/types.ts
index 00d8150e1..4e07ffd26 100644
--- a/skyvern-frontend/src/api/types.ts
+++ b/skyvern-frontend/src/api/types.ts
@@ -895,6 +895,7 @@ export type TaskRunListItem = {
workflow_deleted: boolean;
script_run: boolean;
trigger_type?: TriggerType | null;
+ created_by?: string | null;
searchable_text: string | null;
} & Pick<
WorkflowRunRetryFields,
diff --git a/skyvern-frontend/src/components/icons/SparklesIcon.tsx b/skyvern-frontend/src/components/icons/SparklesIcon.tsx
new file mode 100644
index 000000000..a56bc543d
--- /dev/null
+++ b/skyvern-frontend/src/components/icons/SparklesIcon.tsx
@@ -0,0 +1,28 @@
+type Props = {
+ className?: string;
+};
+
+function SparklesIcon({ className }: Props) {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="1.5"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ className={className}
+ aria-hidden="true"
+ >
+ <path
+ d="M9.94 14.06 7.5 21 5.06 14.06 0 12l5.06-2.06L7.5 3l2.44 6.94L15 12Z"
+ transform="translate(3 0) scale(.82)"
+ />
+ <path d="M20 3v4" />
+ <path d="M22 5h-4" />
+ </svg>
+ );
+}
+
+export { SparklesIcon };
diff --git a/skyvern-frontend/src/routes/history/HistoryPage.tsx b/skyvern-frontend/src/routes/history/HistoryPage.tsx
index cc9e7a061..bc5e87c25 100644
--- a/skyvern-frontend/src/routes/history/HistoryPage.tsx
+++ b/skyvern-frontend/src/routes/history/HistoryPage.tsx
@@ -1,10 +1,14 @@
+import { CreatorDirectoryBoundary } from "@/components/CreatorDirectoryBoundary";
+
import { RunHistory } from "./RunHistory";
function HistoryPage() {
return (
- <div className="space-y-6">
- <RunHistory />
- </div>
+ <CreatorDirectoryBoundary>
+ <div className="space-y-6">
+ <RunHistory />
+ </div>
+ </CreatorDirectoryBoundary>
);
}
diff --git a/skyvern-frontend/src/routes/history/RunHistory.tsx b/skyvern-frontend/src/routes/history/RunHistory.tsx
index afd6d4c5c..1c18c276e 100644
--- a/skyvern-frontend/src/routes/history/RunHistory.tsx
+++ b/skyvern-frontend/src/routes/history/RunHistory.tsx
@@ -74,6 +74,8 @@ import { useKeywordSearch } from "@/routes/workflows/hooks/useKeywordSearch";
import { useParameterExpansion } from "@/routes/workflows/hooks/useParameterExpansion";
import { ParameterDisplayInline } from "@/routes/workflows/components/ParameterDisplayInline";
import { HighlightText } from "@/routes/workflows/components/HighlightText";
+import { WorkflowCreatorLabel } from "@/routes/workflows/components/WorkflowCreatorLabel";
+import { useCreatorColumnEnabled } from "@/store/WorkflowCreatorContext";
import { useOnboardingStateOptional } from "@/store/onboarding/useOnboardingState";
import { OnboardingEmptyState } from "@/components/onboarding/OnboardingEmptyState";
import { useFeatureFlagVariantKey } from "posthog-js/react";
@@ -181,6 +183,7 @@ function getRerunPath(run: TaskRunListItem): string | null {
}
function RunHistory() {
+ const showCreator = useCreatorColumnEnabled();
const onboarding = useOnboardingStateOptional();
const isNewUser = onboarding?.isNewUser ?? false;
const onboardingState = onboarding?.state ?? null;
@@ -307,7 +310,7 @@ function RunHistory() {
[runs, taggingEnabled],
);
const showCheckbox = selectableRuns.length > 0;
- const columnCount = showCheckbox ? 7 : 6;
+ const columnCount = 6 + (showCheckbox ? 1 : 0) + (showCreator ? 1 : 0);
const {
selectedItems: selectedRuns,
isSelected,
@@ -509,6 +512,11 @@ function RunHistory() {
/>
</div>
</TableCell>
+ {showCreator && (
+ <TableCell className="max-w-0">
+ <WorkflowCreatorLabel createdBy={run.created_by} />
+ </TableCell>
+ )}
<TableCell
className="max-w-0 truncate"
title={basicTimeFormat(run.created_at)}
@@ -716,10 +724,21 @@ function RunHistory() {
className="w-10"
/>
)}
- <TableHead className="w-[20%]">Run ID</TableHead>
- <TableHead className="w-[20%]">Detail</TableHead>
- <TableHead className="w-[16%]">Status</TableHead>
- <TableHead className="w-[27%]">Created At</TableHead>
+ <TableHead className={showCreator ? "w-[18%]" : "w-[20%]"}>
+ Run ID
+ </TableHead>
+ <TableHead className={showCreator ? "w-[18%]" : "w-[20%]"}>
+ Detail
+ </TableHead>
+ <TableHead className={showCreator ? "w-[14%]" : "w-[16%]"}>
+ Status
+ </TableHead>
+ {showCreator && (
+ <TableHead className="w-[13%]">Created By</TableHead>
+ )}
+ <TableHead className={showCreator ? "w-[21%]" : "w-[27%]"}>
+ Created At
+ </TableHead>
<TableHead className="w-[8%]">Duration</TableHead>
<TableHead className="w-[8%]"></TableHead>
</TableRow>
diff --git a/skyvern-frontend/src/routes/workflows/copilot/CopilotWorkingStatus.test.tsx b/skyvern-frontend/src/routes/workflows/copilot/CopilotWorkingStatus.test.tsx
index 5d6011467..888906b56 100644
--- a/skyvern-frontend/src/routes/workflows/copilot/CopilotWorkingStatus.test.tsx
+++ b/skyvern-frontend/src/routes/workflows/copilot/CopilotWorkingStatus.test.tsx
@@ -10,15 +10,25 @@ afterEach(() => {
});
describe("CopilotWorkingStatus", () => {
- it("announces the state once, without the cycling verb", () => {
- const { rerender } = render(<CopilotWorkingStatus queued={false} />);
- expect(screen.getByText("Working")).toBeTruthy();
+ it("announces each state through one live region, without the cycling verb", () => {
+ const { rerender } = render(
+ <CopilotWorkingStatus status="working" queued={false} />,
+ );
+ const liveRegion = screen.getByText("Working");
+ expect(liveRegion.getAttribute("aria-live")).toBe("polite");
- rerender(<CopilotWorkingStatus queued />);
- expect(screen.getByText("Message queued")).toBeTruthy();
+ rerender(<CopilotWorkingStatus status="working" queued />);
+ expect(screen.getByText("Message queued")).toBe(liveRegion);
// The verb re-renders every few seconds, so it must stay out of the
// announcement or a screen reader repeats it forever.
- const verb = screen.getByTestId("copilot-working-status").firstElementChild;
- expect(verb?.getAttribute("aria-hidden")).toBe("true");
+ const visible = screen.getByTestId(
+ "copilot-working-status",
+ ).firstElementChild;
+ expect(visible?.getAttribute("aria-hidden")).toBe("true");
+
+ rerender(<CopilotWorkingStatus status="waiting" queued={false} />);
+ expect(
+ screen.getByText("Waiting for you", { selector: "[aria-live]" }),
+ ).toBe(liveRegion);
});
});
diff --git a/skyvern-frontend/src/routes/workflows/copilot/CopilotWorkingStatus.tsx b/skyvern-frontend/src/routes/workflows/copilot/CopilotWorkingStatus.tsx
index 216bddd74..d45f63f72 100644
--- a/skyvern-frontend/src/routes/workflows/copilot/CopilotWorkingStatus.tsx
+++ b/skyvern-frontend/src/routes/workflows/copilot/CopilotWorkingStatus.tsx
@@ -1,38 +1,87 @@
import { useEffect, useState } from "react";
+import { SparklesIcon } from "@/components/icons/SparklesIcon";
+import { cn } from "@/util/utils";
+
import { VERB_CYCLE_MS, pickWorkingVerb } from "./workingVerbs";
+export type CopilotComposerStatus = "working" | "waiting";
+
+const VERB_ROLL_MS = 200;
+
+type RollPhase = "shown" | "leaving" | "entering";
+
type Props = {
+ status: CopilotComposerStatus;
queued: boolean;
};
-export function CopilotWorkingStatus({ queued }: Props) {
+export function CopilotWorkingStatus({ status, queued }: Props) {
const [verb, setVerb] = useState(() => pickWorkingVerb());
+ const [phase, setPhase] = useState<RollPhase>("shown");
useEffect(() => {
- const timer = setInterval(
- () => setVerb((previous) => pickWorkingVerb(previous)),
- VERB_CYCLE_MS,
- );
- return () => clearInterval(timer);
- }, []);
+ if (status !== "working") return;
+ let swap: ReturnType<typeof setTimeout> | undefined;
+ let frame: number | undefined;
+ const timer = setInterval(() => {
+ setPhase("leaving");
+ swap = setTimeout(() => {
+ setVerb((previous) => pickWorkingVerb(previous));
+ setPhase("entering");
+ // Two frames so the below-the-line start position paints before the
+ // transition back to rest; one frame can coalesce with the swap.
+ frame = requestAnimationFrame(() => {
+ frame = requestAnimationFrame(() => setPhase("shown"));
+ });
+ }, VERB_ROLL_MS);
+ }, VERB_CYCLE_MS);
+ return () => {
+ clearInterval(timer);
+ clearTimeout(swap);
+ if (frame !== undefined) cancelAnimationFrame(frame);
+ setPhase("shown");
+ };
+ }, [status]);
+
+ const announcement =
+ status === "waiting"
+ ? "Waiting for you"
+ : queued
+ ? "Message queued"
+ : "Working";
return (
<div
- className="mb-2 flex items-center gap-2 pl-0.5"
+ className="mb-2 flex min-h-6 items-center pl-0.5 text-[12.5px]"
data-testid="copilot-working-status"
>
- <span
- key={verb}
- aria-hidden
- className="min-w-0 truncate duration-150 animate-in fade-in"
- >
- <span className="animate-copilot-verb-shimmer bg-[linear-gradient(90deg,#6B7688_0%,#EAF3FF_50%,#6B7688_100%)] bg-[length:220%_100%] bg-clip-text text-[13.5px] font-semibold text-transparent motion-reduce:animate-none motion-reduce:bg-none motion-reduce:text-[#9AA5B6]">
- {verb}…
- </span>
+ <span aria-hidden className="flex min-w-0 items-center gap-2">
+ {status === "working" ? (
+ <>
+ <SparklesIcon className="h-3.5 w-3.5 shrink-0 animate-copilot-sparkle-breathe text-blue-600 motion-reduce:animate-none dark:text-blue-300" />
+ <span
+ className={cn(
+ "min-w-0 truncate text-zinc-700 transition-[transform,opacity] duration-200 ease-out motion-reduce:translate-y-0 motion-reduce:opacity-100 motion-reduce:transition-none dark:text-slate-300",
+ phase === "leaving" && "-translate-y-[7px] opacity-0",
+ phase === "entering" &&
+ "translate-y-[7px] opacity-0 transition-none",
+ )}
+ >
+ {verb}…
+ </span>
+ </>
+ ) : (
+ <>
+ <span className="h-2 w-2 shrink-0 rounded-full bg-amber-500 shadow-[0_0_0_3px_rgba(245,158,11,0.18)]" />
+ <span className="min-w-0 truncate font-semibold text-amber-700 dark:text-yellow-400">
+ Waiting for you
+ </span>
+ </>
+ )}
</span>
<span className="sr-only" aria-live="polite">
- {queued ? "Message queued" : "Working"}
+ {announcement}
</span>
</div>
);
diff --git a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.composerControls.test.tsx b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.composerControls.test.tsx
index 993a2a30c..d344a3cae 100644
--- a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.composerControls.test.tsx
+++ b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.composerControls.test.tsx
@@ -5,6 +5,7 @@ import {
render,
screen,
waitFor,
+ within,
} from "@testing-library/react";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import {
@@ -205,12 +206,12 @@ type FlagConfig = {
isOpen?: boolean;
};
-async function renderChat(flags: FlagConfig) {
+function chatElement(flags: FlagConfig) {
const booleanFlags: Record<string, boolean> = {
WORKFLOW_COPILOT_CODE_BLOCK_MODE: flags.codeBlockMode ?? false,
CODE_BLOCK_ACCESS: flags.codeBlockMode ?? false,
};
- const view = render(
+ return (
<FeatureFlagContext.Provider value={(name) => booleanFlags[name]}>
<WorkflowCopilotChat
isOpen={flags.isOpen}
@@ -218,8 +219,12 @@ async function renderChat(flags: FlagConfig) {
isLiveBrowserReady={flags.isLiveBrowserReady}
liveBrowserSessionId={flags.liveBrowserSessionId}
/>
- </FeatureFlagContext.Provider>,
+ </FeatureFlagContext.Provider>
);
+}
+
+async function renderChat(flags: FlagConfig) {
+ const view = render(chatElement(flags));
await waitFor(() => expect(screen.getByRole("textbox")).toBeTruthy());
return view;
}
@@ -235,6 +240,31 @@ async function submit(value: string) {
});
}
+const pendingQuestionFrame = (interactionId = "qi_1") => ({
+ type: "question_required",
+ turn_id: "turn-1",
+ workflow_copilot_chat_id: "wcc_1",
+ cancel_token: null,
+ interactions: [
+ {
+ interaction_id: interactionId,
+ turn_id: "turn-1",
+ tool_call_id: `tc_${interactionId}`,
+ parts: [{ part_id: "p1", prompt: "Which column?", choices: [] }],
+ status: "pending",
+ response: null,
+ created_at: "2026-01-01T00:00:00Z",
+ resolved_at: null,
+ },
+ ],
+});
+
+function lastStream(): StreamCall {
+ const call = streamCalls[streamCalls.length - 1];
+ if (!call) throw new Error("no pending stream");
+ return call;
+}
+
async function deliverFirstFrame() {
const call = streamCalls[streamCalls.length - 1];
if (!call) throw new Error("no pending stream to open");
@@ -298,6 +328,7 @@ describe("WorkflowCopilotChat — unflagged S4 composer", () => {
const pending = screen.getByRole("button", { name: "Starting…" });
expect(pending.hasAttribute("disabled")).toBe(false);
expect(pending.getAttribute("aria-busy")).not.toBe("true");
+ expect(within(pending).getByTestId("copilot-stop-ring")).toBeTruthy();
await act(async () => {
fireEvent.click(pending);
});
@@ -309,7 +340,7 @@ describe("WorkflowCopilotChat — unflagged S4 composer", () => {
useRecordingStore.setState({ isRecording: true });
});
const button = screen.getByRole("button", { name: "Stop" });
- expect(screen.getByTestId("copilot-stop-orbit").className).not.toContain(
+ expect(screen.getByTestId("copilot-stop-ring").className).not.toContain(
"paused",
);
expect((button as HTMLButtonElement).disabled).toBe(false);
@@ -318,7 +349,7 @@ describe("WorkflowCopilotChat — unflagged S4 composer", () => {
fireEvent.click(button);
});
await waitFor(() => expect(cancelPost).toHaveBeenCalledTimes(1));
- expect(screen.getByTestId("copilot-stop-orbit").className).toContain(
+ expect(screen.getByTestId("copilot-stop-ring").className).toContain(
"paused",
);
// Cancelling must stay legible without motion: the button also goes
@@ -465,6 +496,85 @@ describe("WorkflowCopilotChat — unflagged S4 composer", () => {
).toBeNull();
});
+ it("says Waiting for you over the working verb while a question is pending", async () => {
+ const view = await renderChat({
+ codeBlockMode: true,
+ requiresLiveBrowser: true,
+ isLiveBrowserReady: true,
+ });
+ await submit("build me a workflow");
+ await waitFor(() => expect(postStreaming).toHaveBeenCalledTimes(1));
+ await deliverFirstFrame();
+
+ await act(async () => {
+ lastStream().onMessage(pendingQuestionFrame());
+ });
+
+ const row = screen.getByTestId("copilot-working-status");
+ expect(row.textContent).toContain("Waiting for you");
+ expect(
+ COPILOT_WORKING_VERBS.some((verb) => row.textContent?.includes(verb)),
+ ).toBe(false);
+
+ // Resolving one question reopens the turn while another is still pending.
+ await act(async () => {
+ lastStream().onMessage(pendingQuestionFrame("qi_2"));
+ lastStream().onMessage({
+ type: "question_resolved",
+ interaction: {
+ ...pendingQuestionFrame().interactions[0],
+ status: "resolved",
+ resolved_at: "2026-01-01T00:00:03Z",
+ },
+ continued: true,
+ });
+ });
+ expect(screen.getByTestId("copilot-working-status").textContent).toContain(
+ "Waiting for you",
+ );
+
+ // The composer is the answer path, so its own status line still shows.
+ view.rerender(
+ chatElement({
+ codeBlockMode: true,
+ requiresLiveBrowser: true,
+ isLiveBrowserReady: false,
+ }),
+ );
+ expect(
+ screen.getByText(
+ "Live browser is starting. Your next send will wait until it connects.",
+ ),
+ ).toBeTruthy();
+ expect(screen.getByTestId("copilot-working-status").textContent).toContain(
+ "Waiting for you",
+ );
+ });
+
+ it("leaves the line empty once a turn ends, whatever the reply said", async () => {
+ await renderChat({ codeBlockMode: true });
+ expect(screen.queryByTestId("copilot-working-status")).toBeNull();
+ await submit("build me a workflow");
+ await waitFor(() => expect(postStreaming).toHaveBeenCalledTimes(1));
+ await deliverFirstFrame();
+
+ await act(async () => {
+ lastStream().onMessage({
+ type: "response",
+ workflow_copilot_chat_id: "chat-1",
+ message: "Done.",
+ updated_workflow: null,
+ response_time: "2026-05-25T00:00:05Z",
+ proposal_disposition: "no_proposal",
+ });
+ lastStream().resolve();
+ });
+ await waitFor(() =>
+ expect(screen.getByRole("button", { name: "Send" })).toBeTruthy(),
+ );
+ expect(screen.queryByTestId("copilot-working-status")).toBeNull();
+ });
+
it("disables the morph button (not a dead-looking Send) while a prompt waits on the live browser", async () => {
await renderChat({
codeBlockMode: true,
diff --git a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsx b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsx
index 6c00b96fa..aa507189e 100644
--- a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsx
+++ b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsx
@@ -139,7 +139,10 @@ import { shouldAutoApplyWorkflowResponse } from "./proposalDisposition";
import { InstantAckPlaceholder, NarrativeView } from "./NarrativeView";
import { CopilotMarkdown } from "./CopilotMarkdown";
import { FeedbackThumbs } from "@/components/feedback/FeedbackThumbs";
-import { CopilotWorkingStatus } from "./CopilotWorkingStatus";
+import {
+ CopilotWorkingStatus,
+ type CopilotComposerStatus,
+} from "./CopilotWorkingStatus";
import { QueuedMessageStrip } from "./QueuedMessageStrip";
import {
RecordingRefinementProgressCard,
@@ -438,9 +441,6 @@ const STOP_UNCONFIRMED_NOTICE =
const STOP_NOT_SENT_NOTICE =
"I couldn't send the stop. Reload to see what this turn recorded.";
-const STOP_ORBIT_GRADIENT =
- "conic-gradient(from 0deg, rgba(120,170,255,.08) 0deg, rgba(120,170,255,.08) 120deg, rgba(150,195,255,.55) 250deg, #dbeaff 330deg, rgba(120,170,255,.08) 360deg)";
-
function parseServerStamp(createdAt: string): number {
const stamp = /(Z|[+-]\d{2}:?\d{2})$/.test(createdAt)
? createdAt
@@ -8746,6 +8746,12 @@ export function WorkflowCopilotChat({
// other Copilot turn: its receipt stays in the transcript while the existing
// working row reports that the turn is still live.
const showWorkingRow = isLoading;
+ // A pending question outranks a live turn, as it does in the session pill.
+ const composerStatus: CopilotComposerStatus | null = hasPendingQuestion
+ ? "waiting"
+ : showWorkingRow
+ ? "working"
+ : null;
// A live_browser-reason queued prompt parks with no active turn to stop, so
// an empty composer's morph button would render as a guaranteed no-op "Send".
// With text typed it does act — it adds to the parked prompt.
@@ -8764,13 +8770,18 @@ export function WorkflowCopilotChat({
const turnPendingFirstFrame =
isLoading && !turnObservablyRunning && narrative.terminal === null;
const morphButtonPending = turnPendingFirstFrame && !hasComposerText;
+ const morphButtonStarting =
+ morphButtonPending &&
+ !authoringBlocksComposerAction &&
+ !isStopping &&
+ !waitingOnQueueOnly;
const morphButtonLabel = authoringBlocksComposerAction
? "Send disabled — finish the current authoring action"
: isStopping
? "Stopping…"
: waitingOnQueueOnly
? "Send disabled — waiting for live browser"
- : morphButtonPending
+ : morphButtonStarting
? "Starting…"
: queuedPrompt && hasComposerText
? queuedPrompt.origin === "typed"
@@ -9773,10 +9784,13 @@ export function WorkflowCopilotChat({
) : null}
</div>
) : null}
- {showWorkingRow ? (
- <CopilotWorkingStatus queued={Boolean(queuedPrompt)} />
+ {composerStatus ? (
+ <CopilotWorkingStatus
+ status={composerStatus}
+ queued={Boolean(queuedPrompt)}
+ />
) : null}
- {inputStatusText && !showWorkingRow ? (
+ {inputStatusText && composerStatus !== "working" ? (
<div
className="mb-2 text-xs text-muted-foreground"
aria-live="polite"
@@ -9852,7 +9866,7 @@ export function WorkflowCopilotChat({
</div>
) : null}
<span className="sr-only" aria-live="polite">
- {queuedPrompt && !showWorkingRow ? "Message queued" : ""}
+ {queuedPrompt && composerStatus !== "working" ? "Message queued" : ""}
</span>
{showQueuedStrip && queuedPrompt ? (
<QueuedMessageStrip
@@ -10003,39 +10017,23 @@ export function WorkflowCopilotChat({
: handleSend()
}
aria-label={morphButtonLabel}
- className={cn(
- "group/stop relative flex h-9 w-9 shrink-0 items-center justify-center overflow-hidden rounded-lg transition focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.92] disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
- showsStopGlyph
- ? "bg-slate-elevation3"
- : "bg-cta text-cta-foreground hover:bg-cta-hover",
- )}
+ className="relative flex h-9 w-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-cta text-cta-foreground transition hover:bg-cta-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.92] disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50"
>
+ {showsStopGlyph || morphButtonStarting ? (
+ <span
+ aria-hidden
+ data-testid="copilot-stop-ring"
+ className={cn(
+ "absolute h-[22px] w-[22px] animate-spin rounded-full border-2 border-[color-mix(in_srgb,currentColor_20%,transparent)] border-t-current motion-reduce:animate-none",
+ isStopping && "paused",
+ )}
+ />
+ ) : null}
{showsStopGlyph ? (
- <>
- <span
- aria-hidden
- data-testid="copilot-stop-orbit"
- className={cn(
- "absolute -inset-[50%] animate-copilot-stop-orbit motion-reduce:hidden",
- isStopping && "paused",
- )}
- style={{
- background: STOP_ORBIT_GRADIENT,
- filter: "blur(1.5px)",
- willChange: "transform",
- }}
- />
- <span
- aria-hidden
- className="absolute inset-0 hidden bg-[rgba(150,195,255,0.55)] motion-reduce:block"
- />
- <span
- aria-hidden
- className="absolute inset-[2px] flex items-center justify-center rounded-md bg-slate-elevation3 transition-colors group-hover/stop:bg-slate-elevation5"
- >
- <span className="h-[11.5px] w-[11.5px] rounded-[2.3px] bg-foreground" />
- </span>
- </>
+ <span
+ aria-hidden
+ className="h-2 w-2 rounded-[1.5px] bg-current"
+ />
) : (
<ArrowUpIcon className="h-4 w-4" />
)}
diff --git a/skyvern-frontend/tailwind.config.js b/skyvern-frontend/tailwind.config.js
index 3a4c58d3e..39813c613 100644
--- a/skyvern-frontend/tailwind.config.js
+++ b/skyvern-frontend/tailwind.config.js
@@ -138,12 +138,9 @@ export default {
},
to: { height: "0", opacity: "0" },
},
- "copilot-stop-orbit": {
- to: { transform: "rotate(1turn)" },
- },
- "copilot-verb-shimmer": {
- from: { backgroundPosition: "180% 0" },
- to: { backgroundPosition: "-80% 0" },
+ "copilot-sparkle-breathe": {
+ "0%, 100%": { transform: "scale(0.8) rotate(0deg)", opacity: "0.6" },
+ "50%": { transform: "scale(1) rotate(90deg)", opacity: "1" },
},
glow: {
"0%, 100%": { boxShadow: "0 0 8px 2px rgba(234, 179, 8, 0.3)" },
@@ -172,8 +169,8 @@ export default {
"collapsible-down-fade 0.22s cubic-bezier(0.22, 1, 0.36, 1)",
"collapsible-up-fade":
"collapsible-up-fade 0.22s cubic-bezier(0.22, 1, 0.36, 1)",
- "copilot-stop-orbit": "copilot-stop-orbit 3s linear infinite",
- "copilot-verb-shimmer": "copilot-verb-shimmer 2.4s linear infinite",
+ "copilot-sparkle-breathe":
+ "copilot-sparkle-breathe 2.8s ease-in-out infinite",
glow: "glow 2.5s ease-in-out infinite",
"analytics-pulse": "analytics-pulse-ring 0.6s ease-out 1",
"copilot-row-flash-success": "copilot-row-flash-success 0.6s ease-out",
diff --git a/skyvern/forge/sdk/copilot/tools/run_execution.py b/skyvern/forge/sdk/copilot/tools/run_execution.py
index 5fd6e10db..1a448d959 100644
--- a/skyvern/forge/sdk/copilot/tools/run_execution.py
+++ b/skyvern/forge/sdk/copilot/tools/run_execution.py
@@ -3595,6 +3595,7 @@ async def _run_blocks_and_collect_debug(
# returns None (no routing hint); cloud returns the value its executor routes to -ui.
trigger_type=(app.AGENT_FUNCTION.resolve_copilot_dispatch_trigger_type() if dispatch_to_worker else None),
copilot_session_id=ctx.workflow_copilot_chat_id,
+ created_by="copilot",
)
if explicit_blank and workflow_run.browser_session_id != run_session_id:
await app.WORKFLOW_SERVICE.mark_workflow_run_as_failed_if_not_final(
diff --git a/skyvern/forge/sdk/db/models.py b/skyvern/forge/sdk/db/models.py
index b43ec0afe..dccceb273 100644
--- a/skyvern/forge/sdk/db/models.py
+++ b/skyvern/forge/sdk/db/models.py
@@ -949,6 +949,7 @@ class WorkflowRunModel(Base):
# the pin, and the gates resolve the flag as before.
secure_runner_pinned = Column(Boolean, nullable=True)
copilot_session_id = Column(String, nullable=True)
+ created_by = Column(String, nullable=True)
# Internal Apply admission decision; NULL retains legacy pricing lookup behavior.
billing_exempt_at_admission = Column(Boolean, nullable=True)
diff --git a/skyvern/forge/sdk/db/repositories/workflow_runs.py b/skyvern/forge/sdk/db/repositories/workflow_runs.py
index 91d0f08d9..fb7bc8fc7 100644
--- a/skyvern/forge/sdk/db/repositories/workflow_runs.py
+++ b/skyvern/forge/sdk/db/repositories/workflow_runs.py
@@ -35,7 +35,7 @@ from sqlalchemy.dialects.postgresql import JSONB
from sqlalchemy.exc import IntegrityError, SQLAlchemyError
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.ext.compiler import compiles
-from sqlalchemy.orm import load_only
+from sqlalchemy.orm import aliased, load_only
from sqlalchemy.sql.compiler import SQLCompiler
from sqlalchemy.sql.selectable import Join
@@ -60,6 +60,7 @@ from skyvern.forge.sdk.db.models import (
StepModel,
TaskModel,
TaskRunModel,
+ TaskV2Model,
WorkflowModel,
WorkflowParameterModel,
WorkflowRunAttemptModel,
@@ -840,6 +841,7 @@ class WorkflowRunsRepository(BaseRepository):
ignore_inherited_workflow_system_prompt: bool = False,
copilot_session_id: str | None = None,
start_fresh_browser: bool | None = None,
+ created_by: str | None = None,
) -> WorkflowRun:
async with self.Session() as session:
kwargs: dict[str, Any] = {}
@@ -878,6 +880,7 @@ class WorkflowRunsRepository(BaseRepository):
fallback_attempt=fallback_attempt,
ignore_inherited_workflow_system_prompt=ignore_inherited_workflow_system_prompt,
copilot_session_id=copilot_session_id,
+ created_by=created_by,
**kwargs,
)
session.add(workflow_run)
@@ -1587,6 +1590,19 @@ class WorkflowRunsRepository(BaseRepository):
WorkflowRunModel.workflow_permanent_id,
)
workflow_deleted_expr = self._workflow_deleted_expr(effective_wpid, TaskRunModel.organization_id)
+ # A task v2 row's run_id is the task v2 id, so its creator lives on the task's own workflow run.
+ task_v2_workflow_run = aliased(WorkflowRunModel)
+ task_v2_created_by = (
+ select(task_v2_workflow_run.created_by)
+ .join(TaskV2Model, TaskV2Model.workflow_run_id == task_v2_workflow_run.workflow_run_id)
+ .where(TaskV2Model.observer_cruise_id == TaskRunModel.run_id)
+ .where(TaskV2Model.organization_id == TaskRunModel.organization_id)
+ .scalar_subquery()
+ )
+ created_by_expr = case(
+ (TaskRunModel.task_run_type == RunType.task_v2, task_v2_created_by),
+ else_=WorkflowRunModel.created_by,
+ )
query = (
select(
TaskRunModel.task_run_id.label("task_run_id"),
@@ -1601,6 +1617,7 @@ class WorkflowRunsRepository(BaseRepository):
effective_wpid.label("workflow_permanent_id"),
TaskRunModel.script_run.label("script_run"),
WorkflowRunModel.trigger_type.label("trigger_type"),
+ created_by_expr.label("created_by"),
TaskRunModel.searchable_text.label("searchable_text"),
workflow_deleted_expr,
)
@@ -1688,6 +1705,7 @@ class WorkflowRunsRepository(BaseRepository):
WorkflowRunModel.workflow_permanent_id.label("workflow_permanent_id"),
WorkflowRunModel.script_run.label("script_run"),
WorkflowRunModel.trigger_type.label("trigger_type"),
+ WorkflowRunModel.created_by.label("created_by"),
WorkflowModel.title.label("searchable_text"),
self._workflow_deleted_expr(
WorkflowRunModel.workflow_permanent_id,
diff --git a/skyvern/forge/sdk/db/utils.py b/skyvern/forge/sdk/db/utils.py
index 023ac1d06..aad2f7947 100644
--- a/skyvern/forge/sdk/db/utils.py
+++ b/skyvern/forge/sdk/db/utils.py
@@ -734,6 +734,7 @@ def convert_to_workflow_run(
failure_category=workflow_run_model.failure_category,
ignore_inherited_workflow_system_prompt=workflow_run_model.ignore_inherited_workflow_system_prompt,
copilot_session_id=workflow_run_model.copilot_session_id,
+ created_by=workflow_run_model.created_by,
credits_used=workflow_run_model.credits_used or 0,
cached_credits_used=workflow_run_model.cached_credits_used or 0,
)
diff --git a/skyvern/forge/sdk/routes/agent_protocol.py b/skyvern/forge/sdk/routes/agent_protocol.py
index c5a6b2c8c..553839f0d 100644
--- a/skyvern/forge/sdk/routes/agent_protocol.py
+++ b/skyvern/forge/sdk/routes/agent_protocol.py
@@ -315,6 +315,7 @@ async def run_task(
background_tasks: BackgroundTasks,
run_request: TaskRunRequest,
caller: org_auth_service.CallerContext = Depends(org_auth_service.get_current_caller_context),
+ user_id: str | None = Depends(org_auth_service.get_current_user_id_or_none),
x_api_key: Annotated[str | None, Header()] = None,
x_user_agent: Annotated[str | None, Header()] = None,
) -> TaskRunResponse:
@@ -513,6 +514,7 @@ async def run_task(
start_fresh_browser=run_request.start_fresh_browser,
browser_address=run_request.browser_address,
run_with=run_request.run_with,
+ created_by=user_id,
)
except task_v2_service.InvalidTaskV2ModelError as e:
raise HTTPException(status_code=400, detail=str(e)) from e
@@ -667,6 +669,7 @@ async def run_workflow(
background_tasks: BackgroundTasks,
workflow_run_request: WorkflowRunRequest,
caller: org_auth_service.CallerContext = Depends(org_auth_service.get_current_caller_context),
+ user_id: str | None = Depends(org_auth_service.get_current_user_id_or_none),
template: bool = Query(False),
x_api_key: Annotated[str | None, Header()] = None,
x_max_steps_override: Annotated[int | None, Header()] = None,
@@ -701,6 +704,7 @@ async def run_workflow(
background_tasks=background_tasks,
trigger_type=trigger_type,
tag_write_context=_tag_write_context_from_caller(caller),
+ created_by=user_id,
)
except MissingBrowserAddressError as e:
raise HTTPException(status_code=400, detail=str(e)) from e
@@ -3521,6 +3525,8 @@ async def run_block(
block_run_request: BlockRunRequest,
organization: Organization = Depends(org_auth_service.get_current_org),
user_id: str = Depends(org_auth_service.get_current_user_id),
+ # user_id is not checked against the api-key org; attribution only records verified members.
+ created_by: str | None = Depends(org_auth_service.get_current_user_id_or_none),
template: bool = Query(False),
x_api_key: Annotated[str | None, Header()] = None,
x_user_agent: Annotated[str | None, Header()] = None,
@@ -3551,6 +3557,7 @@ async def run_block(
workflow_permanent_id=block_run_request.workflow_id,
block_run_request=block_run_request,
trigger_type=block_trigger_type,
+ created_by=created_by,
)
browser_session_id = workflow_run.browser_session_id
@@ -3907,6 +3914,7 @@ async def retry_workflow_run(
background_tasks: BackgroundTasks,
workflow_run_id: str = Path(..., description="The id of the workflow run to retry.", examples=["wr_123"]),
caller: org_auth_service.CallerContext = Depends(org_auth_service.get_current_caller_context),
+ user_id: str | None = Depends(org_auth_service.get_current_user_id_or_none),
x_api_key: Annotated[str | None, Header()] = None,
x_max_steps_override: Annotated[int | None, Header()] = None,
x_user_agent: Annotated[str | None, Header()] = None,
@@ -4009,6 +4017,7 @@ async def retry_workflow_run(
trigger_type=trigger_type,
ignore_inherited_workflow_system_prompt=original_workflow_run.ignore_inherited_workflow_system_prompt,
tag_write_context=_tag_write_context_from_caller(caller),
+ created_by=user_id,
)
except MissingBrowserAddressError as e:
raise HTTPException(status_code=400, detail=str(e)) from e
@@ -4588,6 +4597,7 @@ async def run_workflow_legacy(
workflow_request: WorkflowRequestBody,
version: int | None = None,
caller: org_auth_service.CallerContext = Depends(org_auth_service.get_current_caller_context),
+ user_id: str | None = Depends(org_auth_service.get_current_user_id_or_none),
template: bool = Query(False),
x_api_key: Annotated[str | None, Header()] = None,
x_max_steps_override: Annotated[int | None, Header()] = None,
@@ -4622,6 +4632,7 @@ async def run_workflow_legacy(
background_tasks=background_tasks,
trigger_type=legacy_trigger_type,
tag_write_context=_tag_write_context_from_caller(caller),
+ created_by=user_id,
)
except MissingBrowserAddressError as e:
raise HTTPException(status_code=400, detail=str(e)) from e
@@ -5841,6 +5852,7 @@ async def run_task_v2(
background_tasks: BackgroundTasks,
data: TaskV2Request,
caller: org_auth_service.CallerContext = Depends(org_auth_service.get_current_caller_context),
+ user_id: str | None = Depends(org_auth_service.get_current_user_id_or_none),
x_max_iterations_override: Annotated[int | str | None, Header()] = None,
x_max_steps_override: Annotated[int | str | None, Header()] = None,
x_user_agent: Annotated[str | None, Header()] = None,
@@ -5879,6 +5891,7 @@ async def run_task_v2(
model=data.model,
run_with=data.run_with,
trigger_type=legacy_v2_trigger_type,
+ created_by=user_id,
)
except task_v2_service.InvalidTaskV2ModelError as e:
raise HTTPException(status_code=400, detail=str(e)) from e
diff --git a/skyvern/forge/sdk/routes/credentials.py b/skyvern/forge/sdk/routes/credentials.py
index af761dd08..1aa1c47fc 100644
--- a/skyvern/forge/sdk/routes/credentials.py
+++ b/skyvern/forge/sdk/routes/credentials.py
@@ -1090,6 +1090,7 @@ async def test_login(
organization=current_org,
max_steps_override=None,
trigger_type=workflow_run_trigger_type_from_user_agent(x_user_agent),
+ created_by=current_user_id,
)
await AsyncExecutorFactory.get_executor().execute_workflow(
@@ -1186,6 +1187,7 @@ async def test_credential(
description="Test configuration including the login URL",
),
current_org: Organization = Depends(org_auth_service.get_current_org_for_credential_routes),
+ current_user_id: str | None = Depends(org_auth_service.get_current_user_id_or_none),
x_user_agent: Annotated[str | None, Header()] = None,
) -> TestCredentialResponse:
organization_id = current_org.organization_id
@@ -1285,6 +1287,7 @@ async def test_credential(
organization=current_org,
max_steps_override=None,
trigger_type=workflow_run_trigger_type_from_user_agent(x_user_agent),
+ created_by=current_user_id,
)
await AsyncExecutorFactory.get_executor().execute_workflow(
diff --git a/skyvern/forge/sdk/routes/run_blocks.py b/skyvern/forge/sdk/routes/run_blocks.py
index ca206cd37..e466f04da 100644
--- a/skyvern/forge/sdk/routes/run_blocks.py
+++ b/skyvern/forge/sdk/routes/run_blocks.py
@@ -68,6 +68,7 @@ async def _run_workflow_and_build_response(
caller_type: CallerType,
x_api_key: str | None,
x_user_agent: str | None = None,
+ created_by: str | None = None,
) -> WorkflowRunResponse:
context = skyvern_context.ensure_context()
request_id = context.request_id
@@ -97,6 +98,7 @@ async def _run_workflow_and_build_response(
request=request,
background_tasks=background_tasks,
trigger_type=trigger_type,
+ created_by=created_by,
)
except MissingBrowserAddressError as e:
raise HTTPException(status_code=400, detail=str(e)) from e
@@ -165,6 +167,7 @@ async def login(
background_tasks: BackgroundTasks,
login_request: LoginRequest,
caller: org_auth_service.CallerContext = Depends(org_auth_service.get_current_caller_context),
+ user_id: str | None = Depends(org_auth_service.get_current_user_id_or_none),
x_api_key: Annotated[str | None, Header()] = None,
x_user_agent: Annotated[str | None, Header()] = None,
) -> WorkflowRunResponse:
@@ -312,6 +315,7 @@ async def login(
x_api_key=x_api_key,
x_user_agent=x_user_agent,
caller_type=caller.caller_type,
+ created_by=user_id,
)
@@ -340,6 +344,7 @@ async def download_files(
background_tasks: BackgroundTasks,
download_files_request: DownloadFilesRequest,
caller: org_auth_service.CallerContext = Depends(org_auth_service.get_current_caller_context),
+ user_id: str | None = Depends(org_auth_service.get_current_user_id_or_none),
x_api_key: Annotated[str | None, Header()] = None,
x_user_agent: Annotated[str | None, Header()] = None,
) -> WorkflowRunResponse:
@@ -413,4 +418,5 @@ async def download_files(
x_api_key=x_api_key,
x_user_agent=x_user_agent,
caller_type=caller.caller_type,
+ created_by=user_id,
)
diff --git a/skyvern/forge/sdk/routes/sdk.py b/skyvern/forge/sdk/routes/sdk.py
index b33655a6b..9a3083bbd 100644
--- a/skyvern/forge/sdk/routes/sdk.py
+++ b/skyvern/forge/sdk/routes/sdk.py
@@ -75,17 +75,19 @@ def _release_sdk_action_context(workflow_run_id: str) -> bool:
async def run_sdk_action(
action_request: RunSdkActionRequest,
organization: Organization = Depends(org_auth_service.get_current_org),
+ user_id: str | None = Depends(org_auth_service.get_current_user_id_or_none),
) -> RunSdkActionResponse:
"""Execute a single SDK action with the specified parameters."""
# The whole action runs on this process's event loop, so the cap is taken before any database
# write or page work: an organization over its cap costs a rejected request, not a started one.
async with app.RATE_LIMITER.limit_sdk_action_concurrency(organization.organization_id):
- return await _run_sdk_action(action_request, organization)
+ return await _run_sdk_action(action_request, organization, created_by=user_id)
async def _run_sdk_action(
action_request: RunSdkActionRequest,
organization: Organization,
+ created_by: str | None = None,
) -> RunSdkActionResponse:
LOG.info(
"Running SDK action",
@@ -136,6 +138,7 @@ async def _run_sdk_action(
organization=organization,
version=None,
trigger_type=WorkflowRunTriggerType.api,
+ created_by=created_by,
)
task_type = TaskType.synthetic_sdk_action
diff --git a/skyvern/forge/sdk/workflow/models/workflow.py b/skyvern/forge/sdk/workflow/models/workflow.py
index 7a05c0082..8d529c0da 100644
--- a/skyvern/forge/sdk/workflow/models/workflow.py
+++ b/skyvern/forge/sdk/workflow/models/workflow.py
@@ -386,6 +386,7 @@ class WorkflowRun(BaseModel):
workflow_schedule_id: str | None = None
ignore_inherited_workflow_system_prompt: bool = False
copilot_session_id: str | None = None
+ created_by: str | None = Field(default=None, description="ID of the user who started the run")
credits_used: int = 0
cached_credits_used: int = 0
diff --git a/skyvern/forge/sdk/workflow/service.py b/skyvern/forge/sdk/workflow/service.py
index 763728d09..1fc9e224a 100644
--- a/skyvern/forge/sdk/workflow/service.py
+++ b/skyvern/forge/sdk/workflow/service.py
@@ -3303,6 +3303,7 @@ class WorkflowService:
block_scoped: bool = False,
shares_parent_browser: bool = False,
server_owned_browser_type: str | None = None,
+ created_by: str | None = None,
) -> WorkflowRun:
"""
Create a workflow run and its parameters. Validate the workflow and the organization. If there are missing
@@ -3443,6 +3444,7 @@ class WorkflowService:
copilot_session_id=resolved_copilot_session_id,
workflow=workflow,
block_scoped=block_scoped,
+ created_by=created_by,
)
try:
await self._apply_initial_run_metadata_tags(
@@ -11318,6 +11320,7 @@ class WorkflowService:
copilot_session_id: str | None = None,
workflow: Workflow | None = None,
block_scoped: bool = False,
+ created_by: str | None = None,
) -> WorkflowRun:
requested_browser_session_id = workflow_request.browser_session_id
# validate the browser session or profile id
@@ -11438,6 +11441,7 @@ class WorkflowService:
fallback_attempt=fallback_attempt,
ignore_inherited_workflow_system_prompt=ignore_inherited_workflow_system_prompt,
copilot_session_id=copilot_session_id,
+ created_by=created_by,
)
# A block run creates its block-run rows only after setup, so the caller's intent
# is the only block-scoped signal enrolment can see here.
@@ -11511,6 +11515,7 @@ class WorkflowService:
fallback_attempt=fallback_attempt,
ignore_inherited_workflow_system_prompt=ignore_inherited_workflow_system_prompt,
copilot_session_id=copilot_session_id,
+ created_by=created_by,
)
if not block_scoped:
await ensure_attempt_row(
diff --git a/skyvern/schemas/runs.py b/skyvern/schemas/runs.py
index 92029e0c7..881262c0f 100644
--- a/skyvern/schemas/runs.py
+++ b/skyvern/schemas/runs.py
@@ -864,6 +864,7 @@ class TaskRunListItem(BaseModel):
workflow_deleted: bool = False
script_run: bool = False
trigger_type: WorkflowRunTriggerType | None = None
+ created_by: str | None = Field(default=None, description="ID of the user who started the run")
searchable_text: str | None = Field(default=None, exclude=True)
@field_validator("script_run", mode="before")
diff --git a/skyvern/services/block_service.py b/skyvern/services/block_service.py
index ab8168295..140ab140b 100644
--- a/skyvern/services/block_service.py
+++ b/skyvern/services/block_service.py
@@ -51,6 +51,7 @@ async def ensure_workflow_run(
block_run_request: BlockRunRequest,
x_max_steps_override: int | None = None,
trigger_type: WorkflowRunTriggerType | None = None,
+ created_by: str | None = None,
) -> WorkflowRun:
context = skyvern_context.ensure_context()
@@ -93,6 +94,7 @@ async def ensure_workflow_run(
code_gen=block_run_request.code_gen,
trigger_type=trigger_type,
block_scoped=True,
+ created_by=created_by,
)
return workflow_run
diff --git a/skyvern/services/task_v2_service.py b/skyvern/services/task_v2_service.py
index 6bc1f4652..7e9e68f87 100644
--- a/skyvern/services/task_v2_service.py
+++ b/skyvern/services/task_v2_service.py
@@ -338,6 +338,7 @@ async def initialize_task_v2(
browser_address: str | None = None,
run_with: str | None = None,
trigger_type: WorkflowRunTriggerType | None = None,
+ created_by: str | None = None,
) -> TaskV2:
await _validate_task_v2_model_for_org(organization, model)
if user_url:
@@ -400,6 +401,7 @@ async def initialize_task_v2(
max_steps_override=max_steps_override,
parent_workflow_run_id=parent_workflow_run_id,
trigger_type=trigger_type,
+ created_by=created_by,
)
except Exception:
LOG.error("Failed to setup cruise workflow run", exc_info=True)
diff --git a/skyvern/services/workflow_service.py b/skyvern/services/workflow_service.py
index ed74e0257..6d41bb1fb 100644
--- a/skyvern/services/workflow_service.py
+++ b/skyvern/services/workflow_service.py
@@ -105,6 +105,7 @@ async def prepare_workflow(
resolved_workflow_id: str | None = None,
tag_write_context: TagWriteContext | None = None,
block_scoped: bool = False,
+ created_by: str | None = None,
) -> WorkflowRun:
"""
Prepare a workflow to be run.
@@ -137,6 +138,7 @@ async def prepare_workflow(
resolved_workflow_id=resolved_workflow_id,
tag_write_context=tag_write_context,
block_scoped=block_scoped,
+ created_by=created_by,
)
if resolved_workflow_id is not None:
@@ -188,6 +190,7 @@ async def run_workflow(
fallback_attempt: int | None = None,
ignore_inherited_workflow_system_prompt: bool = False,
tag_write_context: TagWriteContext | None = None,
+ created_by: str | None = None,
) -> WorkflowRun:
# Fail fast before the run is prepared/persisted: reject a run-level browser_type this runtime
# cannot honor with a 4xx, rather than accepting it and failing at launch. No-op when unset or on
@@ -211,6 +214,7 @@ async def run_workflow(
fallback_attempt=fallback_attempt,
ignore_inherited_workflow_system_prompt=ignore_inherited_workflow_system_prompt,
tag_write_context=tag_write_context,
+ created_by=created_by,
)
await AsyncExecutorFactory.get_executor().execute_workflow(
diff --git a/tests/unit/forge/sdk/db/test_workflow_runs_repository.py b/tests/unit/forge/sdk/db/test_workflow_runs_repository.py
index dcd035d14..e536849a0 100644
--- a/tests/unit/forge/sdk/db/test_workflow_runs_repository.py
+++ b/tests/unit/forge/sdk/db/test_workflow_runs_repository.py
@@ -37,6 +37,7 @@ from skyvern.forge.sdk.db.models import (
PersistentBrowserSessionModel,
TaskModel,
TaskRunModel,
+ TaskV2Model,
WorkflowModel,
WorkflowRunAttemptModel,
WorkflowRunBlockModel,
@@ -3928,3 +3929,45 @@ async def test_recovery_paginates_stale_undecided_terminal_runs(sqlite_db: Agent
*((f"wr_undecided_{index}", 1) for index in range(1, 5)),
("wr_undecided_7", 1),
]
+
+
+async def test_get_all_runs_v2_returns_creator_for_workflow_and_task_v2_rows(sqlite_db: AgentDB) -> None:
+ now = datetime.now(tz=timezone.utc)
+ async with sqlite_db.Session() as session:
+ session.add_all(
+ [
+ WorkflowRunModel(
+ workflow_run_id="wr_member",
+ workflow_id="w_member",
+ workflow_permanent_id="wpid_member",
+ organization_id="org_test",
+ status="completed",
+ created_by="user_member",
+ ),
+ WorkflowRunModel(
+ workflow_run_id="wr_task_v2",
+ workflow_id="w_task_v2",
+ workflow_permanent_id="wpid_task_v2",
+ organization_id="org_test",
+ status="completed",
+ created_by="user_prompter",
+ ),
+ TaskV2Model(observer_cruise_id="tsk_v2_1", organization_id="org_test", workflow_run_id="wr_task_v2"),
+ _task_run_model(run_id="wr_member", created_at=now, workflow_permanent_id="wpid_member"),
+ _task_run_model(
+ run_id="tsk_v2_1",
+ created_at=now - timedelta(seconds=1),
+ workflow_permanent_id=None,
+ task_run_type=RunType.task_v2.value,
+ ),
+ ]
+ )
+ await session.commit()
+
+ rows = await sqlite_db.workflow_runs.get_all_runs_v2(organization_id="org_test")
+
+ assert {row["run_id"]: row["created_by"] for row in rows} == {
+ "wr_member": "user_member",
+ "tsk_v2_1": "user_prompter",
+ }
diff --git a/tests/unit/test_runs_v2_route.py b/tests/unit/test_runs_v2_route.py
index d6ee095c4..c40a353ff 100644
--- a/tests/unit/test_runs_v2_route.py
+++ b/tests/unit/test_runs_v2_route.py
@@ -1,18 +1,30 @@
+from collections.abc import AsyncIterator, Awaitable, Callable
+from dataclasses import dataclass
from datetime import UTC, datetime, timedelta, timezone
from types import SimpleNamespace
from typing import Any
from unittest.mock import AsyncMock, MagicMock, call
+import httpx
import orjson
import pytest
-from fastapi import BackgroundTasks, HTTPException
+import pytest_asyncio
+from fastapi import BackgroundTasks, FastAPI, HTTPException, Request, Response
+from sqlalchemy.ext.asyncio import AsyncEngine
from skyvern.constants import SKYVERN_MCP_USER_AGENT, SKYVERN_UI_USER_AGENT
from skyvern.exceptions import WorkflowNotFound
+from skyvern.forge.sdk.core import skyvern_context
+from skyvern.forge.sdk.core.skyvern_context import SkyvernContext
+from skyvern.forge.sdk.db.agent_db import AgentDB
from skyvern.forge.sdk.db.enums import WorkflowRunTriggerType
-from skyvern.forge.sdk.db.models import WorkflowRunAttemptModel
+from skyvern.forge.sdk.db.models import WorkflowModel, WorkflowRunAttemptModel
+from skyvern.forge.sdk.executor.factory import AsyncExecutorFactory
from skyvern.forge.sdk.routes import agent_protocol
+from skyvern.forge.sdk.routes.routers import base_router, legacy_base_router
+from skyvern.forge.sdk.schemas.organizations import Organization
from skyvern.forge.sdk.schemas.tasks import Task, TaskStatus
+from skyvern.forge.sdk.services import org_auth_service
from skyvern.forge.sdk.workflow.models.tags import CallerType, TagSource
from skyvern.forge.sdk.workflow.models.workflow import WorkflowRequestBody, WorkflowRun, WorkflowRunStatus
from skyvern.forge.sdk.workflow.service import WorkflowService
@@ -193,6 +205,7 @@ async def test_get_runs_v2_serializes_mapping_rows_from_database(monkeypatch: py
"workflow_deleted": False,
"script_run": False,
"trigger_type": "mcp",
+ "created_by": None,
"attempt": 1,
"retry_pending": False,
"next_attempt_at": None,
@@ -992,3 +1005,109 @@ async def test_legacy_task_routes_schedule_run_created_hook(monkeypatch: pytest.
caller_type=CallerType.API_KEY,
),
]
+
+
+@dataclass
+class _CreatorHarness:
+ client: httpx.AsyncClient
+ db: AgentDB
+ current_user: dict[str, str]
+
+
+@pytest_asyncio.fixture
+async def creator_harness(
+ monkeypatch: pytest.MonkeyPatch, sqlite_engine: AsyncEngine
+) -> AsyncIterator[_CreatorHarness]:
+ db = AgentDB("sqlite+aiosqlite://", db_engine=sqlite_engine)
+ now = datetime.now(UTC)
+ organization = Organization(
+ organization_id="o_creator", organization_name="Creator Org", created_at=now, modified_at=now
+ )
+ async with db.Session() as session:
+ session.add(
+ WorkflowModel(
+ workflow_id="w_creator",
+ workflow_permanent_id="wpid_creator",
+ organization_id=organization.organization_id,
+ title="Creator Workflow",
+ workflow_definition={"blocks": [], "parameters": []},
+ status="published",
+ version=1,
+ )
+ )
+ await session.commit()
+
+ app_instance = object.__getattribute__(agent_protocol.app, "_inst")
+ monkeypatch.setattr(app_instance, "DATABASE", db)
+ monkeypatch.setattr(app_instance, "WORKFLOW_SERVICE", WorkflowService())
+ monkeypatch.setattr(app_instance, "RATE_LIMITER", SimpleNamespace(rate_limit_submit_run=AsyncMock()), raising=False)
+ monkeypatch.setattr(
+ app_instance,
+ "EXPERIMENTATION_PROVIDER",
+ SimpleNamespace(is_feature_enabled_cached=AsyncMock(return_value=False)),
+ raising=False,
+ )
+ executor = SimpleNamespace(execute_workflow=AsyncMock(), execute_task_v2=AsyncMock())
+ monkeypatch.setattr(AsyncExecutorFactory, "get_executor", lambda: executor)
+
+ current_user = {"id": "user_member"}
+ fastapi_app = FastAPI()
+ fastapi_app.include_router(base_router, prefix="/v1")
+ fastapi_app.include_router(legacy_base_router, prefix="/api/v1")
+ fastapi_app.dependency_overrides[org_auth_service.get_current_caller_context] = lambda: SimpleNamespace(
+ organization=organization, caller_id=current_user["id"], caller_type=CallerType.USER
+ )
+ fastapi_app.dependency_overrides[org_auth_service.get_current_org] = lambda: organization
+ fastapi_app.dependency_overrides[org_auth_service.get_current_user_id_or_none] = lambda: current_user["id"]
+
+ @fastapi_app.middleware("http")
+ async def _request_context(request: Request, call_next: Callable[[Request], Awaitable[Response]]) -> Response:
+ skyvern_context.set(SkyvernContext(request_id="req_creator"))
+ try:
+ return await call_next(request)
+ finally:
+ skyvern_context.reset()
+
+ async with httpx.AsyncClient(transport=httpx.ASGITransport(app=fastapi_app), base_url="http://test") as client:
+ yield _CreatorHarness(client=client, db=db, current_user=current_user)
+
+
+async def _list_creators(client: httpx.AsyncClient) -> dict[str, str | None]:
+ response = await client.get("/v1/runs")
+ assert response.status_code == 200, response.text
+ return {row["run_id"]: row["created_by"] for row in response.json()}
+
+
+ ("path", "body", "run_id_key"),
+ [
+ ("/api/v1/workflows/wpid_creator/run", {}, "workflow_run_id"),
+ ("/v1/run/agents", {"workflow_id": "wpid_creator"}, "run_id"),
+ ("/v1/run/tasks", {"prompt": "Find the pricing page", "engine": "skyvern-2.0"}, "run_id"),
+ ],
+)
+async def test_run_records_creator_and_runs_list_returns_it(
+ creator_harness: _CreatorHarness, path: str, body: dict[str, Any], run_id_key: str
+) -> None:
+ response = await creator_harness.client.post(path, json=body, headers={"x-user-agent": SKYVERN_UI_USER_AGENT})
+ assert response.status_code == 200, response.text
+
+ assert await _list_creators(creator_harness.client) == {response.json()[run_id_key]: "user_member"}
+
+
+async def test_retry_records_the_retrying_user_as_creator(creator_harness: _CreatorHarness) -> None:
+ client = creator_harness.client
+ original = await client.post("/api/v1/workflows/wpid_creator/run", json={})
+ assert original.status_code == 200, original.text
+ original_run_id = original.json()["workflow_run_id"]
+ await creator_harness.db.workflow_runs.update_workflow_run(
+ workflow_run_id=original_run_id, status=WorkflowRunStatus.failed
+ )
+
+ creator_harness.current_user["id"] = "user_retrier"
+ retry = await client.post(f"/v1/workflows/runs/{original_run_id}/retry")
+ assert retry.status_code == 200, retry.text
+
+ assert await _list_creators(client) == {original_run_id: "user_member", retry.json()["run_id"]: "user_retrier"}
diff --git a/tests/unit/test_saved_session_proxy_pin.py b/tests/unit/test_saved_session_proxy_pin.py
index afbbe53b8..2b483672b 100644
--- a/tests/unit/test_saved_session_proxy_pin.py
+++ b/tests/unit/test_saved_session_proxy_pin.py
@@ -825,6 +825,7 @@ async def test_create_workflow_run_non_force_path_single_create_no_update(monkey
fallback_attempt=None,
ignore_inherited_workflow_system_prompt=False,
copilot_session_id=None,
+ created_by=None,
)
update_workflow_run.assert_not_awaited()