Skip to content

Automate browser based workflows with AI

Match the Azure OpenAI host, not a URL substring (#7898)

Shuchang Zhengf5eb24b47847
diff --git a/pyproject.toml b/pyproject.toml
index f65e7fe32..a19aa9d7e 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -33,7 +33,7 @@ local = [
"aiohttp>=3.13.4,<4",
"python-multipart>=0.0.30,<1",
"toml>=0.10.2,<0.11",
- "jinja2>=3.1.2,<4",
+ "jinja2>=3.1.6,<4",
"litellm>=1.84.0",
"playwright>1.46.0 ; python_version >= '3.12' and python_version < '3.14'",
"playwright==1.46.0 ; python_version >= '3.11' and python_version < '3.12'",
@@ -104,7 +104,7 @@ server = [
"aiohttp>=3.13.4,<4",
"python-multipart>=0.0.30,<1",
"toml>=0.10.2,<0.11",
- "jinja2>=3.1.2,<4",
+ "jinja2>=3.1.6,<4",
"uvicorn[standard]>=0.44.0",
"litellm>=1.84.0",
"playwright>1.46.0 ; python_version >= '3.12' and python_version < '3.14'",
diff --git a/skyvern-frontend/src/components/SelfHealApiKeyBanner.test.tsx b/skyvern-frontend/src/components/SelfHealApiKeyBanner.test.tsx
new file mode 100644
index 000000000..13bf84de1
--- /dev/null
+++ b/skyvern-frontend/src/components/SelfHealApiKeyBanner.test.tsx
@@ -0,0 +1,34 @@
+// @vitest-environment jsdom
+import { cleanup, render, screen } from "@testing-library/react";
+import { afterEach, describe, expect, it, vi } from "vitest";
+
+const { diagnosticsState } = vi.hoisted(() => ({
+ diagnosticsState: {
+ data: { status: "missing_api_key" as const },
+ error: null,
+ isLoading: false,
+ refetch: vi.fn(),
+ },
+}));
+
+vi.mock("@/hooks/useAuthDiagnostics", () => ({
+ useAuthDiagnostics: () => diagnosticsState,
+}));
+
+import { SelfHealApiKeyBanner } from "./SelfHealApiKeyBanner";
+
+afterEach(() => {
+ cleanup();
+ vi.clearAllMocks();
+});
+
+describe("SelfHealApiKeyBanner", () => {
+ it("directs the operator to the CLI without offering browser repair", () => {
+ render(<SelfHealApiKeyBanner />);
+
+ screen.getByText("skyvern doctor --fix");
+ expect(
+ screen.queryByRole("button", { name: "Regenerate API key" }),
+ ).toBeNull();
+ });
+});
diff --git a/skyvern-frontend/src/components/SelfHealApiKeyBanner.tsx b/skyvern-frontend/src/components/SelfHealApiKeyBanner.tsx
index f59bb4461..d03ec2765 100644
--- a/skyvern-frontend/src/components/SelfHealApiKeyBanner.tsx
+++ b/skyvern-frontend/src/components/SelfHealApiKeyBanner.tsx
@@ -1,9 +1,4 @@
-import { useState } from "react";
-
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
-import { Button } from "@/components/ui/button";
-import { useToast } from "@/components/ui/use-toast";
-import { getClient, setApiKeyHeader } from "@/api/AxiosClient";
import {
AuthStatusValue,
useAuthDiagnostics,
@@ -21,31 +16,27 @@ function getCopy(status: BannerStatus): { title: string; description: string } {
return {
title: "Frontend API key missing",
description:
- "The UI is not sending an x-api-key header. The backend server can still run locally, but authenticated requests from the UI will fail until VITE_SKYVERN_API_KEY is set or a runtime key is stored.",
+ "The UI is not sending an x-api-key header. Authenticated requests will fail until local auth is repaired.",
};
case "invalid_format":
return {
title: "Skyvern API key is invalid",
- description:
- "The configured key cannot be decoded. Regenerate a new key to continue using the UI.",
+ description: "The configured key cannot be decoded.",
};
case "invalid":
return {
title: "Skyvern API key not recognized",
- description:
- "The backend rejected the configured key. Regenerate it to refresh local auth.",
+ description: "The backend rejected the configured key.",
};
case "expired":
return {
title: "Skyvern API key expired",
- description:
- "The current key is no longer valid. Generate a fresh key to restore connectivity.",
+ description: "The current key is no longer valid.",
};
case "not_found":
return {
title: "Local organization missing",
- description:
- "The backend could not find the Skyvern-local organization. Regenerate the key to recreate it.",
+ description: "The backend could not find the local organization.",
};
case "request_auth_error":
return {
@@ -66,13 +57,8 @@ function getCopy(status: BannerStatus): { title: string; description: string } {
function SelfHealApiKeyBanner() {
const diagnosticsQuery = useAuthDiagnostics();
const authIssue = useAuthIssueStore((state) => state.issue);
- const clearAuthIssue = useAuthIssueStore((state) => state.clearAuthIssue);
- const { toast } = useToast();
- const [isRepairing, setIsRepairing] = useState(false);
- const [errorMessage, setErrorMessage] = useState<string | null>(null);
- const isProductionBuild = !import.meta.env.DEV;
- const { data, error, isLoading, refetch } = diagnosticsQuery;
+ const { data, error } = diagnosticsQuery;
const rawStatus = data?.status;
const bannerStatus: BannerStatus | null = error
@@ -83,89 +69,13 @@ function SelfHealApiKeyBanner() {
? "request_auth_error"
: null;
- if (!bannerStatus && !errorMessage) {
- if (isLoading) {
- return null;
- }
+ if (!bannerStatus) {
return null;
}
- const copy = getCopy(bannerStatus ?? "missing_api_key");
+ const copy = getCopy(bannerStatus);
const queryErrorMessage = error?.message ?? null;
- const handleRepair = async () => {
- setIsRepairing(true);
- setErrorMessage(null);
- try {
- const client = await getClient(null);
- const response = await client.post<{
- fingerprint?: string;
- api_key?: string;
- backend_env_path?: string;
- frontend_env_path?: string;
- }>("/internal/auth/repair");
-
- const {
- fingerprint,
- api_key: apiKey,
- backend_env_path: backendEnvPath,
- frontend_env_path: frontendEnvPath,
- } = response.data;
-
- if (!apiKey) {
- throw new Error("Repair succeeded but no API key was returned.");
- }
-
- setApiKeyHeader(apiKey);
- clearAuthIssue();
-
- const fingerprintSuffix = fingerprint
- ? ` (fingerprint ${fingerprint})`
- : "";
-
- const pathsElements = [];
- if (backendEnvPath) {
- pathsElements.push(<div key="backend">Backend: {backendEnvPath}</div>);
- }
- if (frontendEnvPath) {
- pathsElements.push(
- <div key="frontend">Frontend: {frontendEnvPath}</div>,
- );
- }
-
- toast({
- title: "API key regenerated",
- description: (
- <div>
- <div>
- Requests now use the updated key automatically{fingerprintSuffix}{" "}
- persisted to sessionStorage and written to the following .env
- paths:
- </div>
- {pathsElements.length > 0 && (
- <div className="mt-2 space-y-2">{pathsElements}</div>
- )}
- {isProductionBuild && (
- <div className="mt-3">
- Restart the UI server for more robust API key persistence.
- </div>
- )}
- </div>
- ),
- });
-
- await refetch({ throwOnError: false });
- } catch (fetchError) {
- const message =
- fetchError instanceof Error
- ? fetchError.message
- : "Unable to repair API key";
- setErrorMessage(message);
- } finally {
- setIsRepairing(false);
- }
- };
-
return (
<div className="px-4 pt-4">
<Alert className="flex flex-col items-center gap-2 border-slate-700 bg-slate-900 text-slate-50">
@@ -176,17 +86,12 @@ function SelfHealApiKeyBanner() {
{bannerStatus !== "error" ? (
<>
<p>
- {copy.description} Update <code>VITE_SKYVERN_API_KEY</code> in{" "}
- <code className="mx-1">skyvern-frontend/.env</code>
- by running <code>skyvern init</code> or click the button below
- to regenerate it automatically.
+ {copy.description} Run <code>skyvern doctor --fix</code> in the
+ project directory, then restart local services if prompted.
</p>
{data?.detail ? (
<p className="text-xs text-slate-300">{data.detail}</p>
) : null}
- {data?.next_step ? (
- <p className="text-xs text-slate-300">{data.next_step}</p>
- ) : null}
{authIssue ? (
<p className="text-xs text-slate-300">
Last failed request: HTTP {authIssue.statusCode}
@@ -194,38 +99,11 @@ function SelfHealApiKeyBanner() {
{authIssue.detail ? ` (${authIssue.detail})` : ""}
</p>
) : null}
- {bannerStatus === "request_auth_error" ? (
- <p className="text-yellow-300">
- Run <code>skyvern doctor --fix</code> from the cloned Skyvern
- directory, then restart Docker Compose if the command asks you
- to.
- </p>
- ) : null}
- {isProductionBuild && (
- <p className="text-yellow-300">
- When running a production build, the regenerated API key is
- stored in sessionStorage. Closing this tab or browser window
- will lose the key. Restart the UI server for more robust
- persistence.
- </p>
- )}
- <div className="flex justify-center">
- <Button
- onClick={handleRepair}
- disabled={isRepairing}
- variant="secondary"
- >
- {isRepairing ? "Regenerating…" : "Regenerate API key"}
- </Button>
- </div>
</>
) : (
<p>{copy.description}</p>
)}
- {errorMessage ? (
- <p className="text-xs text-rose-200">{errorMessage}</p>
- ) : null}
- {queryErrorMessage && !errorMessage ? (
+ {queryErrorMessage ? (
<p className="text-xs text-rose-200">{queryErrorMessage}</p>
) : null}
</AlertDescription>
diff --git a/skyvern-frontend/src/hooks/useAuthDiagnostics.ts b/skyvern-frontend/src/hooks/useAuthDiagnostics.ts
index 0e1345aea..087692865 100644
--- a/skyvern-frontend/src/hooks/useAuthDiagnostics.ts
+++ b/skyvern-frontend/src/hooks/useAuthDiagnostics.ts
@@ -15,10 +15,6 @@ export type AuthDiagnosticsResponse = {
status: AuthStatusValue;
detail?: string;
next_step?: string;
- fingerprint?: string;
- organization_id?: string;
- expires_at?: number;
- api_key?: string;
};
async function fetchDiagnostics(): Promise<AuthDiagnosticsResponse> {
diff --git a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotHistory.tsx b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotHistory.tsx
index 920ecee6c..74f35b1cd 100644
--- a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotHistory.tsx
+++ b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotHistory.tsx
@@ -171,7 +171,7 @@ function WorkflowCopilotHistory({
onMouseDown={(e) => e.stopPropagation()}
className={
compact
- ? "inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-border text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:opacity-50"
+ ? "inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:opacity-40"
: "flex items-center gap-1 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:bg-accent hover:text-accent-foreground disabled:opacity-50"
}
>
diff --git a/skyvern-frontend/src/routes/workflows/studio/BrowserPaneHeader.tsx b/skyvern-frontend/src/routes/workflows/studio/BrowserPaneHeader.tsx
index a2eae7c3f..b81257a22 100644
--- a/skyvern-frontend/src/routes/workflows/studio/BrowserPaneHeader.tsx
+++ b/skyvern-frontend/src/routes/workflows/studio/BrowserPaneHeader.tsx
@@ -173,10 +173,10 @@ export function BrowserPaneActions() {
// capture and the mounted RecordingPanel commits the recorded steps.
const stopButton = (
<Button
- variant="outline"
+ variant="ghost"
size="sm"
className={cn(
- "h-7 shrink-0 gap-1.5 border-border bg-transparent px-2 text-xs shadow-none",
+ "h-7 shrink-0 gap-1.5 px-2",
manualCapturePaused ? "text-amber-500" : "text-red-500",
)}
aria-label="Stop recording"
diff --git a/skyvern-frontend/src/routes/workflows/studio/BrowserTab.test.tsx b/skyvern-frontend/src/routes/workflows/studio/BrowserTab.test.tsx
index 759122892..ec0408e3d 100644
--- a/skyvern-frontend/src/routes/workflows/studio/BrowserTab.test.tsx
+++ b/skyvern-frontend/src/routes/workflows/studio/BrowserTab.test.tsx
@@ -495,14 +495,14 @@ describe("BrowserTab pills and selection sync", () => {
renderBrowserPane(STUDIO_PATH);
expect(screen.getByLabelText("Turn off browser").className).toContain(
- "badge-destructive",
+ "text-destructive",
);
for (const name of [
"Reconnect browser stream",
"Open browser in new tab",
]) {
expect(screen.getByLabelText(name).className).not.toContain(
- "badge-destructive",
+ "text-destructive",
);
}
});
diff --git a/skyvern-frontend/src/routes/workflows/studio/StudioPaneToggles.test.tsx b/skyvern-frontend/src/routes/workflows/studio/StudioPaneToggles.test.tsx
index 842007920..15349a74f 100644
--- a/skyvern-frontend/src/routes/workflows/studio/StudioPaneToggles.test.tsx
+++ b/skyvern-frontend/src/routes/workflows/studio/StudioPaneToggles.test.tsx
@@ -86,10 +86,14 @@ function tab(name: RegExp | string): HTMLButtonElement {
return screen.getByRole("button", { name }) as HTMLButtonElement;
}
-// The run selector tab reads "View Run: <id>" once a run is inspected and
-// "Past Runs" otherwise; match either so tests survive both states.
+// The primary run control reads "View Run: <id>" once a run is inspected and
+// "Past Runs" otherwise.
function runsTab(): HTMLButtonElement {
- return tab(/^(Past Runs|View Run)/);
+ return (
+ (screen.queryByRole("button", {
+ name: /^View Run/,
+ }) as HTMLButtonElement | null) ?? tab(/^Past Runs/)
+ );
}
function currentPanes(): string | null {
@@ -127,12 +131,19 @@ describe("StudioPaneToggles structure", () => {
expect(tab(/^Browser/).getAttribute("aria-expanded")).toBe("false");
});
+ test("the empty Past Runs control exposes its popover state and target", () => {
+ renderAt();
+ const trigger = tab(/^Past Runs/);
+
+ expect(trigger.getAttribute("aria-expanded")).toBe("false");
+ expect(trigger.getAttribute("aria-controls")).toBeTruthy();
+ });
+
test("explicit ?panes= wins over a run deep link", () => {
runsQueryMock.mockReturnValue({ data: [{ status: Status.Completed }] });
renderAt("/workflows/wpid_abc/studio?wr=run_1&panes=copilot");
expect(tab(/^Copilot/).getAttribute("aria-expanded")).toBe("true");
- // The Past Runs tab is a popover trigger; its active state (run pane open)
- // is aria-pressed, not aria-expanded.
+ // The inspected-run control reports whether its pane is open.
expect(runsTab().getAttribute("aria-pressed")).toBe("false");
});
@@ -232,6 +243,32 @@ describe("StudioPaneToggles run selector", () => {
expect(currentPanes()).toBe("copilot");
});
+ test("clicking the current run tab reopens its closed pane directly", () => {
+ renderAt("/workflows/wpid_abc/studio?panes=copilot&wr=wr_current");
+
+ fireEvent.click(tab("View Run: wr_current"));
+
+ expect(currentPanes()?.split(",")).toContain("overview");
+ expect(screen.queryByText("Past runs")).toBeNull();
+ });
+
+ test("clicking the current run tab closes its open pane", () => {
+ renderAt("/workflows/wpid_abc/studio?panes=copilot,overview&wr=wr_current");
+
+ fireEvent.click(tab("View Run: wr_current"));
+
+ expect(currentPanes()?.split(",")).not.toContain("overview");
+ });
+
+ test("the separate Past runs button opens the selector without toggling the run pane", async () => {
+ renderAt("/workflows/wpid_abc/studio?panes=copilot&wr=wr_current");
+
+ fireEvent.click(tab("Past Runs"));
+
+ expect(await screen.findByText("Past runs")).toBeTruthy();
+ expect(currentPanes()).toBe("copilot");
+ });
+
test("selecting a run opens the run pane and closes the popover", async () => {
infiniteRunsMock.mockReturnValue(
infiniteRuns([
@@ -244,7 +281,7 @@ describe("StudioPaneToggles run selector", () => {
);
// A different current run so the picked row is clickable (not the current).
renderAt("/workflows/wpid_abc/studio?panes=copilot&wr=wr_other");
- fireEvent.click(runsTab());
+ fireEvent.click(tab("Past Runs"));
fireEvent.click(await screen.findByText("wr_pick"));
// Selecting opens the run pane (overview). The row's switchRun also sets
@@ -268,7 +305,7 @@ describe("StudioPaneToggles run selector", () => {
]),
);
renderAt("/workflows/wpid_abc/studio?panes=copilot&wr=wr_same");
- fireEvent.click(runsTab());
+ fireEvent.click(tab("Past Runs"));
fireEvent.click(await screen.findByText("wr_same"));
expect(currentPanes()?.split(",")).toContain("overview");
@@ -352,6 +389,18 @@ describe("StudioPaneToggles keyboard navigation", () => {
expect(document.activeElement).toBe(tab(/^Copilot/));
});
+ test("ArrowRight includes the separate Past runs control while inspecting a run", () => {
+ renderAt("/workflows/wpid_abc/studio?wr=wr_current");
+ fireEvent.focus(tab(/^Browser/));
+
+ fireEvent.keyDown(tab(/^Browser/), { key: "ArrowRight" });
+ expect(document.activeElement).toBe(tab("View Run: wr_current"));
+ fireEvent.keyDown(tab("View Run: wr_current"), { key: "ArrowRight" });
+ expect(document.activeElement).toBe(tab("Past Runs"));
+ fireEvent.keyDown(tab("Past Runs"), { key: "ArrowRight" });
+ expect(document.activeElement).toBe(tab(/^Copilot/));
+ });
+
test("ArrowLeft wraps to the last tab and Home returns to the first", () => {
renderAt();
tab(/^Copilot/).focus();
diff --git a/skyvern-frontend/src/routes/workflows/studio/StudioPaneToggles.tsx b/skyvern-frontend/src/routes/workflows/studio/StudioPaneToggles.tsx
index 03c1533ac..693382c9a 100644
--- a/skyvern-frontend/src/routes/workflows/studio/StudioPaneToggles.tsx
+++ b/skyvern-frontend/src/routes/workflows/studio/StudioPaneToggles.tsx
@@ -1,5 +1,5 @@
import { useEffect, useState, type KeyboardEvent } from "react";
-import { CheckIcon, CopyIcon } from "@radix-ui/react-icons";
+import { CheckIcon, ChevronDownIcon, CopyIcon } from "@radix-ui/react-icons";
import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";
import { Status } from "@/api/types";
@@ -73,11 +73,11 @@ function useLabelsCollapsed(): boolean {
/**
* The studio's pane toggles, top-center in the top bar. Copilot, Editor and
* Browser are peer TOGGLES (multi-active — each opens or closes its pane). The
- * run pane's tab is different: it's the run selector — labeled with the
- * inspected run ("View Run: wr_…", falling back to "Past Runs"), clicking
- * always opens a run-history popover (it never toggles the pane), and picking
- * a run opens/retargets the run pane. Labels collapse to icons below xl so the
- * cluster never crowds the title or the run actions.
+ * run pane uses a split control while a run is inspected: its labeled button
+ * toggles that run's pane, and the adjacent chevron opens the Past Runs
+ * selector. With no run to inspect, the single Past Runs button opens the
+ * selector. Labels collapse to icons below xl so the cluster never crowds the
+ * title or the run actions.
*/
export function StudioPaneToggles() {
const { panes, togglePane, openPane } = useStudioPanes();
@@ -124,10 +124,19 @@ export function StudioPaneToggles() {
const paneBlockedByDeletion = (id: StudioPaneId) =>
workflowDeleted && DELETED_WORKFLOW_BLOCKED_PANES.includes(id);
+ type StudioControlId = StudioPaneId | "past-runs";
+ const controlIds: StudioControlId[] = STUDIO_PANE_IDS.flatMap((id) =>
+ id === "overview" && runId ? [id, "past-runs"] : [id],
+ );
+
// Roving tabindex (WAI-ARIA toolbar): the cluster is one tab stop; arrow
// keys move focus across the enabled toggles, Enter/Space toggles/opens.
- const [focusedId, setFocusedId] = useState<StudioPaneId>(STUDIO_PANE_IDS[0]!);
- const enabledIds = STUDIO_PANE_IDS.filter((id) => !paneBlockedByDeletion(id));
+ const [focusedId, setFocusedId] = useState<StudioControlId>(
+ STUDIO_PANE_IDS[0]!,
+ );
+ const enabledIds = controlIds.filter(
+ (id) => id === "past-runs" || !paneBlockedByDeletion(id),
+ );
const tabStopId = enabledIds.includes(focusedId) ? focusedId : enabledIds[0];
const onKeyDown = (event: KeyboardEvent<HTMLElement>) => {
const keys = ["ArrowRight", "ArrowLeft", "Home", "End"];
@@ -165,14 +174,14 @@ export function StudioPaneToggles() {
const label = railLabel(id, runId);
const open = panes.includes(id);
const blockedByDeletion = paneBlockedByDeletion(id);
- const isRunSelector = id === "overview";
+ const isRunControl = id === "overview";
const disabled = blockedByDeletion;
const showActivityDot =
id === "browser" && hasUnseenBrowserActivity && !open;
- const showRunStatusDot = isRunSelector && Boolean(runStatus);
+ const showRunStatusDot = isRunControl && Boolean(runStatus);
const ariaLabel = showActivityDot
? "Browser, new activity"
- : isRunSelector && runStatus
+ : isRunControl && runStatus
? `${label}, ${runStatusLabel(runStatus)}`
: label;
const iconAndDot = (
@@ -208,62 +217,87 @@ export function StudioPaneToggles() {
disabled && "pointer-events-none opacity-50",
);
- // The run pane's tab is a popover trigger: clicking opens the run
- // selector (Radix manages aria-haspopup/expanded/controls). Its
- // active state still reflects whether the run pane is open.
- if (isRunSelector) {
- const trigger = (
+ if (isRunControl) {
+ const runButton = (
+ <button
+ id={studioTabId(id)}
+ type="button"
+ aria-pressed={open}
+ {...(runId
+ ? {
+ "aria-expanded": open,
+ "aria-controls": studioPanelId(id),
+ }
+ : {})}
+ aria-label={ariaLabel}
+ tabIndex={id === tabStopId ? 0 : -1}
+ onFocus={() => setFocusedId(id)}
+ onClick={runId ? () => onToggle(id) : undefined}
+ className={cn(
+ buttonClassName,
+ "group",
+ runId && "rounded-r-none pr-2",
+ )}
+ >
+ {iconAndDot}
+ {runId ? (
+ <span
+ role="button"
+ tabIndex={0}
+ aria-label="Copy run link"
+ title="Copy run link"
+ onPointerDown={(event) => event.stopPropagation()}
+ onClick={(event) => {
+ event.stopPropagation();
+ event.preventDefault();
+ void copyRunLink();
+ }}
+ onKeyDown={(event) => {
+ if (event.key === "Enter" || event.key === " ") {
+ event.stopPropagation();
+ event.preventDefault();
+ void copyRunLink();
+ }
+ }}
+ className={cn(
+ "-ml-1.5 hidden w-0 overflow-hidden rounded p-0 opacity-0 transition-all xl:inline-flex",
+ "text-muted-foreground hover:text-foreground",
+ "group-focus-within:ml-0 group-focus-within:w-4 group-focus-within:p-0.5 group-focus-within:opacity-100 group-hover:ml-0 group-hover:w-4 group-hover:p-0.5 group-hover:opacity-100",
+ "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
+ runLinkCopied &&
+ "ml-0 w-4 p-0.5 text-foreground opacity-100",
+ )}
+ >
+ {runLinkCopied ? (
+ <CheckIcon className="size-3" aria-hidden />
+ ) : (
+ <CopyIcon className="size-3" aria-hidden />
+ )}
+ </span>
+ ) : null}
+ </button>
+ );
+ const selectorTrigger = runId ? (
<PopoverTrigger asChild>
<button
- id={studioTabId(id)}
+ id={studioTabId("past-runs")}
type="button"
- aria-pressed={open}
- aria-label={ariaLabel}
- tabIndex={id === tabStopId ? 0 : -1}
- onFocus={() => setFocusedId(id)}
- className={cn(buttonClassName, "group")}
+ aria-label="Past Runs"
+ tabIndex={"past-runs" === tabStopId ? 0 : -1}
+ onFocus={() => setFocusedId("past-runs")}
+ className={cn(
+ "inline-flex h-8 w-7 items-center justify-center rounded-l-none rounded-r-md border-l border-border/60 transition-colors",
+ "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
+ open || runsSelectorOpen
+ ? "bg-accent text-foreground"
+ : "text-muted-foreground hover:bg-accent/50 hover:text-foreground",
+ )}
>
- {iconAndDot}
- {runId ? (
- // Hover affordance beside the (fully visible) run id: copy
- // the run's URL without opening the selector popover. A span
- // because buttons can't nest; stopPropagation keeps the
- // popover closed.
- <span
- role="button"
- tabIndex={0}
- aria-label="Copy run link"
- title="Copy run link"
- onPointerDown={(event) => event.stopPropagation()}
- onClick={(event) => {
- event.stopPropagation();
- event.preventDefault();
- void copyRunLink();
- }}
- onKeyDown={(event) => {
- if (event.key === "Enter" || event.key === " ") {
- event.stopPropagation();
- event.preventDefault();
- void copyRunLink();
- }
- }}
- className={cn(
- "hidden rounded p-0.5 opacity-0 transition-opacity xl:inline-flex",
- "text-muted-foreground hover:text-foreground",
- "group-focus-within:opacity-100 group-hover:opacity-100",
- "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
- runLinkCopied && "text-foreground opacity-100",
- )}
- >
- {runLinkCopied ? (
- <CheckIcon className="size-3" aria-hidden />
- ) : (
- <CopyIcon className="size-3" aria-hidden />
- )}
- </span>
- ) : null}
+ <ChevronDownIcon className="size-3.5" aria-hidden />
</button>
</PopoverTrigger>
+ ) : (
+ <PopoverTrigger asChild>{runButton}</PopoverTrigger>
);
const tip = runId
? `View Run: ${runId}${
@@ -278,19 +312,33 @@ export function StudioPaneToggles() {
open={runsSelectorOpen}
onOpenChange={setRunsSelectorOpen}
>
- {/* Icon-collapsed keeps a label tooltip, composed straight onto
- the (never-disabled) button so aria-describedby reaches it;
- with labels visible the full id is already in the tab. */}
- {labelsCollapsed ? (
- <Tooltip>
- <TooltipTrigger asChild>{trigger}</TooltipTrigger>
- <TooltipContent side="bottom">{tip}</TooltipContent>
- </Tooltip>
- ) : (
- trigger
- )}
+ <span className="inline-flex items-center">
+ {runId ? (
+ labelsCollapsed ? (
+ <Tooltip>
+ <TooltipTrigger asChild>{runButton}</TooltipTrigger>
+ <TooltipContent side="bottom">{tip}</TooltipContent>
+ </Tooltip>
+ ) : (
+ runButton
+ )
+ ) : null}
+ {runId ? (
+ <Tooltip>
+ <TooltipTrigger asChild>{selectorTrigger}</TooltipTrigger>
+ <TooltipContent side="bottom">Past Runs</TooltipContent>
+ </Tooltip>
+ ) : labelsCollapsed ? (
+ <Tooltip>
+ <TooltipTrigger asChild>{selectorTrigger}</TooltipTrigger>
+ <TooltipContent side="bottom">{tip}</TooltipContent>
+ </Tooltip>
+ ) : (
+ selectorTrigger
+ )}
+ </span>
<PopoverContent
- align="start"
+ align={runId ? "end" : "start"}
sideOffset={8}
className="w-[22rem] p-0"
>
diff --git a/skyvern-frontend/src/routes/workflows/studio/StudioTopBar.tsx b/skyvern-frontend/src/routes/workflows/studio/StudioTopBar.tsx
index 1356a2aa9..5c74edb85 100644
--- a/skyvern-frontend/src/routes/workflows/studio/StudioTopBar.tsx
+++ b/skyvern-frontend/src/routes/workflows/studio/StudioTopBar.tsx
@@ -138,9 +138,9 @@ export function SaveButton() {
<>
<ControlTooltip content="Save workflow" blocked={isRecording}>
<Button
- variant="outline"
+ variant="ghost"
size="icon"
- className="relative h-8 w-8 border-border bg-transparent shadow-none"
+ className="relative h-8 w-8 text-muted-foreground"
disabled={isRecording}
onClick={() => {
// Recompute dirtiness synchronously from the same source as the
@@ -233,12 +233,12 @@ function PanelToggle({
const isOpen = state.active && state.content === content;
const button = (
<Button
- variant="outline"
+ variant="ghost"
size={icon ? "icon" : "default"}
disabled={isRecording}
aria-pressed={isOpen}
className={cn(
- "border-border bg-transparent shadow-none",
+ "text-muted-foreground",
icon ? "h-8 w-8" : "h-8 px-3 text-xs",
isOpen && "bg-accent text-accent-foreground hover:bg-accent/80",
)}
@@ -442,7 +442,7 @@ export function StudioTopBar() {
{workflowDeletedAt ? (
// Legacy run-header tag idiom; every workflow-mutating action (save,
// schedule, inputs, run) is gone with the agent. Run history stays
- // reachable from the Past Runs rail tab.
+ // reachable from the run control.
<span
title={basicTimeFormat(workflowDeletedAt)}
className="shrink-0 text-xs text-muted-foreground"
@@ -464,7 +464,7 @@ export function StudioTopBar() {
icon={<CalendarIcon className="size-4" />}
/>
<EditorOverflowMenu
- triggerClassName="h-8 w-8 rounded-md border border-border bg-transparent shadow-none"
+ triggerClassName="h-8 w-8 rounded-md border-0 bg-transparent text-muted-foreground hover:bg-accent hover:text-accent-foreground"
onVersionHistory={openVersionHistory}
embedded
/>
diff --git a/skyvern-frontend/src/routes/workflows/studio/constants.ts b/skyvern-frontend/src/routes/workflows/studio/constants.ts
index 510737669..6466cc80e 100644
--- a/skyvern-frontend/src/routes/workflows/studio/constants.ts
+++ b/skyvern-frontend/src/routes/workflows/studio/constants.ts
@@ -6,14 +6,15 @@ export const STUDIO_COPILOT_TRANSITION_MS = 300;
export const studioTabId = (tab: string) => `studio-tab-${tab}`;
export const studioPanelId = (tab: string) => `studio-panel-${tab}`;
-// Bordered icon-square pane-header action per the studio button grammar
+// Ghost icon-square pane-header action per the studio button grammar
// (cloud_docs/frontend/studio-button-system.md).
export const PANE_HEADER_ICON_BUTTON_CLASS =
- "inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-border text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40";
+ "inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40";
-// Same icon-square footprint as PANE_HEADER_ICON_BUTTON_CLASS, reserved for
-// the one control that actually ends the live browser session (documented
-// exception in studio-button-system.md, SKY-12247) — do not reuse for
-// Reconnect/Open-in-new-tab/pane-close, which don't carry that consequence.
+// Same ghost icon-square footprint as PANE_HEADER_ICON_BUTTON_CLASS, with the
+// destructive color on the icon for the one control that actually ends the
+// live browser session (documented exception in studio-button-system.md,
+// SKY-12247) — do not reuse for Reconnect/Open-in-new-tab/pane-close, which
+// don't carry that consequence.
export const PANE_HEADER_ICON_BUTTON_DESTRUCTIVE_CLASS =
- "inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-badge-destructive bg-badge-destructive text-foreground hover:bg-badge-destructive/80 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40";
+ "inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40";
diff --git a/skyvern-frontend/src/routes/workflows/studio/paneMeta.test.ts b/skyvern-frontend/src/routes/workflows/studio/paneMeta.test.ts
index fe6defca5..d03618744 100644
--- a/skyvern-frontend/src/routes/workflows/studio/paneMeta.test.ts
+++ b/skyvern-frontend/src/routes/workflows/studio/paneMeta.test.ts
@@ -37,7 +37,7 @@ describe("paneAccessibleName", () => {
test("the run pane's controls keep the stable name 'Run'", () => {
// The pane's own controls (region/close/drag) announce "Run", matching the
- // "Run: wr_…" content; "Past Runs" is the rail selector's name (railLabel).
+ // "Run: wr_…" content; "Past Runs" is the idle run control's label.
expect(paneAccessibleName("overview")).toBe("Run");
expect(paneLabel("overview", "wr_5538abcdef")).toBe("Run: wr_5538…");
});
diff --git a/skyvern-frontend/src/routes/workflows/studio/paneMeta.ts b/skyvern-frontend/src/routes/workflows/studio/paneMeta.ts
index 9e0d31317..75d0d2993 100644
--- a/skyvern-frontend/src/routes/workflows/studio/paneMeta.ts
+++ b/skyvern-frontend/src/routes/workflows/studio/paneMeta.ts
@@ -40,21 +40,18 @@ export function paneLabel(id: StudioPaneId, runId?: string | null): string {
// The stable accessible name for a pane's OWN controls (region, header, drag,
// close, resize) and announcements. The run pane keeps "Run" so a screen reader
-// hears "Close Run pane", matching its "Run: wr_…" content — "Past Runs" is the
-// selector trigger's name (railLabel), not the pane's. The run id never enters
-// this name: a truncated id is ambiguous and would rename the control on every
-// run switch.
+// hears "Close Run pane", matching its "Run: wr_…" content. The run id never
+// enters this name: a truncated id is ambiguous and would rename the control
+// on every run switch.
export function paneAccessibleName(id: StudioPaneId): string {
return paneLabel(id);
}
-// The rail tab / stage-launcher tile label. The run pane's tab is the run
-// selector (it opens the run history rather than toggling a pane): it names the
-// inspected run with its FULL id ("View Run: wr_55380…" — the top bar is where
-// people read and copy run ids, so no truncation) when callers pass one, and
-// reads "Past Runs" otherwise (no run inspected, or surfaces like the stage
-// launcher that don't resolve a run). Every other tab matches its pane's
-// accessible name.
+// The rail control / stage-launcher tile label. The inspected run's primary
+// control uses its FULL id ("View Run: wr_55380…" — the top bar is where people
+// read and copy run ids, so no truncation), while empty-state surfaces that
+// cannot open a run yet read "Past Runs". Every other control matches its
+// pane's accessible name.
export function railLabel(id: StudioPaneId, runId?: string | null): string {
if (id === "overview") {
return runId ? `View Run: ${runId}` : "Past Runs";
diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunPaneHeader.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunPaneHeader.tsx
index eb935646e..c0f852331 100644
--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunPaneHeader.tsx
+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunPaneHeader.tsx
@@ -188,7 +188,7 @@ export function RunPaneViewToggles() {
type="button"
onClick={focusBrowserPane}
aria-label="Live"
- className="inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-border px-2.5 text-[11px] font-medium text-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
+ className="inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md px-2.5 text-[11px] font-medium text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
>
<span className="h-1.5 w-1.5 animate-pulse rounded-full bg-success" />
{compact ? null : "Live"}
@@ -241,7 +241,7 @@ export function RunPaneActions() {
type="button"
aria-label="API & Webhooks"
className={cn(
- "inline-flex h-7 shrink-0 items-center gap-1.5 whitespace-nowrap rounded-md border border-border text-[11px] font-medium",
+ "inline-flex h-7 shrink-0 items-center gap-1.5 whitespace-nowrap rounded-md text-[11px] font-medium",
compact ? "w-7 justify-center px-0" : "px-2",
"text-muted-foreground hover:bg-accent hover:text-accent-foreground",
"focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
diff --git a/skyvern/forge/sdk/api/aws.py b/skyvern/forge/sdk/api/aws.py
index 2735b984f..c5bcf5701 100644
--- a/skyvern/forge/sdk/api/aws.py
+++ b/skyvern/forge/sdk/api/aws.py
@@ -29,6 +29,9 @@ add_type("application/zstd", ".zst")
_S3_OPERATION_RETRIES = 2
# get_object on a missing key raises NoSuchKey; head-style paths use 404/NotFound.
_S3_NOT_FOUND_ERROR_CODES = frozenset({"NoSuchKey", "NotFound", "404"})
+# Long-lived holders (e.g. the storage singleton on persistent-sessions workers) must not reuse a
+# session past the 1-hour projected web-identity token expiry (SKY-8743, SKY-13210).
+_SESSION_TTL_SECONDS: float = 45 * 60
LOG = structlog.get_logger()
@@ -72,6 +75,7 @@ class AsyncAWSClient:
self._aws_secret_access_key = aws_secret_access_key
self._profile_name = profile_name
self._session: aioboto3.Session | None = None
+ self._session_created_at: float = 0.0
@property
def session(self) -> aioboto3.Session:
@@ -80,6 +84,7 @@ class AsyncAWSClient:
@session.setter
def session(self, session: aioboto3.Session) -> None:
self._session = session
+ self._session_created_at = time.monotonic()
def _create_session(self, client_type_hint: AWSClientType | None = None) -> None:
try:
@@ -88,6 +93,7 @@ class AsyncAWSClient:
aws_secret_access_key=self._aws_secret_access_key,
profile_name=self._profile_name,
)
+ self._session_created_at = time.monotonic()
except ProfileNotFound as e:
profile_name = self._profile_name or os.environ.get("AWS_PROFILE") or "default"
client_scope = f" while creating the {client_type_hint.value} client" if client_type_hint else ""
@@ -99,6 +105,9 @@ class AsyncAWSClient:
def _get_session(self, client_type_hint: AWSClientType | None = None) -> aioboto3.Session:
if self._session is None:
self._create_session(client_type_hint)
+ elif (time.monotonic() - self._session_created_at) > _SESSION_TTL_SECONDS:
+ LOG.info("Recreating AWS session (TTL expired)", ttl_seconds=_SESSION_TTL_SECONDS)
+ self._create_session(client_type_hint)
return self._session
def refresh_session(self) -> None:
@@ -669,7 +678,7 @@ def tag_set_to_dict(tag_set: list[dict[str, str]]) -> dict[str, str]:
_aws_client: AsyncAWSClient | None = None
_aws_client_created_at: float = 0.0
-_AWS_CLIENT_TTL_SECONDS: float = 45 * 60 # 45 mins - before the 1-hour projected token expiry
+_AWS_CLIENT_TTL_SECONDS: float = _SESSION_TTL_SECONDS
def get_aws_client() -> AsyncAWSClient:
diff --git a/skyvern/forge/sdk/copilot/model_telemetry.py b/skyvern/forge/sdk/copilot/model_telemetry.py
index c0912988f..363ff9257 100644
--- a/skyvern/forge/sdk/copilot/model_telemetry.py
+++ b/skyvern/forge/sdk/copilot/model_telemetry.py
@@ -118,6 +118,13 @@ def _model_call_cost(telemetry: CopilotModelCallTelemetry, model: str) -> float
return float(input_cost + output_cost)
+def _is_azure_openai_host(base_url: str) -> bool:
+ # Match on the parsed host, not a substring: "https://evil.test/?x=.openai.azure.com"
+ # and "https://openai.azure.com.evil.test" both contain the domain but are not Azure.
+ host = (urlparse(base_url).hostname or "").lower()
+ return host == "openai.azure.com" or host.endswith(".openai.azure.com")
+
+
def _otel_provider_name(model: str, base_url: str | None) -> str | None:
normalized = model.lower()
provider, separator, _ = normalized.partition("/")
@@ -131,10 +138,8 @@ def _otel_provider_name(model: str, base_url: str | None) -> str | None:
}.get(provider)
if separator and explicit_provider is not None:
return explicit_provider
- if base_url:
- hostname = urlparse(base_url).hostname
- if hostname and hostname.lower().endswith(".openai.azure.com"):
- return "azure.ai.openai"
+ if base_url and _is_azure_openai_host(base_url):
+ return "azure.ai.openai"
if normalized.startswith(("gpt-", "o1", "o3", "o4")):
return "openai"
return None
diff --git a/skyvern/forge/sdk/routes/internal_auth.py b/skyvern/forge/sdk/routes/internal_auth.py
index f0cd2bbd2..ababecdf5 100644
--- a/skyvern/forge/sdk/routes/internal_auth.py
+++ b/skyvern/forge/sdk/routes/internal_auth.py
@@ -7,7 +7,7 @@ from fastapi import APIRouter, HTTPException, Request, status
from skyvern.config import settings
from skyvern.forge import app
-from skyvern.forge.sdk.services.local_org_auth_token_service import fingerprint_token, regenerate_local_api_key
+from skyvern.forge.sdk.services.local_org_auth_token_service import fingerprint_token
from skyvern.forge.sdk.services.org_auth_service import resolve_org_from_api_key
router = APIRouter(prefix="/internal/auth", tags=["internal"])
@@ -41,14 +41,11 @@ def _is_local_request(request: Request) -> bool:
except ValueError:
LOG.warning("Invalid IP address in request", host=host)
return False
- # Check if request is from Docker host (gateway IP)
- # Docker typically uses 172.x.x.x or 192.168.x.x for bridge networks
- is_local = addr.is_loopback or addr.is_private
+ is_local = addr.is_loopback
LOG.info(
"Checking if request is local",
host=host,
is_loopback=addr.is_loopback,
- is_private=addr.is_private,
is_local=is_local,
)
return is_local
@@ -72,10 +69,7 @@ async def _evaluate_local_api_key(token: str) -> DiagnosticsResult:
),
validation=None,
token=None,
- next_step=(
- "Send the local API key in the x-api-key header, or call POST /api/v1/internal/auth/repair "
- "from localhost to regenerate a local key and update the env files."
- ),
+ next_step="Run skyvern doctor --fix to regenerate the local key and update the env files.",
)
try:
@@ -114,12 +108,9 @@ def _emit_diagnostics(result: DiagnosticsResult) -> dict[str, object]:
fingerprint=fingerprint,
expires_at=result.validation.payload.exp,
)
- return {
- "status": status_value,
- "organization_id": result.validation.organization.organization_id,
- "fingerprint": fingerprint,
- "expires_at": result.validation.payload.exp,
- }
+ # The organization id, fingerprint and expiry stay in the log. The response body carries only
+ # the status, so this endpoint discloses nothing beyond it to whoever reaches the address gate.
+ return {"status": status_value}
log_kwargs: dict[str, object] = {"status": status_value}
if result.detail:
@@ -137,28 +128,9 @@ def _emit_diagnostics(result: DiagnosticsResult) -> dict[str, object]:
return payload
[email protected]("/repair", include_in_schema=False)
-async def repair_api_key(request: Request) -> dict[str, object]:
- _require_local_access(request)
-
- token, organization_id, backend_env_path, frontend_env_path = await regenerate_local_api_key()
-
- response: dict[str, object] = {
- "status": AuthStatus.ok.value,
- "organization_id": organization_id,
- "fingerprint": fingerprint_token(token),
- "api_key": token,
- "backend_env_path": backend_env_path,
- }
-
- if frontend_env_path:
- response["frontend_env_path"] = frontend_env_path
-
- return response
-
-
@router.get("/status", include_in_schema=False)
async def auth_status(request: Request) -> dict[str, object]:
+ _require_local_access(request)
token_candidate = request.headers.get("x-api-key") or ""
result = await _evaluate_local_api_key(token_candidate)
return _emit_diagnostics(result)
diff --git a/skyvern/forge/sdk/routes/streaming/channels/message.py b/skyvern/forge/sdk/routes/streaming/channels/message.py
index 9a32f638b..7718c9c47 100644
--- a/skyvern/forge/sdk/routes/streaming/channels/message.py
+++ b/skyvern/forge/sdk/routes/streaming/channels/message.py
@@ -565,7 +565,7 @@ async def loop_stream_messages(message_channel: MessageChannel) -> None:
vnc_channel = get_vnc_channel(message_channel.client_id)
if not vnc_channel:
- LOG.error(
+ LOG.warning(
f"{class_name} no vnc channel client found for message channel - cannot exfiltrate.",
message=message,
**message_channel.identity,
@@ -669,7 +669,7 @@ async def loop_stream_messages(message_channel: MessageChannel) -> None:
vnc_channel = get_vnc_channel(message_channel.client_id)
if not vnc_channel:
- LOG.error(
+ LOG.warning(
f"{class_name} no vnc channel client found for message channel.",
message=message,
**message_channel.identity,
@@ -875,7 +875,7 @@ async def loop_stream_messages(message_channel: MessageChannel) -> None:
vnc_channel = get_vnc_channel(message_channel.client_id)
if not vnc_channel:
- LOG.error(
+ LOG.warning(
f"{class_name} no vnc channel client found for message channel.",
message=message,
**message_channel.identity,
diff --git a/skyvern/forge/sdk/workflow/models/block.py b/skyvern/forge/sdk/workflow/models/block.py
index 6d470a322..cff94721f 100644
--- a/skyvern/forge/sdk/workflow/models/block.py
+++ b/skyvern/forge/sdk/workflow/models/block.py
@@ -3719,6 +3719,8 @@ _CODE_BLOCK_RECAPTCHA_RESPONSE_SELECTOR = 'textarea[name="g-recaptcha-response"]
_CODE_BLOCK_RECAPTCHA_ANCHOR_HOSTS = ("www.google.com", "www.recaptcha.net")
_CODE_BLOCK_RECAPTCHA_ANCHOR_PATHS = ("/recaptcha/api2/anchor", "/recaptcha/enterprise/anchor")
_CODE_BLOCK_RECAPTCHA_ANCHOR_ARM_TIMEOUT_SECONDS = 5
+# The extension arm polls a solver over the network; the scout caller has no enclosing bound.
+_CODE_BLOCK_EXTENSION_ARM_TIMEOUT_SECONDS = 12
# Google's widget flips aria-checked after its own animation; a shorter wait reads as unsolved.
_CODE_BLOCK_RECAPTCHA_ANCHOR_SETTLE_MS = 2_000
_CODE_BLOCK_CAPTCHA_CONTINUE_SELECTOR = ", ".join(
@@ -3848,8 +3850,9 @@ async def _code_block_solve_captcha_builtin(
LOG.info("code block CAPTCHA anchor frame arm did not solve", arm="recaptcha_anchor_frame")
try:
- if await app.AGENT_FUNCTION.auto_solve_captchas(page):
- return
+ async with asyncio.timeout(_CODE_BLOCK_EXTENSION_ARM_TIMEOUT_SECONDS):
+ if await app.AGENT_FUNCTION.auto_solve_captchas(page):
+ return
except Exception:
LOG.info("code block CAPTCHA extension arm did not solve", arm="extension")
diff --git a/tests/unit/test_aws_client_ttl.py b/tests/unit/test_aws_client_ttl.py
index 646603f70..eb03dcf5e 100644
--- a/tests/unit/test_aws_client_ttl.py
+++ b/tests/unit/test_aws_client_ttl.py
@@ -83,6 +83,42 @@ def test_refresh_session_creates_new_session():
assert client.session is not old_session
+def test_client_session_reused_within_ttl():
+ with patch.object(aws.aioboto3, "Session", side_effect=lambda **_: MagicMock()) as mock_session:
+ client = aws.AsyncAWSClient()
+ first = client.session
+ second = client.session
+
+ assert first is second
+ assert mock_session.call_count == 1
+
+
+def test_client_session_recreated_after_ttl():
+ """Any holder of AsyncAWSClient (e.g. the storage singleton on a long-lived worker) gets a
+ fresh session past the TTL, not just callers of the module-level get_aws_client() factory."""
+ with patch.object(aws.aioboto3, "Session", side_effect=lambda **_: MagicMock()) as mock_session:
+ client = aws.AsyncAWSClient()
+ first = client.session
+ client._session_created_at = time.monotonic() - (aws._SESSION_TTL_SECONDS + 1)
+ second = client.session
+
+ assert first is not second
+ assert mock_session.call_count == 2
+
+
+def test_setter_stamps_session_ttl_clock():
+ """A backdated clock plus a setter-installed session must not trigger recreation: the setter
+ stamps the TTL clock. Deterministic regardless of host uptime, unlike the compat test."""
+ client = aws.AsyncAWSClient()
+ client._session_created_at = -(aws._SESSION_TTL_SECONDS + 1)
+ session = MagicMock()
+
+ client.session = session
+
+ assert client._session_created_at > 0
+ assert client.session is session
+
+
def test_no_profile_session_creation_uses_default_credential_chain(monkeypatch: pytest.MonkeyPatch):
monkeypatch.delenv("AWS_PROFILE", raising=False)
session = MagicMock()
diff --git a/tests/unit/test_code_block_captcha.py b/tests/unit/test_code_block_captcha.py
index e90abbe0d..695c69589 100644
--- a/tests/unit/test_code_block_captcha.py
+++ b/tests/unit/test_code_block_captcha.py
@@ -519,3 +519,36 @@ async def test_real_sandbox_solve_captcha_raises_constant_sanitized_error(
def test_solve_captcha_is_reserved_in_sandbox_namespace() -> None:
assert "solve_captcha" in CodeBlock.build_safe_vars()
+
+
+async def test_extension_arm_is_bounded_and_falls_through_on_hang(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """The copilot scout calls this builtin with no enclosing timeout, so a solver extension that
+ never answers must not stall the turn — the arm is bounded and the ladder continues."""
+
+ async def _never_returns(*_args: object, **_kwargs: object) -> bool:
+ await asyncio.Event().wait()
+ raise AssertionError("should be cancelled before this point")
+
+ agent_function = type(
+ "AgentFunctionStub",
+ (),
+ {
+ "auto_solve_captchas": AsyncMock(side_effect=_never_returns),
+ "solve_recaptcha_token": AsyncMock(return_value=False),
+ },
+ )()
+ monkeypatch.setattr(app, "AGENT_FUNCTION", agent_function)
+ monkeypatch.setattr(block_module, "_CODE_BLOCK_EXTENSION_ARM_TIMEOUT_SECONDS", 0.01)
+ page = FakePage(recaptcha=True)
+ block = CodeBlock.model_construct(code="await solve_captcha(page)", label="captcha_ext_hang")
+
+ # wait_for makes an ablated (unbounded) arm fail this test cleanly instead of
+ # hanging it until the CI job timeout.
+ with pytest.raises(CodeBlockCaptchaError):
+ await asyncio.wait_for(block.generate_async_user_function(block.code, page)(), timeout=5)
+
+ agent_function.auto_solve_captchas.assert_awaited_once()
+ agent_function.solve_recaptcha_token.assert_awaited_once()
diff --git a/tests/unit/test_copilot_model_telemetry.py b/tests/unit/test_copilot_model_telemetry.py
index 06899e12c..070e609c8 100644
--- a/tests/unit/test_copilot_model_telemetry.py
+++ b/tests/unit/test_copilot_model_telemetry.py
@@ -541,22 +541,6 @@ def test_datadog_usage_preserves_missing_cache_write_as_absent(
assert "operation.cost" not in events[0]
- ("base_url", "expected_provider"),
- [
- ("https://example.openai.azure.com", "azure.ai.openai"),
- ("https://EXAMPLE.OPENAI.AZURE.COM/openai", "azure.ai.openai"),
- ("https://example.com/.openai.azure.com", None),
- ("https://openai.azure.com.attacker.example", None),
- ],
-)
-def test_otel_provider_name_validates_azure_hostname(
- base_url: str,
- expected_provider: str | None,
-) -> None:
- assert model_telemetry_module._otel_provider_name("custom-model", base_url) == expected_provider
-
-
def test_datadog_usage_attributes_fallback_spend_to_response_model(
monkeypatch: pytest.MonkeyPatch,
) -> None:
@@ -680,3 +664,29 @@ async def test_stream_cancellation_resets_context_without_changing_stream_owners
assert current_model_call_telemetry() is None
assert stream.closed is False
+
+
+ "base_url",
+ [
+ "https://example.openai.azure.com",
+ "https://example.openai.azure.com/openai/deployments/x",
+ "https://OPENAI.AZURE.COM",
+ ],
+)
+def test_otel_provider_name_detects_azure_hosts(base_url: str) -> None:
+ assert model_telemetry_module._otel_provider_name("gpt-5.6-sol", base_url) == "azure.ai.openai"
+
+
+ "base_url",
+ [
+ "https://evil.test/?redirect=.openai.azure.com",
+ "https://openai.azure.com.evil.test",
+ "https://evil.test/.openai.azure.com",
+ "https://notopenai.azure.com.attacker.test/v1",
+ ],
+)
+def test_otel_provider_name_rejects_lookalike_azure_urls(base_url: str) -> None:
+ # A bare substring check labelled all of these as Azure; the host check must not.
+ assert model_telemetry_module._otel_provider_name("some-model", base_url) is None
diff --git a/tests/unit/test_internal_auth.py b/tests/unit/test_internal_auth.py
new file mode 100644
index 000000000..e200bce84
--- /dev/null
+++ b/tests/unit/test_internal_auth.py
@@ -0,0 +1,78 @@
+from types import SimpleNamespace
+from unittest.mock import AsyncMock
+
+import pytest
+from fastapi import FastAPI, HTTPException, Request, status
+from fastapi.testclient import TestClient
+
+from skyvern.forge.sdk.routes import internal_auth
+
+
+def _request(client_host: str = "127.0.0.1") -> Request:
+ return Request(
+ {
+ "type": "http",
+ "headers": [],
+ "client": (client_host, 1234),
+ "method": "GET",
+ "path": "/internal/auth/status",
+ "scheme": "http",
+ }
+ )
+
+
+def test_is_local_request_returns_false_for_public_ip() -> None:
+ assert internal_auth._is_local_request(_request(client_host="8.8.8.8")) is False
+
+
+def test_is_local_request_accepts_loopback() -> None:
+ assert internal_auth._is_local_request(_request()) is True
+
+
+def test_is_local_request_rejects_private_non_loopback_address() -> None:
+ assert internal_auth._is_local_request(_request(client_host="192.168.1.20")) is False
+
+
+def test_is_local_request_handles_missing_client() -> None:
+ request = _request()
+ request.scope["client"] = None
+ assert internal_auth._is_local_request(request) is False
+
+
+def test_repair_route_is_not_registered() -> None:
+ app = FastAPI()
+ app.include_router(internal_auth.router)
+
+ with TestClient(app) as client:
+ response = client.post("/internal/auth/repair")
+
+ assert response.status_code == status.HTTP_404_NOT_FOUND
+
+
+async def test_auth_status_rejects_private_non_loopback_address(monkeypatch: pytest.MonkeyPatch) -> None:
+ monkeypatch.setattr(internal_auth, "settings", SimpleNamespace(ENV="local"))
+ evaluate_local_api_key = AsyncMock()
+ monkeypatch.setattr(internal_auth, "_evaluate_local_api_key", evaluate_local_api_key)
+
+ with pytest.raises(HTTPException) as exc_info:
+ await internal_auth.auth_status(_request(client_host="192.168.1.20"))
+
+ assert exc_info.value.status_code == status.HTTP_403_FORBIDDEN
+ evaluate_local_api_key.assert_not_awaited()
+
+
+def test_diagnostics_body_discloses_only_the_status() -> None:
+ result = internal_auth.DiagnosticsResult(
+ status=internal_auth.AuthStatus.ok,
+ detail=None,
+ validation=SimpleNamespace(
+ organization=SimpleNamespace(organization_id="org-secret"),
+ payload=SimpleNamespace(exp=4102444800),
+ ),
+ token="sk-abcdefghijklmnopqrstuvwxyz",
+ )
+
+ payload = internal_auth._emit_diagnostics(result)
+
+ assert payload == {"status": "ok"}
diff --git a/tests/unit_tests/test_internal_auth.py b/tests/unit_tests/test_internal_auth.py
deleted file mode 100644
index 2723f4d9b..000000000
--- a/tests/unit_tests/test_internal_auth.py
+++ /dev/null
@@ -1,35 +0,0 @@
-from starlette.requests import Request
-
-from skyvern.forge.sdk.routes.internal_auth import _is_local_request
-
-
-def _make_request(host: str | None) -> Request:
- scope = {
- "type": "http",
- "client": (host, 12345) if host else None,
- "headers": [],
- "method": "GET",
- "path": "/",
- "scheme": "http",
- }
- return Request(scope)
-
-
-def test_is_local_request_returns_false_for_public_ip() -> None:
- request = _make_request("8.8.8.8") # public IPv4 address
- assert _is_local_request(request) is False
-
-
-def test_is_local_request_accepts_loopback() -> None:
- request = _make_request("127.0.0.1")
- assert _is_local_request(request) is True
-
-
-def test_is_local_request_accepts_private_networks() -> None:
- request = _make_request("192.168.1.20")
- assert _is_local_request(request) is True
-
-
-def test_is_local_request_handles_missing_client() -> None:
- request = _make_request(None)
- assert _is_local_request(request) is False
diff --git a/uv.lock b/uv.lock
index 452f7e14f..05b35dbe9 100644
--- a/uv.lock
+++ b/uv.lock
@@ -6151,8 +6151,8 @@ requires-dist = [
{ name = "greenlet", marker = "python_full_version >= '3.12' and python_full_version < '3.14' and extra == 'local'", specifier = ">3.0.3" },
{ name = "greenlet", marker = "python_full_version >= '3.12' and python_full_version < '3.14' and extra == 'server'", specifier = ">3.0.3" },
{ name = "httpx", extras = ["socks"], specifier = ">=0.27.0" },
- { name = "jinja2", marker = "extra == 'local'", specifier = ">=3.1.2,<4" },
- { name = "jinja2", marker = "extra == 'server'", specifier = ">=3.1.2,<4" },
+ { name = "jinja2", marker = "extra == 'local'", specifier = ">=3.1.6,<4" },
+ { name = "jinja2", marker = "extra == 'server'", specifier = ">=3.1.6,<4" },
{ name = "json-repair", marker = "extra == 'local'", specifier = ">=0.60.1,<0.61" },
{ name = "json-repair", marker = "extra == 'server'", specifier = ">=0.60.1,<0.61" },
{ name = "json5", marker = "extra == 'local'", specifier = ">=0.13.0,<1" },