Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

feat(frontend): add perf dev tools for re-renders, JS CPU and heap (#15669)

Abhimanyu Yadav604916b4c6c0
diff --git a/autogpt_platform/frontend/.env.default b/autogpt_platform/frontend/.env.default
index a17d62e8d6..0ba4c4ca09 100644
--- a/autogpt_platform/frontend/.env.default
+++ b/autogpt_platform/frontend/.env.default
@@ -87,6 +87,9 @@ NEXT_PUBLIC_REACT_QUERY_DEVTOOL=true
# self-hosted single-container image, never show it whatever this is set to.
# Set false to hide it in dev too; inlined at build time, so it needs a rebuild.
NEXT_PUBLIC_TOKEN_DEVTOOL=true
+# React render counter for `pnpm perf` (window.__renderCounter). Off unless
+# exactly "1"; see docs/engineering/frontend-perf-measurement.md.
+# NEXT_PUBLIC_RENDER_COUNTER=1
NEXT_PUBLIC_GA_MEASUREMENT_ID=G-FH2XK2W4GN
# Google Ads conversion tracking (production only). The account's tag ID and
diff --git a/autogpt_platform/frontend/.gitignore b/autogpt_platform/frontend/.gitignore
index 3099c0622b..b92a653f83 100644
--- a/autogpt_platform/frontend/.gitignore
+++ b/autogpt_platform/frontend/.gitignore
@@ -64,3 +64,4 @@ src/app/api/__generated__/
*.mp4
!public/onboarding/*.mp4
!public/videos/workflows-moved.mp4
+/.perf/
diff --git a/autogpt_platform/frontend/TESTING.md b/autogpt_platform/frontend/TESTING.md
index 2817627c39..8b4431c798 100644
--- a/autogpt_platform/frontend/TESTING.md
+++ b/autogpt_platform/frontend/TESTING.md
@@ -173,6 +173,14 @@ If you reset the Docker DB and logins start failing:
- `pnpm test-storybook` — CI runner
- When changing components in `src/components`, update or add stories and verify in Storybook/Chromatic
+## Performance measurement
+
+`pnpm perf` measures re-renders, main-thread time and JS heap for a fixed scenario (copilot, builder, library) against `NEXT_PUBLIC_RENDER_COUNTER=1 pnpm dev`, and `pnpm perf:compare` prints two labelled sets side by side. It is a local tool, not part of CI. See [frontend-perf-measurement.md](../../docs/engineering/frontend-perf-measurement.md) for setup, the scenarios and how to read the output.
+
+### Performance PRs
+
+A PR that claims to make the frontend faster includes the `pnpm perf:compare --a before --b after` table for the scenario it targets, measured on the same machine. A PR that adds a scenario adds its baseline to [frontend-perf-baseline.md](../../docs/engineering/frontend-perf-baseline.md).
+
## TDD Workflow
When fixing a bug or adding a feature:
diff --git a/autogpt_platform/frontend/knip.json b/autogpt_platform/frontend/knip.json
index c3944ece9c..f041c70004 100644
--- a/autogpt_platform/frontend/knip.json
+++ b/autogpt_platform/frontend/knip.json
@@ -3,7 +3,10 @@
"entry": [
"sentry.{edge,server}.config.ts",
"scripts/migrate-supabase-auth.ts",
- "scripts/seed-preview-accounts.ts"
+ "scripts/seed-preview-accounts.ts",
+ "scripts/perf/record.ts",
+ "public/devtools/render-counter.js",
+ "scripts/perf/fixtures/generate.ts"
],
"ignoreDependencies": [
"@opentelemetry/instrumentation",
diff --git a/autogpt_platform/frontend/package.json b/autogpt_platform/frontend/package.json
index d82d52fd8a..260f9d7352 100644
--- a/autogpt_platform/frontend/package.json
+++ b/autogpt_platform/frontend/package.json
@@ -29,7 +29,9 @@
"test-storybook:ci": "concurrently -k -s first -n \"SB,TEST\" -c \"magenta,blue\" \"pnpm run build-storybook -- --quiet && npx http-server storybook-static --port 6006 --silent\" \"wait-on tcp:6006 && pnpm run test-storybook\"",
"generate:api": "npx --yes tsx ./scripts/generate-api-queries.ts && orval --config ./orval.config.ts",
"generate:api:force": "npx --yes tsx ./scripts/generate-api-queries.ts --force && orval --config ./orval.config.ts",
- "copy:vad-assets": "node ./scripts/copy-vad-assets.mjs"
+ "copy:vad-assets": "node ./scripts/copy-vad-assets.mjs",
+ "perf": "npx --yes tsx scripts/perf/measure.ts",
+ "perf:compare": "npx --yes tsx scripts/perf/compare.ts"
},
"browserslist": [
"defaults"
diff --git a/autogpt_platform/frontend/public/devtools/render-counter.js b/autogpt_platform/frontend/public/devtools/render-counter.js
new file mode 100644
index 0000000000..0e319bd5c7
--- /dev/null
+++ b/autogpt_platform/frontend/public/devtools/render-counter.js
@@ -0,0 +1,216 @@
+/*
+ * Dev-only React render counter. Loaded by src/app/layout.tsx only when
+ * NEXT_PUBLIC_RENDER_COUNTER=1, before React, so React reports every commit
+ * to __REACT_DEVTOOLS_GLOBAL_HOOK__. Plain JS, never bundled.
+ *
+ * Console: __renderCounter.print() / .report() / .reset() / .start() / .stop()
+ * Docs: docs/engineering/frontend-perf-measurement.md
+ */
+(function () {
+ "use strict";
+ if (typeof window === "undefined" || window.__renderCounter) return;
+
+ // React 18 fiber tags and flags.
+ var FUNCTION = 0;
+ var CLASS = 1;
+ var FORWARD_REF = 11;
+ var SIMPLE_MEMO = 15;
+ var PERFORMED_WORK = 1;
+ // MemoComponent (14) is left out on purpose: React marks both the memo
+ // wrapper and the component inside it, which would count one render twice.
+ var COUNTED_TAGS = [FUNCTION, CLASS, FORWARD_REF, SIMPLE_MEMO];
+
+ var recording = true;
+ var commits = 0;
+ var totalRenders = 0;
+ var maxRendersPerCommit = 0;
+ var counts = new Map();
+ var causes = new Map();
+
+ function bump(map, key) {
+ map.set(key, (map.get(key) || 0) + 1);
+ }
+
+ function nameOf(type) {
+ if (!type) return "Anonymous";
+ var name =
+ type.displayName ||
+ type.name ||
+ (type.type && (type.type.displayName || type.type.name)) ||
+ (type.render && (type.render.displayName || type.render.name)) ||
+ "Anonymous";
+ var match;
+ while ((match = /^(?:Memo|ForwardRef)\((.*)\)$/.exec(name))) {
+ name = match[1];
+ }
+ return name || "Anonymous";
+ }
+
+ function changedStateSlot(fiber) {
+ var before = fiber.alternate.memoizedState;
+ var after = fiber.memoizedState;
+ if (fiber.tag === CLASS) return before !== after ? "state" : null;
+ var index = 0;
+ while (before && after && typeof after === "object" && "next" in after) {
+ if (after.queue !== null && !Object.is(before.memoizedState, after.memoizedState)) {
+ return "state#" + index;
+ }
+ before = before.next;
+ after = after.next;
+ index++;
+ }
+ return null;
+ }
+
+ function changedPropKeys(before, after) {
+ var keys = [];
+ var seen = {};
+ [before, after].forEach(function (props) {
+ if (!props || typeof props !== "object") return;
+ Object.keys(props).forEach(function (key) {
+ if (seen[key]) return;
+ seen[key] = true;
+ if (!Object.is(before && before[key], after && after[key])) keys.push(key);
+ });
+ });
+ return keys;
+ }
+
+ function causeOf(fiber, parentName) {
+ if (fiber.alternate === null) return "mount";
+ var state = changedStateSlot(fiber);
+ if (state) return state;
+ var before = fiber.alternate.memoizedProps;
+ var after = fiber.memoizedProps;
+ if (before !== after) {
+ var keys = changedPropKeys(before, after);
+ if (keys.length === 0) return "parent-same-props<-" + parentName;
+ var more = keys.length > 4 ? ",+" + (keys.length - 4) : "";
+ return "props:" + keys.slice(0, 4).join(",") + more;
+ }
+ return "context";
+ }
+
+ function walk(root) {
+ var rendersThisCommit = 0;
+ var stack = [[root.current, "Root"]];
+ while (stack.length) {
+ var item = stack.pop();
+ var fiber = item[0];
+ var parentName = item[1];
+ var rendered =
+ COUNTED_TAGS.indexOf(fiber.tag) !== -1 &&
+ (fiber.flags & PERFORMED_WORK) !== 0;
+ var childParent = parentName;
+ if (rendered) {
+ var name = nameOf(fiber.type);
+ rendersThisCommit++;
+ bump(counts, name);
+ bump(causes, name + " " + causeOf(fiber, parentName));
+ childParent = name;
+ } else if (COUNTED_TAGS.indexOf(fiber.tag) !== -1) {
+ childParent = nameOf(fiber.type);
+ }
+ if (fiber.sibling) stack.push([fiber.sibling, parentName]);
+ // A bailed-out subtree keeps the fibers (and stale flags) of an older
+ // commit, so nothing below it rendered in this one.
+ var bailedOut =
+ fiber.alternate !== null && fiber.child === fiber.alternate.child && !rendered;
+ if (fiber.child && !bailedOut) stack.push([fiber.child, childParent]);
+ }
+ return rendersThisCommit;
+ }
+
+ function onCommit(root) {
+ if (!recording || !root || !root.current) return;
+ try {
+ var renders = walk(root);
+ commits++;
+ totalRenders += renders;
+ if (renders > maxRendersPerCommit) maxRendersPerCommit = renders;
+ } catch (error) {
+ console.warn("[render-counter] walk failed", error);
+ }
+ }
+
+ function sorted(map) {
+ return Array.from(map, function (entry) {
+ return { key: entry[0], count: entry[1] };
+ }).sort(function (a, b) {
+ return b.count - a.count;
+ });
+ }
+
+ function installHook() {
+ var hook = window.__REACT_DEVTOOLS_GLOBAL_HOOK__;
+ if (!hook) {
+ var nextId = 1;
+ var noop = function () {};
+ hook = {
+ supportsFiber: true,
+ renderers: new Map(),
+ inject: function (renderer) {
+ var id = nextId++;
+ hook.renderers.set(id, renderer);
+ return id;
+ },
+ onCommitFiberRoot: noop,
+ onCommitFiberUnmount: noop,
+ onPostCommitFiberRoot: noop,
+ onScheduleFiberRoot: noop,
+ checkDCE: noop,
+ isDisabled: false,
+ on: noop,
+ off: noop,
+ emit: noop,
+ sub: function () {
+ return noop;
+ },
+ };
+ window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = hook;
+ }
+ var previous = hook.onCommitFiberRoot;
+ hook.onCommitFiberRoot = function (rendererID, root) {
+ onCommit(root);
+ if (typeof previous === "function") return previous.apply(this, arguments);
+ };
+ }
+
+ window.__renderCounter = {
+ start: function () {
+ recording = true;
+ },
+ stop: function () {
+ recording = false;
+ },
+ reset: function () {
+ commits = 0;
+ totalRenders = 0;
+ maxRendersPerCommit = 0;
+ counts.clear();
+ causes.clear();
+ },
+ report: function () {
+ return {
+ commits: commits,
+ totalRenders: totalRenders,
+ rendersPerCommit: commits ? totalRenders / commits : 0,
+ maxRendersPerCommit: maxRendersPerCommit,
+ components: sorted(counts),
+ causes: sorted(causes),
+ };
+ },
+ print: function (limit) {
+ var report = this.report();
+ var top = limit || 20;
+ console.log(
+ "[render-counter] " + report.commits + " commits, " + report.totalRenders + " renders"
+ );
+ console.table(report.components.slice(0, top));
+ console.table(report.causes.slice(0, top));
+ return report;
+ },
+ };
+
+ installHook();
+})();
diff --git a/autogpt_platform/frontend/scripts/perf/__tests__/cdp.test.ts b/autogpt_platform/frontend/scripts/perf/__tests__/cdp.test.ts
new file mode 100644
index 0000000000..41c8cb4e90
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/__tests__/cdp.test.ts
@@ -0,0 +1,41 @@
+import { describe, expect, it } from "vitest";
+import { summarizeLongTasks, type TraceEvent } from "../lib/cdp";
+
+function task(pid: number, tid: number, durMs: number): TraceEvent {
+ return { name: "RunTask", ph: "X", pid, tid, ts: 0, dur: durMs * 1000 };
+}
+
+function threadName(pid: number, tid: number, name: string): TraceEvent {
+ return { name: "thread_name", ph: "M", pid, tid, ts: 0, args: { name } };
+}
+
+describe("summarizeLongTasks", () => {
+ it("counts tasks of 50 ms or more on the page's renderer main thread", () => {
+ const events: TraceEvent[] = [
+ {
+ name: "TracingStartedInBrowser",
+ ph: "I",
+ pid: 1,
+ tid: 1,
+ ts: 0,
+ args: {
+ data: { frames: [{ processId: 7 }, { processId: 9, parent: "f" }] },
+ },
+ },
+ threadName(7, 70, "CrRendererMain"),
+ threadName(7, 71, "Compositor"),
+ threadName(9, 90, "CrRendererMain"),
+ task(7, 70, 80),
+ task(7, 70, 50),
+ task(7, 70, 49),
+ task(7, 71, 200),
+ task(9, 90, 300),
+ ];
+ expect(summarizeLongTasks(events)).toEqual({ count: 2, totalMs: 130 });
+ });
+
+ it("falls back to every renderer main thread without frame info", () => {
+ const events = [threadName(3, 30, "CrRendererMain"), task(3, 30, 60)];
+ expect(summarizeLongTasks(events)).toEqual({ count: 1, totalMs: 60 });
+ });
+});
diff --git a/autogpt_platform/frontend/scripts/perf/__tests__/fixtures.test.ts b/autogpt_platform/frontend/scripts/perf/__tests__/fixtures.test.ts
new file mode 100644
index 0000000000..0942c2ecef
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/__tests__/fixtures.test.ts
@@ -0,0 +1,91 @@
+import fs from "fs";
+import path from "path";
+import { describe, expect, it } from "vitest";
+import { buildGraph, buildRunningExecution } from "../lib/builder-fixture";
+import { replyText } from "../lib/copilot-fixture";
+import {
+ buildLibraryAgents,
+ buildRunningExecutions,
+} from "../lib/library-fixture";
+import { FIXTURES_DIR } from "../lib/paths";
+import { splitFrames } from "../lib/stream-server";
+import {
+ REPLY_20_LINES,
+ buildReplyStream,
+ buildSessionRows,
+} from "../fixtures/generate";
+
+describe("copilot fixtures", () => {
+ it("builds a 200-row session with text, code, tables and tool calls", () => {
+ const rows = buildSessionRows();
+ expect(rows).toHaveLength(200);
+ expect(rows.map((row) => row.sequence)).toEqual(rows.map((_, i) => i));
+ expect(rows.some((row) => row.role === "tool")).toBe(true);
+ expect(rows.some((row) => row.content.includes("```ts"))).toBe(true);
+ expect(rows.some((row) => row.content.includes("| Day |"))).toBe(true);
+ });
+
+ it("streams the 20-line reply as one text part that ends with [DONE]", () => {
+ expect(REPLY_20_LINES.split("\n")).toHaveLength(20);
+ const sse = buildReplyStream(REPLY_20_LINES, "m1");
+ const frames = splitFrames(sse);
+ expect(frames[0]).toBe('data: {"type":"start","messageId":"m1"}');
+ expect(frames.at(-1)).toBe("data: [DONE]");
+ expect(replyText(sse)).toBe(REPLY_20_LINES);
+ });
+
+ it("reads the reply text out of recorded frames with id lines and comments", () => {
+ const recorded = [
+ 'id: t:1-0\ndata: {"type": "data-status", "data": {}}',
+ ": heartbeat",
+ 'id: t:2-0\ndata: {"type":"text-delta","id":"x","delta":"Hello "}',
+ 'id: t:2-1\ndata: {"type":"text-delta","id":"x","delta":"world"}',
+ "data: [DONE]",
+ ].join("\n\n");
+ expect(replyText(recorded)).toBe("Hello world");
+ });
+
+ it("matches the committed fixture files", () => {
+ const session = JSON.parse(
+ fs.readFileSync(path.join(FIXTURES_DIR, "session-200.json"), "utf8"),
+ );
+ expect(session.messages).toEqual(buildSessionRows());
+ expect(
+ fs.readFileSync(path.join(FIXTURES_DIR, "reply-20-lines.sse"), "utf8"),
+ ).toBe(buildReplyStream(REPLY_20_LINES, "perf-reply-20-lines"));
+ });
+});
+
+describe("builder fixture", () => {
+ it("owns a 50-node graph by the signed-in user with a running execution", () => {
+ const graph = buildGraph("user-1");
+ const execution = buildRunningExecution(graph, "user-1");
+ expect(graph.user_id).toBe("user-1");
+ expect(graph.nodes).toHaveLength(50);
+ const ids = new Set(graph.nodes.map((node) => node.id));
+ expect(ids.size).toBe(50);
+ expect(
+ graph.links.every(
+ (link) => ids.has(link.source_id) && ids.has(link.sink_id),
+ ),
+ ).toBe(true);
+ expect(execution.status).toBe("RUNNING");
+ expect(
+ execution.node_executions.filter((node) => node.status === "RUNNING"),
+ ).toHaveLength(3);
+ });
+});
+
+describe("library fixture", () => {
+ it("gives each of the 20 workflows a RUNNING execution", () => {
+ const agents = buildLibraryAgents();
+ const executions = buildRunningExecutions(agents, "user-1");
+ expect(agents).toHaveLength(20);
+ expect(executions.map((execution) => execution.graph_id)).toEqual(
+ agents.map((agent) => agent.graph_id),
+ );
+ expect(
+ executions.every((execution) => execution.status === "RUNNING"),
+ ).toBe(true);
+ });
+});
diff --git a/autogpt_platform/frontend/scripts/perf/__tests__/render-counter.test.tsx b/autogpt_platform/frontend/scripts/perf/__tests__/render-counter.test.tsx
new file mode 100644
index 0000000000..f148cb673e
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/__tests__/render-counter.test.tsx
@@ -0,0 +1,222 @@
+import fs from "fs";
+import path from "path";
+import {
+ act,
+ createContext,
+ memo,
+ useContext,
+ useState,
+ type Dispatch,
+ type SetStateAction,
+} from "react";
+import { createRoot, type Root } from "react-dom/client";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+
+const SCRIPT = fs.readFileSync(
+ path.resolve(__dirname, "../../../public/devtools/render-counter.js"),
+ "utf8",
+);
+
+interface Report {
+ commits: number;
+ totalRenders: number;
+ components: { key: string; count: number }[];
+ causes: { key: string; count: number }[];
+}
+
+interface Hook {
+ onCommitFiberRoot(rendererID: number, root: unknown): void;
+}
+
+type TestWindow = Window & {
+ __renderCounter?: {
+ start(): void;
+ stop(): void;
+ reset(): void;
+ report(): Report;
+ };
+ __REACT_DEVTOOLS_GLOBAL_HOOK__?: Hook;
+};
+
+const testWindow = window as TestWindow;
+
+function loadCounter() {
+ new Function(SCRIPT)();
+ return testWindow.__renderCounter!;
+}
+
+// React DOM is already loaded by the test setup, before the hook existed, so
+// it never injected. Hand each commit to the hook the way React would.
+function commit(container: HTMLElement) {
+ const key = Object.keys(container).find((name) =>
+ name.startsWith("__reactContainer$"),
+ );
+ const hostRoot = (
+ container as unknown as Record<string, { stateNode: unknown }>
+ )[key!];
+ testWindow.__REACT_DEVTOOLS_GLOBAL_HOOK__!.onCommitFiberRoot(
+ 1,
+ hostRoot.stateNode,
+ );
+}
+
+function causes(report: Report) {
+ return Object.fromEntries(report.causes.map((c) => [c.key, c.count]));
+}
+
+const ThemeContext = createContext("light");
+let setCount: Dispatch<SetStateAction<number>> = () => undefined;
+let setTheme: Dispatch<SetStateAction<string>> = () => undefined;
+
+function Leaf() {
+ return <span>leaf</span>;
+}
+
+const MemoLabel = memo(function Label({ value }: { value: number }) {
+ return <span>{value}</span>;
+});
+
+const MemoStatic = memo(function Static() {
+ return <Leaf />;
+});
+
+function ThemeReader() {
+ return <span>{useContext(ThemeContext)}</span>;
+}
+
+const MemoThemeBox = memo(function ThemeBox() {
+ return <ThemeReader />;
+});
+
+function Counter() {
+ const [count, update] = useState(0);
+ setCount = update;
+ return (
+ <div>
+ <Leaf />
+ <MemoLabel value={Math.floor(count / 2)} />
+ <MemoStatic />
+ </div>
+ );
+}
+
+function App() {
+ const [theme, update] = useState("light");
+ setTheme = update;
+ return (
+ <ThemeContext.Provider value={theme}>
+ <Counter />
+ <MemoThemeBox />
+ </ThemeContext.Provider>
+ );
+}
+
+describe("render-counter.js", () => {
+ let container: HTMLElement;
+ let root: Root;
+
+ beforeEach(() => {
+ delete testWindow.__renderCounter;
+ delete testWindow.__REACT_DEVTOOLS_GLOBAL_HOOK__;
+ container = document.createElement("div");
+ document.body.appendChild(container);
+ });
+
+ afterEach(() => {
+ act(() => root?.unmount());
+ container.remove();
+ });
+
+ function mount() {
+ const counter = loadCounter();
+ root = createRoot(container);
+ act(() => root.render(<App />));
+ commit(container);
+ return counter;
+ }
+
+ it("counts every component on mount with the mount cause", () => {
+ const report = mount().report();
+
+ expect(report.commits).toBe(1);
+ expect(causes(report)).toMatchObject({
+ "App mount": 1,
+ "Counter mount": 1,
+ "Leaf mount": 2,
+ "Label mount": 1,
+ "ThemeReader mount": 1,
+ });
+ });
+
+ it("names the state slot and skips memoised children whose props held", () => {
+ const counter = mount();
+ counter.reset();
+
+ act(() => setCount(1));
+ commit(container);
+ const report = counter.report();
+
+ expect(report.commits).toBe(1);
+ expect(causes(report)).toEqual({
+ "Counter state#0": 1,
+ "Leaf parent-same-props<-Counter": 1,
+ });
+ });
+
+ it("lists the changed props of a memoised child", () => {
+ const counter = mount();
+ act(() => setCount(1));
+ counter.reset();
+
+ act(() => setCount(2));
+ commit(container);
+
+ expect(causes(counter.report())).toEqual({
+ "Counter state#0": 1,
+ "Leaf parent-same-props<-Counter": 1,
+ "Label props:value": 1,
+ });
+ });
+
+ it("attributes a render under a bailed-out parent to context", () => {
+ const counter = mount();
+ counter.reset();
+
+ act(() => setTheme("dark"));
+ commit(container);
+ const byCause = causes(counter.report());
+
+ expect(byCause["ThemeReader context"]).toBe(1);
+ expect(byCause["ThemeBox context"]).toBeUndefined();
+ expect(byCause["Label props:value"]).toBeUndefined();
+ });
+
+ it("records nothing while stopped and starts again from zero after reset", () => {
+ const counter = mount();
+ counter.stop();
+ act(() => setCount(5));
+ commit(container);
+ expect(counter.report().commits).toBe(1);
+
+ counter.reset();
+ counter.start();
+ act(() => setCount(6));
+ commit(container);
+ expect(counter.report().commits).toBe(1);
+ expect(counter.report().totalRenders).toBeGreaterThan(0);
+ });
+
+ it("keeps calling an existing devtools hook", () => {
+ const previous = vi.fn();
+ testWindow.__REACT_DEVTOOLS_GLOBAL_HOOK__ = {
+ onCommitFiberRoot: previous,
+ };
+ loadCounter();
+ root = createRoot(container);
+ act(() => root.render(<App />));
+ commit(container);
+
+ expect(previous).toHaveBeenCalledTimes(1);
+ expect(testWindow.__renderCounter!.report().commits).toBe(1);
+ });
+});
diff --git a/autogpt_platform/frontend/scripts/perf/__tests__/report.test.ts b/autogpt_platform/frontend/scripts/perf/__tests__/report.test.ts
new file mode 100644
index 0000000000..4b45d4f2db
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/__tests__/report.test.ts
@@ -0,0 +1,117 @@
+import fs from "fs";
+import os from "os";
+import path from "path";
+import { describe, expect, it } from "vitest";
+import {
+ formatComparison,
+ formatDelta,
+ loadRuns,
+ median,
+ safeLabel,
+ spreadPercent,
+ summarize,
+ writeRun,
+ type RunResult,
+} from "../lib/report";
+
+function run(label: string, index: number, renders: number): RunResult {
+ return {
+ scenario: "copilot-stream-reply",
+ label,
+ run: index,
+ startedAt: `2026-01-05T09:00:0${index}.000Z`,
+ gitSha: "abcdef1234567890",
+ baseURL: "http://localhost:3000",
+ windowMs: 1000,
+ metrics: {
+ commits: 10,
+ totalRenders: renders,
+ rendersPerCommit: renders / 10,
+ maxRendersPerCommit: renders / 2,
+ scriptMs: renders / 4,
+ taskMs: 0,
+ layoutMs: 0,
+ recalcStyleMs: 0,
+ longTaskCount: 1,
+ longTaskMs: 60,
+ heapUsedMB: 80,
+ },
+ components: [
+ { key: "TimelineRow", count: renders / 2 },
+ { key: "ChatInput", count: index },
+ ],
+ causes: [{ key: "TimelineRow props:message", count: renders / 2 }],
+ pageErrors: 0,
+ };
+}
+
+describe("median", () => {
+ it("takes the middle value, or the mean of the two middle values", () => {
+ expect(median([3, 1, 2])).toBe(2);
+ expect(median([4, 1, 3, 2])).toBe(2.5);
+ expect(median([])).toBe(0);
+ });
+});
+
+describe("spreadPercent", () => {
+ it("is the range as a share of the median", () => {
+ expect(spreadPercent([95, 100, 105])).toBeCloseTo(10);
+ expect(spreadPercent([7])).toBe(0);
+ });
+});
+
+describe("formatDelta", () => {
+ it("shows the signed difference and percentage", () => {
+ expect(formatDelta(200, 50, 0)).toBe("-150 (-75.0%)");
+ expect(formatDelta(10, 12.5, 1)).toBe("+2.5 (+25.0%)");
+ expect(formatDelta(0, 0, 0)).toBe("0");
+ expect(formatDelta(0, 3, 0)).toBe("+3");
+ });
+});
+
+describe("summarize", () => {
+ it("takes per-metric medians and median counts per component", () => {
+ const summary = summarize([
+ run("before", 1, 100),
+ run("before", 2, 300),
+ run("before", 3, 200),
+ ]);
+ expect(summary.metrics.totalRenders).toBe(200);
+ expect(summary.components[0]).toEqual({ key: "TimelineRow", count: 100 });
+ expect(summary.components[1]).toEqual({ key: "ChatInput", count: 2 });
+ });
+});
+
+describe("formatComparison", () => {
+ it("prints both medians with the delta, rankings and raw runs", () => {
+ const output = formatComparison({
+ scenario: "copilot-stream-reply",
+ a: { label: "before", runs: [run("before", 1, 2000)] },
+ b: { label: "after", runs: [run("after", 1, 200)] },
+ });
+ expect(output).toContain("| metric | before | after | Δ |");
+ expect(output).toContain(
+ "| total renders | 2,000 | 200 | -1,800 (-90.0%) |",
+ );
+ expect(output).toContain("| `TimelineRow` | 1,000 | 100 | -900 (-90.0%) |");
+ expect(output).toContain("Raw runs");
+ });
+});
+
+describe("run files", () => {
+ it("round-trips runs and filters them by label", () => {
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), "perf-report-"));
+ writeRun(dir, run("before", 2, 10));
+ writeRun(dir, run("before", 1, 20));
+ writeRun(dir, run("before-x", 1, 30));
+ const loaded = loadRuns(dir, "before");
+ expect(loaded.map((result) => result.run)).toEqual([1, 2]);
+ expect(loadRuns(path.join(dir, "missing"), "before")).toEqual([]);
+ fs.rmSync(dir, { recursive: true });
+ });
+
+ it("rejects labels that are not safe file name parts", () => {
+ expect(safeLabel("before-fix_2")).toBe("before-fix_2");
+ expect(() => safeLabel("../before")).toThrow();
+ });
+});
diff --git a/autogpt_platform/frontend/scripts/perf/__tests__/routes.test.ts b/autogpt_platform/frontend/scripts/perf/__tests__/routes.test.ts
new file mode 100644
index 0000000000..8853df2e3b
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/__tests__/routes.test.ts
@@ -0,0 +1,59 @@
+import { describe, expect, it } from "vitest";
+import { matchRoute, type RouteHandlers } from "../lib/routes";
+
+const handler = async () => undefined;
+const all: RouteHandlers = {
+ featureFlags: handler,
+ onboardingCompleted: handler,
+ chatStream: handler,
+ chatSessionList: handler,
+ chatSession: handler,
+ chatSessionChild: handler,
+ graphExecution: handler,
+ graph: handler,
+ libraryAgents: handler,
+ executions: handler,
+};
+
+function nameOf(url: string, handlers: RouteHandlers = all) {
+ return matchRoute(url, handlers)?.name ?? null;
+}
+
+describe("matchRoute", () => {
+ it("routes the copilot stream on the backend host and through the proxy", () => {
+ expect(nameOf("http://localhost:8006/api/chat/sessions/s1/stream")).toBe(
+ "chatStream",
+ );
+ expect(
+ nameOf("http://localhost:3000/api/proxy/api/chat/sessions/s1/stream"),
+ ).toBe("chatStream");
+ });
+
+ it("tells the session list, a session and its sub-resources apart", () => {
+ const base = "http://localhost:3000/api/proxy/api/chat/sessions";
+ expect(nameOf(`${base}?limit=50&offset=0`)).toBe("chatSessionList");
+ expect(nameOf(`${base}/s1`)).toBe("chatSession");
+ expect(nameOf(`${base}/s1?limit=50&before_sequence=9`)).toBe("chatSession");
+ const child = matchRoute(`${base}/s1/messages/pending`, all);
+ expect(child?.name).toBe("chatSessionChild");
+ expect(child?.match[2]).toBe("messages/pending");
+ });
+
+ it("matches an execution before its graph", () => {
+ const base = "http://localhost:3000/api/proxy/api/graphs/g1";
+ expect(nameOf(`${base}/executions/e1`)).toBe("graphExecution");
+ expect(nameOf(`${base}?version=1`)).toBe("graph");
+ });
+
+ it("leaves pages, other endpoints and unhandled routes alone", () => {
+ expect(nameOf("http://localhost:3000/home?sessionId=s1")).toBeNull();
+ expect(
+ nameOf("http://localhost:3000/api/proxy/api/executions/cost-summary"),
+ ).toBeNull();
+ expect(
+ nameOf("http://localhost:3000/api/proxy/api/executions", {
+ graph: handler,
+ }),
+ ).toBeNull();
+ });
+});
diff --git a/autogpt_platform/frontend/scripts/perf/__tests__/stream-server.test.ts b/autogpt_platform/frontend/scripts/perf/__tests__/stream-server.test.ts
new file mode 100644
index 0000000000..392bcd73e1
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/__tests__/stream-server.test.ts
@@ -0,0 +1,43 @@
+import { afterEach, describe, expect, it } from "vitest";
+import { startStreamServer, type StreamServer } from "../lib/stream-server";
+
+const FIXTURE = "reply-20-lines.sse";
+
+describe("stream server", () => {
+ let server: StreamServer | null = null;
+
+ afterEach(async () => {
+ await server?.close();
+ server = null;
+ });
+
+ it("gives every stream its own tag for the life of the server", async () => {
+ server = await startStreamServer();
+ const first = server.open({ fixture: FIXTURE, paceMs: 30 });
+ const second = server.open({ fixture: FIXTURE, paceMs: 30 });
+
+ expect(first.tag).not.toBe(second.tag);
+ expect(first.url).not.toBe(second.url);
+ });
+
+ it("does not treat a new stream as done because an earlier one finished", async () => {
+ server = await startStreamServer();
+ const { tag } = server.open({ fixture: FIXTURE, paceMs: 30 });
+ const settled = await Promise.race([
+ server.waitForDone(tag, 200).then(
+ () => "resolved",
+ () => "timed out",
+ ),
+ new Promise((resolve) => setTimeout(() => resolve("pending"), 100)),
+ ]);
+
+ expect(settled).toBe("pending");
+ });
+
+ it("rejects an unknown fixture name", async () => {
+ server = await startStreamServer();
+ expect(() =>
+ server!.open({ fixture: "../secrets.sse", paceMs: 30 }),
+ ).toThrow("Bad fixture name");
+ });
+});
diff --git a/autogpt_platform/frontend/scripts/perf/compare.ts b/autogpt_platform/frontend/scripts/perf/compare.ts
new file mode 100644
index 0000000000..f71032fa18
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/compare.ts
@@ -0,0 +1,65 @@
+/**
+ * Prints the medians of two labelled sets of `pnpm perf` runs side by side,
+ * one markdown table per scenario, ready to paste into a PR. With only --a,
+ * prints that set's medians, spread and rankings (used for the baseline).
+ *
+ * pnpm perf:compare --a before --b after [--scenario copilot-stream-reply]
+ * pnpm perf:compare --a baseline
+ */
+import fs from "fs";
+import { parseArgs } from "util";
+import { PERF_OUTPUT_DIR, scenarioOutputDir } from "./lib/paths";
+import {
+ formatComparison,
+ formatSummary,
+ loadRuns,
+ safeLabel,
+} from "./lib/report";
+
+function main() {
+ const { values } = parseArgs({
+ options: {
+ a: { type: "string" },
+ b: { type: "string" },
+ scenario: { type: "string" },
+ },
+ });
+ if (!values.a) throw new Error("Pass --a <label> [--b <label>].");
+ const a = safeLabel(values.a);
+ const b = values.b ? safeLabel(values.b) : null;
+ const scenarios = values.scenario
+ ? [values.scenario]
+ : fs.existsSync(PERF_OUTPUT_DIR)
+ ? fs.readdirSync(PERF_OUTPUT_DIR).sort()
+ : [];
+
+ const sections = scenarios.flatMap((scenario) => {
+ const dir = scenarioOutputDir(scenario);
+ const runsA = loadRuns(dir, a);
+ if (runsA.length === 0) return [];
+ if (!b) return [formatSummary({ label: a, runs: runsA })];
+ const runsB = loadRuns(dir, b);
+ if (runsB.length === 0) return [];
+ return [
+ formatComparison({
+ scenario,
+ a: { label: a, runs: runsA },
+ b: { label: b, runs: runsB },
+ }),
+ ];
+ });
+ if (sections.length === 0) {
+ const labels = b ? `both "${a}" and "${b}"` : `"${a}"`;
+ throw new Error(
+ `No scenario in ${PERF_OUTPUT_DIR} has runs labelled ${labels}.`,
+ );
+ }
+ console.log(sections.join("\n\n"));
+}
+
+try {
+ main();
+} catch (error) {
+ console.error(error instanceof Error ? error.message : error);
+ process.exit(1);
+}
diff --git a/autogpt_platform/frontend/scripts/perf/fixtures/generate.ts b/autogpt_platform/frontend/scripts/perf/fixtures/generate.ts
new file mode 100644
index 0000000000..ceb5f9bd82
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/fixtures/generate.ts
@@ -0,0 +1,230 @@
+/**
+ * Writes the synthetic copilot fixtures: a 200-row chat session and a
+ * 20-line streamed reply. Deterministic, so re-running produces the same
+ * files. To capture real wire data from a running stack instead, use
+ * scripts/perf/record.ts.
+ *
+ * npx tsx scripts/perf/fixtures/generate.ts
+ */
+import fs from "fs";
+import path from "path";
+import { FIXTURES_DIR } from "../lib/paths";
+
+const SESSION_ROWS = 200;
+const START_TIME = Date.parse("2026-01-05T09:00:00.000Z");
+const WORDS_PER_DELTA = 1;
+
+interface ToolCall {
+ id: string;
+ type: "function";
+ function: { name: string; arguments: string };
+}
+
+interface SessionRow {
+ id: string;
+ role: "user" | "assistant" | "tool";
+ content: string;
+ tool_calls: ToolCall[] | null;
+ tool_call_id: string | null;
+ sequence: number;
+ duration_ms: number | null;
+ created_at: string;
+ metadata: Record<string, never>;
+}
+
+const TOPICS = [
+ "weekly sales report",
+ "customer onboarding emails",
+ "competitor price tracking",
+ "support ticket triage",
+ "blog post outline",
+ "invoice reconciliation",
+ "meeting notes summary",
+ "social media calendar",
+];
+
+function plainAnswer(turn: number, topic: string) {
+ return [
+ `Here is what I found for the ${topic}. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.`,
+ "",
+ `I would keep the current plan and check again on Monday. If the trend holds, we can move turn ${turn} into the regular schedule.`,
+ ].join("\n");
+}
+
+function codeAnswer(turn: number, topic: string) {
+ return [
+ `This script prepares the ${topic} data:`,
+ "",
+ "```ts",
+ `export function summarise(rows: { day: string; total: number }[]) {`,
+ ` const total = rows.reduce((sum, row) => sum + row.total, 0);`,
+ ` const best = rows.reduce((a, b) => (b.total > a.total ? b : a));`,
+ ` return { total, best: best.day, turn: ${turn} };`,
+ `}`,
+ "```",
+ "",
+ "Run it once per day and paste the result here.",
+ ].join("\n");
+}
+
+function tableAnswer(turn: number, topic: string) {
+ return [
+ `Breakdown for the ${topic}:`,
+ "",
+ "| Day | Items | Change |",
+ "| --- | ---: | ---: |",
+ `| Monday | ${120 + turn} | +4% |`,
+ `| Tuesday | ${98 + turn} | -2% |`,
+ `| Wednesday | ${143 + turn} | +11% |`,
+ `| Thursday | ${160 + turn} | +9% |`,
+ "",
+ "Wednesday and Thursday carry most of the week.",
+ ].join("\n");
+}
+
+function listAnswer(turn: number, topic: string) {
+ return [
+ `Next steps for the ${topic}:`,
+ "",
+ "1. Pull the latest export from the shared drive.",
+ "2. Remove duplicate rows and empty lines.",
+ `3. Compare against the numbers from turn ${Math.max(1, turn - 1)}.`,
+ "4. Send the short summary to the team channel.",
+ "",
+ "- **Owner:** you",
+ "- **Due:** Friday",
+ ].join("\n");
+}
+
+const ANSWERS = [plainAnswer, codeAnswer, tableAnswer, listAnswer];
+
+function rowFactory() {
+ let sequence = 0;
+ return function row(
+ role: SessionRow["role"],
+ content: string,
+ extra: Partial<SessionRow> = {},
+ ): SessionRow {
+ const current = sequence++;
+ return {
+ id: `perf-msg-${String(current).padStart(4, "0")}`,
+ role,
+ content,
+ tool_calls: null,
+ tool_call_id: null,
+ sequence: current,
+ duration_ms: role === "assistant" ? 1800 + (current % 7) * 150 : null,
+ created_at: new Date(START_TIME + current * 45_000).toISOString(),
+ metadata: {},
+ ...extra,
+ };
+ };
+}
+
+function toolTurn(
+ row: ReturnType<typeof rowFactory>,
+ turn: number,
+ topic: string,
+) {
+ const callID = `call_perf_${turn}`;
+ return [
+ row("assistant", "", {
+ tool_calls: [
+ {
+ id: callID,
+ type: "function",
+ function: {
+ name: "perf_lookup",
+ arguments: JSON.stringify({ query: topic, page: turn }),
+ },
+ },
+ ],
+ }),
+ row("tool", JSON.stringify({ query: topic, results: 3, turn }), {
+ tool_call_id: callID,
+ }),
+ row("assistant", plainAnswer(turn, topic)),
+ ];
+}
+
+export function buildSessionRows(count = SESSION_ROWS): SessionRow[] {
+ const row = rowFactory();
+ const rows: SessionRow[] = [];
+ for (let turn = 1; rows.length < count; turn++) {
+ const topic = TOPICS[turn % TOPICS.length];
+ rows.push(row("user", `Turn ${turn}: can you help with the ${topic}?`));
+ if (turn % 5 === 0) {
+ rows.push(...toolTurn(row, turn, topic));
+ } else {
+ rows.push(row("assistant", ANSWERS[turn % ANSWERS.length](turn, topic)));
+ }
+ }
+ return rows.slice(0, count);
+}
+
+export const REPLY_20_LINES = [
+ "Sure. Here is a quick plan for the launch week.",
+ "",
+ "## Goals",
+ "",
+ "- Ship the new onboarding flow to every new account.",
+ "- Keep the support queue under one day of waiting time.",
+ "- Collect feedback from the first fifty teams.",
+ "",
+ "## Script to check sign-ups",
+ "",
+ "```ts",
+ "export function countSignups(events: { type: string }[]) {",
+ ' return events.filter((event) => event.type === "signup").length;',
+ "}",
+ "```",
+ "",
+ "1. Run the script every morning and post the number.",
+ "2. Flag any day that drops more than ten percent.",
+ "3. Share a short summary with the team on Friday.",
+ "Let me know if you want me to set up the daily check for you.",
+].join("\n");
+
+export function buildReplyStream(text: string, messageID: string) {
+ const words = text.match(/\S+\s*|\s+/g) ?? [];
+ const deltas: string[] = [];
+ for (let i = 0; i < words.length; i += WORDS_PER_DELTA) {
+ deltas.push(words.slice(i, i + WORDS_PER_DELTA).join(""));
+ }
+ const events: unknown[] = [
+ { type: "start", messageId: messageID },
+ { type: "start-step" },
+ { type: "text-start", id: "perf-text-1" },
+ ...deltas.map((delta) => ({
+ type: "text-delta",
+ id: "perf-text-1",
+ delta,
+ })),
+ { type: "text-end", id: "perf-text-1" },
+ { type: "finish-step" },
+ { type: "finish" },
+ ];
+ return [
+ ...events.map((event) => `data: ${JSON.stringify(event)}`),
+ "data: [DONE]",
+ ]
+ .map((frame) => `${frame}\n\n`)
+ .join("");
+}
+
+function main() {
+ fs.mkdirSync(FIXTURES_DIR, { recursive: true });
+ const sessionFile = path.join(FIXTURES_DIR, "session-200.json");
+ fs.writeFileSync(
+ sessionFile,
+ `${JSON.stringify({ messages: buildSessionRows() }, null, 2)}\n`,
+ );
+ const replyFile = path.join(FIXTURES_DIR, "reply-20-lines.sse");
+ fs.writeFileSync(
+ replyFile,
+ buildReplyStream(REPLY_20_LINES, "perf-reply-20-lines"),
+ );
+ console.log(`wrote ${sessionFile}\nwrote ${replyFile}`);
+}
+
+if (require.main === module) main();
diff --git a/autogpt_platform/frontend/scripts/perf/fixtures/reply-20-lines.sse b/autogpt_platform/frontend/scripts/perf/fixtures/reply-20-lines.sse
new file mode 100644
index 0000000000..d851247e95
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/fixtures/reply-20-lines.sse
@@ -0,0 +1,230 @@
+data: {"type":"start","messageId":"perf-reply-20-lines"}
+
+data: {"type":"start-step"}
+
+data: {"type":"text-start","id":"perf-text-1"}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"Sure. "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"Here "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"is "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"a "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"quick "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"plan "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"for "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"the "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"launch "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"week.\n\n"}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"## "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"Goals\n\n"}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"- "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"Ship "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"the "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"new "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"onboarding "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"flow "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"to "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"every "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"new "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"account.\n"}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"- "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"Keep "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"the "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"support "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"queue "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"under "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"one "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"day "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"of "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"waiting "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"time.\n"}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"- "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"Collect "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"feedback "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"from "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"the "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"first "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"fifty "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"teams.\n\n"}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"## "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"Script "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"to "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"check "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"sign-ups\n\n"}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"```ts\n"}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"export "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"function "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"countSignups(events: "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"{ "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"type: "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"string "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"}[]) "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"{\n "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"return "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"events.filter((event) "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"=> "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"event.type "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"=== "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"\"signup\").length;\n"}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"}\n"}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"```\n\n"}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"1. "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"Run "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"the "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"script "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"every "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"morning "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"and "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"post "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"the "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"number.\n"}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"2. "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"Flag "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"any "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"day "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"that "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"drops "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"more "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"than "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"ten "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"percent.\n"}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"3. "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"Share "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"a "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"short "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"summary "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"with "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"the "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"team "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"on "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"Friday.\n"}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"Let "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"me "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"know "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"if "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"you "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"want "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"me "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"to "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"set "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"up "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"the "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"daily "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"check "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"for "}
+
+data: {"type":"text-delta","id":"perf-text-1","delta":"you."}
+
+data: {"type":"text-end","id":"perf-text-1"}
+
+data: {"type":"finish-step"}
+
+data: {"type":"finish"}
+
+data: [DONE]
+
diff --git a/autogpt_platform/frontend/scripts/perf/fixtures/session-200.json b/autogpt_platform/frontend/scripts/perf/fixtures/session-200.json
new file mode 100644
index 0000000000..bc78cd07fe
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/fixtures/session-200.json
@@ -0,0 +1,2348 @@
+{
+ "messages": [
+ {
+ "id": "perf-msg-0000",
+ "role": "user",
+ "content": "Turn 1: can you help with the customer onboarding emails?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 0,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:00:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0001",
+ "role": "assistant",
+ "content": "This script prepares the customer onboarding emails data:\n\n```ts\nexport function summarise(rows: { day: string; total: number }[]) {\n const total = rows.reduce((sum, row) => sum + row.total, 0);\n const best = rows.reduce((a, b) => (b.total > a.total ? b : a));\n return { total, best: best.day, turn: 1 };\n}\n```\n\nRun it once per day and paste the result here.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 1,
+ "duration_ms": 1950,
+ "created_at": "2026-01-05T09:00:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0002",
+ "role": "user",
+ "content": "Turn 2: can you help with the competitor price tracking?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 2,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:01:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0003",
+ "role": "assistant",
+ "content": "Breakdown for the competitor price tracking:\n\n| Day | Items | Change |\n| --- | ---: | ---: |\n| Monday | 122 | +4% |\n| Tuesday | 100 | -2% |\n| Wednesday | 145 | +11% |\n| Thursday | 162 | +9% |\n\nWednesday and Thursday carry most of the week.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 3,
+ "duration_ms": 2250,
+ "created_at": "2026-01-05T09:02:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0004",
+ "role": "user",
+ "content": "Turn 3: can you help with the support ticket triage?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 4,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:03:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0005",
+ "role": "assistant",
+ "content": "Next steps for the support ticket triage:\n\n1. Pull the latest export from the shared drive.\n2. Remove duplicate rows and empty lines.\n3. Compare against the numbers from turn 2.\n4. Send the short summary to the team channel.\n\n- **Owner:** you\n- **Due:** Friday",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 5,
+ "duration_ms": 2550,
+ "created_at": "2026-01-05T09:03:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0006",
+ "role": "user",
+ "content": "Turn 4: can you help with the blog post outline?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 6,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:04:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0007",
+ "role": "assistant",
+ "content": "Here is what I found for the blog post outline. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 4 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 7,
+ "duration_ms": 1800,
+ "created_at": "2026-01-05T09:05:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0008",
+ "role": "user",
+ "content": "Turn 5: can you help with the invoice reconciliation?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 8,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:06:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0009",
+ "role": "assistant",
+ "content": "",
+ "tool_calls": [
+ {
+ "id": "call_perf_5",
+ "type": "function",
+ "function": {
+ "name": "perf_lookup",
+ "arguments": "{\"query\":\"invoice reconciliation\",\"page\":5}"
+ }
+ }
+ ],
+ "tool_call_id": null,
+ "sequence": 9,
+ "duration_ms": 2100,
+ "created_at": "2026-01-05T09:06:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0010",
+ "role": "tool",
+ "content": "{\"query\":\"invoice reconciliation\",\"results\":3,\"turn\":5}",
+ "tool_calls": null,
+ "tool_call_id": "call_perf_5",
+ "sequence": 10,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:07:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0011",
+ "role": "assistant",
+ "content": "Here is what I found for the invoice reconciliation. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 5 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 11,
+ "duration_ms": 2400,
+ "created_at": "2026-01-05T09:08:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0012",
+ "role": "user",
+ "content": "Turn 6: can you help with the meeting notes summary?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 12,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:09:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0013",
+ "role": "assistant",
+ "content": "Breakdown for the meeting notes summary:\n\n| Day | Items | Change |\n| --- | ---: | ---: |\n| Monday | 126 | +4% |\n| Tuesday | 104 | -2% |\n| Wednesday | 149 | +11% |\n| Thursday | 166 | +9% |\n\nWednesday and Thursday carry most of the week.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 13,
+ "duration_ms": 2700,
+ "created_at": "2026-01-05T09:09:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0014",
+ "role": "user",
+ "content": "Turn 7: can you help with the social media calendar?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 14,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:10:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0015",
+ "role": "assistant",
+ "content": "Next steps for the social media calendar:\n\n1. Pull the latest export from the shared drive.\n2. Remove duplicate rows and empty lines.\n3. Compare against the numbers from turn 6.\n4. Send the short summary to the team channel.\n\n- **Owner:** you\n- **Due:** Friday",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 15,
+ "duration_ms": 1950,
+ "created_at": "2026-01-05T09:11:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0016",
+ "role": "user",
+ "content": "Turn 8: can you help with the weekly sales report?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 16,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:12:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0017",
+ "role": "assistant",
+ "content": "Here is what I found for the weekly sales report. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 8 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 17,
+ "duration_ms": 2250,
+ "created_at": "2026-01-05T09:12:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0018",
+ "role": "user",
+ "content": "Turn 9: can you help with the customer onboarding emails?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 18,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:13:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0019",
+ "role": "assistant",
+ "content": "This script prepares the customer onboarding emails data:\n\n```ts\nexport function summarise(rows: { day: string; total: number }[]) {\n const total = rows.reduce((sum, row) => sum + row.total, 0);\n const best = rows.reduce((a, b) => (b.total > a.total ? b : a));\n return { total, best: best.day, turn: 9 };\n}\n```\n\nRun it once per day and paste the result here.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 19,
+ "duration_ms": 2550,
+ "created_at": "2026-01-05T09:14:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0020",
+ "role": "user",
+ "content": "Turn 10: can you help with the competitor price tracking?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 20,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:15:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0021",
+ "role": "assistant",
+ "content": "",
+ "tool_calls": [
+ {
+ "id": "call_perf_10",
+ "type": "function",
+ "function": {
+ "name": "perf_lookup",
+ "arguments": "{\"query\":\"competitor price tracking\",\"page\":10}"
+ }
+ }
+ ],
+ "tool_call_id": null,
+ "sequence": 21,
+ "duration_ms": 1800,
+ "created_at": "2026-01-05T09:15:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0022",
+ "role": "tool",
+ "content": "{\"query\":\"competitor price tracking\",\"results\":3,\"turn\":10}",
+ "tool_calls": null,
+ "tool_call_id": "call_perf_10",
+ "sequence": 22,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:16:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0023",
+ "role": "assistant",
+ "content": "Here is what I found for the competitor price tracking. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 10 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 23,
+ "duration_ms": 2100,
+ "created_at": "2026-01-05T09:17:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0024",
+ "role": "user",
+ "content": "Turn 11: can you help with the support ticket triage?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 24,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:18:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0025",
+ "role": "assistant",
+ "content": "Next steps for the support ticket triage:\n\n1. Pull the latest export from the shared drive.\n2. Remove duplicate rows and empty lines.\n3. Compare against the numbers from turn 10.\n4. Send the short summary to the team channel.\n\n- **Owner:** you\n- **Due:** Friday",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 25,
+ "duration_ms": 2400,
+ "created_at": "2026-01-05T09:18:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0026",
+ "role": "user",
+ "content": "Turn 12: can you help with the blog post outline?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 26,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:19:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0027",
+ "role": "assistant",
+ "content": "Here is what I found for the blog post outline. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 12 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 27,
+ "duration_ms": 2700,
+ "created_at": "2026-01-05T09:20:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0028",
+ "role": "user",
+ "content": "Turn 13: can you help with the invoice reconciliation?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 28,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:21:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0029",
+ "role": "assistant",
+ "content": "This script prepares the invoice reconciliation data:\n\n```ts\nexport function summarise(rows: { day: string; total: number }[]) {\n const total = rows.reduce((sum, row) => sum + row.total, 0);\n const best = rows.reduce((a, b) => (b.total > a.total ? b : a));\n return { total, best: best.day, turn: 13 };\n}\n```\n\nRun it once per day and paste the result here.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 29,
+ "duration_ms": 1950,
+ "created_at": "2026-01-05T09:21:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0030",
+ "role": "user",
+ "content": "Turn 14: can you help with the meeting notes summary?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 30,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:22:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0031",
+ "role": "assistant",
+ "content": "Breakdown for the meeting notes summary:\n\n| Day | Items | Change |\n| --- | ---: | ---: |\n| Monday | 134 | +4% |\n| Tuesday | 112 | -2% |\n| Wednesday | 157 | +11% |\n| Thursday | 174 | +9% |\n\nWednesday and Thursday carry most of the week.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 31,
+ "duration_ms": 2250,
+ "created_at": "2026-01-05T09:23:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0032",
+ "role": "user",
+ "content": "Turn 15: can you help with the social media calendar?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 32,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:24:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0033",
+ "role": "assistant",
+ "content": "",
+ "tool_calls": [
+ {
+ "id": "call_perf_15",
+ "type": "function",
+ "function": {
+ "name": "perf_lookup",
+ "arguments": "{\"query\":\"social media calendar\",\"page\":15}"
+ }
+ }
+ ],
+ "tool_call_id": null,
+ "sequence": 33,
+ "duration_ms": 2550,
+ "created_at": "2026-01-05T09:24:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0034",
+ "role": "tool",
+ "content": "{\"query\":\"social media calendar\",\"results\":3,\"turn\":15}",
+ "tool_calls": null,
+ "tool_call_id": "call_perf_15",
+ "sequence": 34,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:25:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0035",
+ "role": "assistant",
+ "content": "Here is what I found for the social media calendar. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 15 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 35,
+ "duration_ms": 1800,
+ "created_at": "2026-01-05T09:26:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0036",
+ "role": "user",
+ "content": "Turn 16: can you help with the weekly sales report?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 36,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:27:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0037",
+ "role": "assistant",
+ "content": "Here is what I found for the weekly sales report. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 16 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 37,
+ "duration_ms": 2100,
+ "created_at": "2026-01-05T09:27:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0038",
+ "role": "user",
+ "content": "Turn 17: can you help with the customer onboarding emails?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 38,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:28:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0039",
+ "role": "assistant",
+ "content": "This script prepares the customer onboarding emails data:\n\n```ts\nexport function summarise(rows: { day: string; total: number }[]) {\n const total = rows.reduce((sum, row) => sum + row.total, 0);\n const best = rows.reduce((a, b) => (b.total > a.total ? b : a));\n return { total, best: best.day, turn: 17 };\n}\n```\n\nRun it once per day and paste the result here.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 39,
+ "duration_ms": 2400,
+ "created_at": "2026-01-05T09:29:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0040",
+ "role": "user",
+ "content": "Turn 18: can you help with the competitor price tracking?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 40,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:30:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0041",
+ "role": "assistant",
+ "content": "Breakdown for the competitor price tracking:\n\n| Day | Items | Change |\n| --- | ---: | ---: |\n| Monday | 138 | +4% |\n| Tuesday | 116 | -2% |\n| Wednesday | 161 | +11% |\n| Thursday | 178 | +9% |\n\nWednesday and Thursday carry most of the week.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 41,
+ "duration_ms": 2700,
+ "created_at": "2026-01-05T09:30:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0042",
+ "role": "user",
+ "content": "Turn 19: can you help with the support ticket triage?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 42,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:31:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0043",
+ "role": "assistant",
+ "content": "Next steps for the support ticket triage:\n\n1. Pull the latest export from the shared drive.\n2. Remove duplicate rows and empty lines.\n3. Compare against the numbers from turn 18.\n4. Send the short summary to the team channel.\n\n- **Owner:** you\n- **Due:** Friday",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 43,
+ "duration_ms": 1950,
+ "created_at": "2026-01-05T09:32:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0044",
+ "role": "user",
+ "content": "Turn 20: can you help with the blog post outline?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 44,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:33:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0045",
+ "role": "assistant",
+ "content": "",
+ "tool_calls": [
+ {
+ "id": "call_perf_20",
+ "type": "function",
+ "function": {
+ "name": "perf_lookup",
+ "arguments": "{\"query\":\"blog post outline\",\"page\":20}"
+ }
+ }
+ ],
+ "tool_call_id": null,
+ "sequence": 45,
+ "duration_ms": 2250,
+ "created_at": "2026-01-05T09:33:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0046",
+ "role": "tool",
+ "content": "{\"query\":\"blog post outline\",\"results\":3,\"turn\":20}",
+ "tool_calls": null,
+ "tool_call_id": "call_perf_20",
+ "sequence": 46,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:34:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0047",
+ "role": "assistant",
+ "content": "Here is what I found for the blog post outline. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 20 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 47,
+ "duration_ms": 2550,
+ "created_at": "2026-01-05T09:35:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0048",
+ "role": "user",
+ "content": "Turn 21: can you help with the invoice reconciliation?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 48,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:36:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0049",
+ "role": "assistant",
+ "content": "This script prepares the invoice reconciliation data:\n\n```ts\nexport function summarise(rows: { day: string; total: number }[]) {\n const total = rows.reduce((sum, row) => sum + row.total, 0);\n const best = rows.reduce((a, b) => (b.total > a.total ? b : a));\n return { total, best: best.day, turn: 21 };\n}\n```\n\nRun it once per day and paste the result here.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 49,
+ "duration_ms": 1800,
+ "created_at": "2026-01-05T09:36:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0050",
+ "role": "user",
+ "content": "Turn 22: can you help with the meeting notes summary?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 50,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:37:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0051",
+ "role": "assistant",
+ "content": "Breakdown for the meeting notes summary:\n\n| Day | Items | Change |\n| --- | ---: | ---: |\n| Monday | 142 | +4% |\n| Tuesday | 120 | -2% |\n| Wednesday | 165 | +11% |\n| Thursday | 182 | +9% |\n\nWednesday and Thursday carry most of the week.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 51,
+ "duration_ms": 2100,
+ "created_at": "2026-01-05T09:38:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0052",
+ "role": "user",
+ "content": "Turn 23: can you help with the social media calendar?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 52,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:39:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0053",
+ "role": "assistant",
+ "content": "Next steps for the social media calendar:\n\n1. Pull the latest export from the shared drive.\n2. Remove duplicate rows and empty lines.\n3. Compare against the numbers from turn 22.\n4. Send the short summary to the team channel.\n\n- **Owner:** you\n- **Due:** Friday",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 53,
+ "duration_ms": 2400,
+ "created_at": "2026-01-05T09:39:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0054",
+ "role": "user",
+ "content": "Turn 24: can you help with the weekly sales report?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 54,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:40:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0055",
+ "role": "assistant",
+ "content": "Here is what I found for the weekly sales report. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 24 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 55,
+ "duration_ms": 2700,
+ "created_at": "2026-01-05T09:41:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0056",
+ "role": "user",
+ "content": "Turn 25: can you help with the customer onboarding emails?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 56,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:42:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0057",
+ "role": "assistant",
+ "content": "",
+ "tool_calls": [
+ {
+ "id": "call_perf_25",
+ "type": "function",
+ "function": {
+ "name": "perf_lookup",
+ "arguments": "{\"query\":\"customer onboarding emails\",\"page\":25}"
+ }
+ }
+ ],
+ "tool_call_id": null,
+ "sequence": 57,
+ "duration_ms": 1950,
+ "created_at": "2026-01-05T09:42:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0058",
+ "role": "tool",
+ "content": "{\"query\":\"customer onboarding emails\",\"results\":3,\"turn\":25}",
+ "tool_calls": null,
+ "tool_call_id": "call_perf_25",
+ "sequence": 58,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:43:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0059",
+ "role": "assistant",
+ "content": "Here is what I found for the customer onboarding emails. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 25 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 59,
+ "duration_ms": 2250,
+ "created_at": "2026-01-05T09:44:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0060",
+ "role": "user",
+ "content": "Turn 26: can you help with the competitor price tracking?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 60,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:45:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0061",
+ "role": "assistant",
+ "content": "Breakdown for the competitor price tracking:\n\n| Day | Items | Change |\n| --- | ---: | ---: |\n| Monday | 146 | +4% |\n| Tuesday | 124 | -2% |\n| Wednesday | 169 | +11% |\n| Thursday | 186 | +9% |\n\nWednesday and Thursday carry most of the week.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 61,
+ "duration_ms": 2550,
+ "created_at": "2026-01-05T09:45:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0062",
+ "role": "user",
+ "content": "Turn 27: can you help with the support ticket triage?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 62,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:46:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0063",
+ "role": "assistant",
+ "content": "Next steps for the support ticket triage:\n\n1. Pull the latest export from the shared drive.\n2. Remove duplicate rows and empty lines.\n3. Compare against the numbers from turn 26.\n4. Send the short summary to the team channel.\n\n- **Owner:** you\n- **Due:** Friday",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 63,
+ "duration_ms": 1800,
+ "created_at": "2026-01-05T09:47:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0064",
+ "role": "user",
+ "content": "Turn 28: can you help with the blog post outline?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 64,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:48:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0065",
+ "role": "assistant",
+ "content": "Here is what I found for the blog post outline. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 28 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 65,
+ "duration_ms": 2100,
+ "created_at": "2026-01-05T09:48:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0066",
+ "role": "user",
+ "content": "Turn 29: can you help with the invoice reconciliation?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 66,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:49:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0067",
+ "role": "assistant",
+ "content": "This script prepares the invoice reconciliation data:\n\n```ts\nexport function summarise(rows: { day: string; total: number }[]) {\n const total = rows.reduce((sum, row) => sum + row.total, 0);\n const best = rows.reduce((a, b) => (b.total > a.total ? b : a));\n return { total, best: best.day, turn: 29 };\n}\n```\n\nRun it once per day and paste the result here.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 67,
+ "duration_ms": 2400,
+ "created_at": "2026-01-05T09:50:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0068",
+ "role": "user",
+ "content": "Turn 30: can you help with the meeting notes summary?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 68,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:51:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0069",
+ "role": "assistant",
+ "content": "",
+ "tool_calls": [
+ {
+ "id": "call_perf_30",
+ "type": "function",
+ "function": {
+ "name": "perf_lookup",
+ "arguments": "{\"query\":\"meeting notes summary\",\"page\":30}"
+ }
+ }
+ ],
+ "tool_call_id": null,
+ "sequence": 69,
+ "duration_ms": 2700,
+ "created_at": "2026-01-05T09:51:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0070",
+ "role": "tool",
+ "content": "{\"query\":\"meeting notes summary\",\"results\":3,\"turn\":30}",
+ "tool_calls": null,
+ "tool_call_id": "call_perf_30",
+ "sequence": 70,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:52:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0071",
+ "role": "assistant",
+ "content": "Here is what I found for the meeting notes summary. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 30 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 71,
+ "duration_ms": 1950,
+ "created_at": "2026-01-05T09:53:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0072",
+ "role": "user",
+ "content": "Turn 31: can you help with the social media calendar?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 72,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:54:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0073",
+ "role": "assistant",
+ "content": "Next steps for the social media calendar:\n\n1. Pull the latest export from the shared drive.\n2. Remove duplicate rows and empty lines.\n3. Compare against the numbers from turn 30.\n4. Send the short summary to the team channel.\n\n- **Owner:** you\n- **Due:** Friday",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 73,
+ "duration_ms": 2250,
+ "created_at": "2026-01-05T09:54:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0074",
+ "role": "user",
+ "content": "Turn 32: can you help with the weekly sales report?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 74,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:55:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0075",
+ "role": "assistant",
+ "content": "Here is what I found for the weekly sales report. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 32 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 75,
+ "duration_ms": 2550,
+ "created_at": "2026-01-05T09:56:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0076",
+ "role": "user",
+ "content": "Turn 33: can you help with the customer onboarding emails?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 76,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:57:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0077",
+ "role": "assistant",
+ "content": "This script prepares the customer onboarding emails data:\n\n```ts\nexport function summarise(rows: { day: string; total: number }[]) {\n const total = rows.reduce((sum, row) => sum + row.total, 0);\n const best = rows.reduce((a, b) => (b.total > a.total ? b : a));\n return { total, best: best.day, turn: 33 };\n}\n```\n\nRun it once per day and paste the result here.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 77,
+ "duration_ms": 1800,
+ "created_at": "2026-01-05T09:57:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0078",
+ "role": "user",
+ "content": "Turn 34: can you help with the competitor price tracking?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 78,
+ "duration_ms": null,
+ "created_at": "2026-01-05T09:58:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0079",
+ "role": "assistant",
+ "content": "Breakdown for the competitor price tracking:\n\n| Day | Items | Change |\n| --- | ---: | ---: |\n| Monday | 154 | +4% |\n| Tuesday | 132 | -2% |\n| Wednesday | 177 | +11% |\n| Thursday | 194 | +9% |\n\nWednesday and Thursday carry most of the week.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 79,
+ "duration_ms": 2100,
+ "created_at": "2026-01-05T09:59:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0080",
+ "role": "user",
+ "content": "Turn 35: can you help with the support ticket triage?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 80,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:00:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0081",
+ "role": "assistant",
+ "content": "",
+ "tool_calls": [
+ {
+ "id": "call_perf_35",
+ "type": "function",
+ "function": {
+ "name": "perf_lookup",
+ "arguments": "{\"query\":\"support ticket triage\",\"page\":35}"
+ }
+ }
+ ],
+ "tool_call_id": null,
+ "sequence": 81,
+ "duration_ms": 2400,
+ "created_at": "2026-01-05T10:00:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0082",
+ "role": "tool",
+ "content": "{\"query\":\"support ticket triage\",\"results\":3,\"turn\":35}",
+ "tool_calls": null,
+ "tool_call_id": "call_perf_35",
+ "sequence": 82,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:01:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0083",
+ "role": "assistant",
+ "content": "Here is what I found for the support ticket triage. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 35 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 83,
+ "duration_ms": 2700,
+ "created_at": "2026-01-05T10:02:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0084",
+ "role": "user",
+ "content": "Turn 36: can you help with the blog post outline?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 84,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:03:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0085",
+ "role": "assistant",
+ "content": "Here is what I found for the blog post outline. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 36 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 85,
+ "duration_ms": 1950,
+ "created_at": "2026-01-05T10:03:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0086",
+ "role": "user",
+ "content": "Turn 37: can you help with the invoice reconciliation?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 86,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:04:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0087",
+ "role": "assistant",
+ "content": "This script prepares the invoice reconciliation data:\n\n```ts\nexport function summarise(rows: { day: string; total: number }[]) {\n const total = rows.reduce((sum, row) => sum + row.total, 0);\n const best = rows.reduce((a, b) => (b.total > a.total ? b : a));\n return { total, best: best.day, turn: 37 };\n}\n```\n\nRun it once per day and paste the result here.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 87,
+ "duration_ms": 2250,
+ "created_at": "2026-01-05T10:05:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0088",
+ "role": "user",
+ "content": "Turn 38: can you help with the meeting notes summary?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 88,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:06:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0089",
+ "role": "assistant",
+ "content": "Breakdown for the meeting notes summary:\n\n| Day | Items | Change |\n| --- | ---: | ---: |\n| Monday | 158 | +4% |\n| Tuesday | 136 | -2% |\n| Wednesday | 181 | +11% |\n| Thursday | 198 | +9% |\n\nWednesday and Thursday carry most of the week.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 89,
+ "duration_ms": 2550,
+ "created_at": "2026-01-05T10:06:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0090",
+ "role": "user",
+ "content": "Turn 39: can you help with the social media calendar?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 90,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:07:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0091",
+ "role": "assistant",
+ "content": "Next steps for the social media calendar:\n\n1. Pull the latest export from the shared drive.\n2. Remove duplicate rows and empty lines.\n3. Compare against the numbers from turn 38.\n4. Send the short summary to the team channel.\n\n- **Owner:** you\n- **Due:** Friday",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 91,
+ "duration_ms": 1800,
+ "created_at": "2026-01-05T10:08:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0092",
+ "role": "user",
+ "content": "Turn 40: can you help with the weekly sales report?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 92,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:09:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0093",
+ "role": "assistant",
+ "content": "",
+ "tool_calls": [
+ {
+ "id": "call_perf_40",
+ "type": "function",
+ "function": {
+ "name": "perf_lookup",
+ "arguments": "{\"query\":\"weekly sales report\",\"page\":40}"
+ }
+ }
+ ],
+ "tool_call_id": null,
+ "sequence": 93,
+ "duration_ms": 2100,
+ "created_at": "2026-01-05T10:09:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0094",
+ "role": "tool",
+ "content": "{\"query\":\"weekly sales report\",\"results\":3,\"turn\":40}",
+ "tool_calls": null,
+ "tool_call_id": "call_perf_40",
+ "sequence": 94,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:10:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0095",
+ "role": "assistant",
+ "content": "Here is what I found for the weekly sales report. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 40 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 95,
+ "duration_ms": 2400,
+ "created_at": "2026-01-05T10:11:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0096",
+ "role": "user",
+ "content": "Turn 41: can you help with the customer onboarding emails?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 96,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:12:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0097",
+ "role": "assistant",
+ "content": "This script prepares the customer onboarding emails data:\n\n```ts\nexport function summarise(rows: { day: string; total: number }[]) {\n const total = rows.reduce((sum, row) => sum + row.total, 0);\n const best = rows.reduce((a, b) => (b.total > a.total ? b : a));\n return { total, best: best.day, turn: 41 };\n}\n```\n\nRun it once per day and paste the result here.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 97,
+ "duration_ms": 2700,
+ "created_at": "2026-01-05T10:12:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0098",
+ "role": "user",
+ "content": "Turn 42: can you help with the competitor price tracking?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 98,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:13:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0099",
+ "role": "assistant",
+ "content": "Breakdown for the competitor price tracking:\n\n| Day | Items | Change |\n| --- | ---: | ---: |\n| Monday | 162 | +4% |\n| Tuesday | 140 | -2% |\n| Wednesday | 185 | +11% |\n| Thursday | 202 | +9% |\n\nWednesday and Thursday carry most of the week.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 99,
+ "duration_ms": 1950,
+ "created_at": "2026-01-05T10:14:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0100",
+ "role": "user",
+ "content": "Turn 43: can you help with the support ticket triage?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 100,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:15:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0101",
+ "role": "assistant",
+ "content": "Next steps for the support ticket triage:\n\n1. Pull the latest export from the shared drive.\n2. Remove duplicate rows and empty lines.\n3. Compare against the numbers from turn 42.\n4. Send the short summary to the team channel.\n\n- **Owner:** you\n- **Due:** Friday",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 101,
+ "duration_ms": 2250,
+ "created_at": "2026-01-05T10:15:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0102",
+ "role": "user",
+ "content": "Turn 44: can you help with the blog post outline?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 102,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:16:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0103",
+ "role": "assistant",
+ "content": "Here is what I found for the blog post outline. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 44 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 103,
+ "duration_ms": 2550,
+ "created_at": "2026-01-05T10:17:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0104",
+ "role": "user",
+ "content": "Turn 45: can you help with the invoice reconciliation?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 104,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:18:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0105",
+ "role": "assistant",
+ "content": "",
+ "tool_calls": [
+ {
+ "id": "call_perf_45",
+ "type": "function",
+ "function": {
+ "name": "perf_lookup",
+ "arguments": "{\"query\":\"invoice reconciliation\",\"page\":45}"
+ }
+ }
+ ],
+ "tool_call_id": null,
+ "sequence": 105,
+ "duration_ms": 1800,
+ "created_at": "2026-01-05T10:18:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0106",
+ "role": "tool",
+ "content": "{\"query\":\"invoice reconciliation\",\"results\":3,\"turn\":45}",
+ "tool_calls": null,
+ "tool_call_id": "call_perf_45",
+ "sequence": 106,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:19:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0107",
+ "role": "assistant",
+ "content": "Here is what I found for the invoice reconciliation. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 45 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 107,
+ "duration_ms": 2100,
+ "created_at": "2026-01-05T10:20:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0108",
+ "role": "user",
+ "content": "Turn 46: can you help with the meeting notes summary?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 108,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:21:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0109",
+ "role": "assistant",
+ "content": "Breakdown for the meeting notes summary:\n\n| Day | Items | Change |\n| --- | ---: | ---: |\n| Monday | 166 | +4% |\n| Tuesday | 144 | -2% |\n| Wednesday | 189 | +11% |\n| Thursday | 206 | +9% |\n\nWednesday and Thursday carry most of the week.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 109,
+ "duration_ms": 2400,
+ "created_at": "2026-01-05T10:21:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0110",
+ "role": "user",
+ "content": "Turn 47: can you help with the social media calendar?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 110,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:22:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0111",
+ "role": "assistant",
+ "content": "Next steps for the social media calendar:\n\n1. Pull the latest export from the shared drive.\n2. Remove duplicate rows and empty lines.\n3. Compare against the numbers from turn 46.\n4. Send the short summary to the team channel.\n\n- **Owner:** you\n- **Due:** Friday",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 111,
+ "duration_ms": 2700,
+ "created_at": "2026-01-05T10:23:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0112",
+ "role": "user",
+ "content": "Turn 48: can you help with the weekly sales report?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 112,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:24:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0113",
+ "role": "assistant",
+ "content": "Here is what I found for the weekly sales report. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 48 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 113,
+ "duration_ms": 1950,
+ "created_at": "2026-01-05T10:24:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0114",
+ "role": "user",
+ "content": "Turn 49: can you help with the customer onboarding emails?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 114,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:25:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0115",
+ "role": "assistant",
+ "content": "This script prepares the customer onboarding emails data:\n\n```ts\nexport function summarise(rows: { day: string; total: number }[]) {\n const total = rows.reduce((sum, row) => sum + row.total, 0);\n const best = rows.reduce((a, b) => (b.total > a.total ? b : a));\n return { total, best: best.day, turn: 49 };\n}\n```\n\nRun it once per day and paste the result here.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 115,
+ "duration_ms": 2250,
+ "created_at": "2026-01-05T10:26:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0116",
+ "role": "user",
+ "content": "Turn 50: can you help with the competitor price tracking?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 116,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:27:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0117",
+ "role": "assistant",
+ "content": "",
+ "tool_calls": [
+ {
+ "id": "call_perf_50",
+ "type": "function",
+ "function": {
+ "name": "perf_lookup",
+ "arguments": "{\"query\":\"competitor price tracking\",\"page\":50}"
+ }
+ }
+ ],
+ "tool_call_id": null,
+ "sequence": 117,
+ "duration_ms": 2550,
+ "created_at": "2026-01-05T10:27:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0118",
+ "role": "tool",
+ "content": "{\"query\":\"competitor price tracking\",\"results\":3,\"turn\":50}",
+ "tool_calls": null,
+ "tool_call_id": "call_perf_50",
+ "sequence": 118,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:28:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0119",
+ "role": "assistant",
+ "content": "Here is what I found for the competitor price tracking. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 50 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 119,
+ "duration_ms": 1800,
+ "created_at": "2026-01-05T10:29:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0120",
+ "role": "user",
+ "content": "Turn 51: can you help with the support ticket triage?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 120,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:30:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0121",
+ "role": "assistant",
+ "content": "Next steps for the support ticket triage:\n\n1. Pull the latest export from the shared drive.\n2. Remove duplicate rows and empty lines.\n3. Compare against the numbers from turn 50.\n4. Send the short summary to the team channel.\n\n- **Owner:** you\n- **Due:** Friday",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 121,
+ "duration_ms": 2100,
+ "created_at": "2026-01-05T10:30:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0122",
+ "role": "user",
+ "content": "Turn 52: can you help with the blog post outline?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 122,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:31:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0123",
+ "role": "assistant",
+ "content": "Here is what I found for the blog post outline. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 52 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 123,
+ "duration_ms": 2400,
+ "created_at": "2026-01-05T10:32:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0124",
+ "role": "user",
+ "content": "Turn 53: can you help with the invoice reconciliation?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 124,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:33:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0125",
+ "role": "assistant",
+ "content": "This script prepares the invoice reconciliation data:\n\n```ts\nexport function summarise(rows: { day: string; total: number }[]) {\n const total = rows.reduce((sum, row) => sum + row.total, 0);\n const best = rows.reduce((a, b) => (b.total > a.total ? b : a));\n return { total, best: best.day, turn: 53 };\n}\n```\n\nRun it once per day and paste the result here.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 125,
+ "duration_ms": 2700,
+ "created_at": "2026-01-05T10:33:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0126",
+ "role": "user",
+ "content": "Turn 54: can you help with the meeting notes summary?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 126,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:34:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0127",
+ "role": "assistant",
+ "content": "Breakdown for the meeting notes summary:\n\n| Day | Items | Change |\n| --- | ---: | ---: |\n| Monday | 174 | +4% |\n| Tuesday | 152 | -2% |\n| Wednesday | 197 | +11% |\n| Thursday | 214 | +9% |\n\nWednesday and Thursday carry most of the week.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 127,
+ "duration_ms": 1950,
+ "created_at": "2026-01-05T10:35:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0128",
+ "role": "user",
+ "content": "Turn 55: can you help with the social media calendar?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 128,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:36:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0129",
+ "role": "assistant",
+ "content": "",
+ "tool_calls": [
+ {
+ "id": "call_perf_55",
+ "type": "function",
+ "function": {
+ "name": "perf_lookup",
+ "arguments": "{\"query\":\"social media calendar\",\"page\":55}"
+ }
+ }
+ ],
+ "tool_call_id": null,
+ "sequence": 129,
+ "duration_ms": 2250,
+ "created_at": "2026-01-05T10:36:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0130",
+ "role": "tool",
+ "content": "{\"query\":\"social media calendar\",\"results\":3,\"turn\":55}",
+ "tool_calls": null,
+ "tool_call_id": "call_perf_55",
+ "sequence": 130,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:37:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0131",
+ "role": "assistant",
+ "content": "Here is what I found for the social media calendar. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 55 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 131,
+ "duration_ms": 2550,
+ "created_at": "2026-01-05T10:38:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0132",
+ "role": "user",
+ "content": "Turn 56: can you help with the weekly sales report?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 132,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:39:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0133",
+ "role": "assistant",
+ "content": "Here is what I found for the weekly sales report. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 56 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 133,
+ "duration_ms": 1800,
+ "created_at": "2026-01-05T10:39:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0134",
+ "role": "user",
+ "content": "Turn 57: can you help with the customer onboarding emails?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 134,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:40:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0135",
+ "role": "assistant",
+ "content": "This script prepares the customer onboarding emails data:\n\n```ts\nexport function summarise(rows: { day: string; total: number }[]) {\n const total = rows.reduce((sum, row) => sum + row.total, 0);\n const best = rows.reduce((a, b) => (b.total > a.total ? b : a));\n return { total, best: best.day, turn: 57 };\n}\n```\n\nRun it once per day and paste the result here.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 135,
+ "duration_ms": 2100,
+ "created_at": "2026-01-05T10:41:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0136",
+ "role": "user",
+ "content": "Turn 58: can you help with the competitor price tracking?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 136,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:42:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0137",
+ "role": "assistant",
+ "content": "Breakdown for the competitor price tracking:\n\n| Day | Items | Change |\n| --- | ---: | ---: |\n| Monday | 178 | +4% |\n| Tuesday | 156 | -2% |\n| Wednesday | 201 | +11% |\n| Thursday | 218 | +9% |\n\nWednesday and Thursday carry most of the week.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 137,
+ "duration_ms": 2400,
+ "created_at": "2026-01-05T10:42:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0138",
+ "role": "user",
+ "content": "Turn 59: can you help with the support ticket triage?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 138,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:43:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0139",
+ "role": "assistant",
+ "content": "Next steps for the support ticket triage:\n\n1. Pull the latest export from the shared drive.\n2. Remove duplicate rows and empty lines.\n3. Compare against the numbers from turn 58.\n4. Send the short summary to the team channel.\n\n- **Owner:** you\n- **Due:** Friday",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 139,
+ "duration_ms": 2700,
+ "created_at": "2026-01-05T10:44:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0140",
+ "role": "user",
+ "content": "Turn 60: can you help with the blog post outline?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 140,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:45:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0141",
+ "role": "assistant",
+ "content": "",
+ "tool_calls": [
+ {
+ "id": "call_perf_60",
+ "type": "function",
+ "function": {
+ "name": "perf_lookup",
+ "arguments": "{\"query\":\"blog post outline\",\"page\":60}"
+ }
+ }
+ ],
+ "tool_call_id": null,
+ "sequence": 141,
+ "duration_ms": 1950,
+ "created_at": "2026-01-05T10:45:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0142",
+ "role": "tool",
+ "content": "{\"query\":\"blog post outline\",\"results\":3,\"turn\":60}",
+ "tool_calls": null,
+ "tool_call_id": "call_perf_60",
+ "sequence": 142,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:46:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0143",
+ "role": "assistant",
+ "content": "Here is what I found for the blog post outline. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 60 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 143,
+ "duration_ms": 2250,
+ "created_at": "2026-01-05T10:47:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0144",
+ "role": "user",
+ "content": "Turn 61: can you help with the invoice reconciliation?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 144,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:48:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0145",
+ "role": "assistant",
+ "content": "This script prepares the invoice reconciliation data:\n\n```ts\nexport function summarise(rows: { day: string; total: number }[]) {\n const total = rows.reduce((sum, row) => sum + row.total, 0);\n const best = rows.reduce((a, b) => (b.total > a.total ? b : a));\n return { total, best: best.day, turn: 61 };\n}\n```\n\nRun it once per day and paste the result here.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 145,
+ "duration_ms": 2550,
+ "created_at": "2026-01-05T10:48:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0146",
+ "role": "user",
+ "content": "Turn 62: can you help with the meeting notes summary?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 146,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:49:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0147",
+ "role": "assistant",
+ "content": "Breakdown for the meeting notes summary:\n\n| Day | Items | Change |\n| --- | ---: | ---: |\n| Monday | 182 | +4% |\n| Tuesday | 160 | -2% |\n| Wednesday | 205 | +11% |\n| Thursday | 222 | +9% |\n\nWednesday and Thursday carry most of the week.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 147,
+ "duration_ms": 1800,
+ "created_at": "2026-01-05T10:50:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0148",
+ "role": "user",
+ "content": "Turn 63: can you help with the social media calendar?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 148,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:51:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0149",
+ "role": "assistant",
+ "content": "Next steps for the social media calendar:\n\n1. Pull the latest export from the shared drive.\n2. Remove duplicate rows and empty lines.\n3. Compare against the numbers from turn 62.\n4. Send the short summary to the team channel.\n\n- **Owner:** you\n- **Due:** Friday",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 149,
+ "duration_ms": 2100,
+ "created_at": "2026-01-05T10:51:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0150",
+ "role": "user",
+ "content": "Turn 64: can you help with the weekly sales report?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 150,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:52:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0151",
+ "role": "assistant",
+ "content": "Here is what I found for the weekly sales report. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 64 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 151,
+ "duration_ms": 2400,
+ "created_at": "2026-01-05T10:53:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0152",
+ "role": "user",
+ "content": "Turn 65: can you help with the customer onboarding emails?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 152,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:54:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0153",
+ "role": "assistant",
+ "content": "",
+ "tool_calls": [
+ {
+ "id": "call_perf_65",
+ "type": "function",
+ "function": {
+ "name": "perf_lookup",
+ "arguments": "{\"query\":\"customer onboarding emails\",\"page\":65}"
+ }
+ }
+ ],
+ "tool_call_id": null,
+ "sequence": 153,
+ "duration_ms": 2700,
+ "created_at": "2026-01-05T10:54:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0154",
+ "role": "tool",
+ "content": "{\"query\":\"customer onboarding emails\",\"results\":3,\"turn\":65}",
+ "tool_calls": null,
+ "tool_call_id": "call_perf_65",
+ "sequence": 154,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:55:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0155",
+ "role": "assistant",
+ "content": "Here is what I found for the customer onboarding emails. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 65 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 155,
+ "duration_ms": 1950,
+ "created_at": "2026-01-05T10:56:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0156",
+ "role": "user",
+ "content": "Turn 66: can you help with the competitor price tracking?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 156,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:57:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0157",
+ "role": "assistant",
+ "content": "Breakdown for the competitor price tracking:\n\n| Day | Items | Change |\n| --- | ---: | ---: |\n| Monday | 186 | +4% |\n| Tuesday | 164 | -2% |\n| Wednesday | 209 | +11% |\n| Thursday | 226 | +9% |\n\nWednesday and Thursday carry most of the week.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 157,
+ "duration_ms": 2250,
+ "created_at": "2026-01-05T10:57:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0158",
+ "role": "user",
+ "content": "Turn 67: can you help with the support ticket triage?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 158,
+ "duration_ms": null,
+ "created_at": "2026-01-05T10:58:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0159",
+ "role": "assistant",
+ "content": "Next steps for the support ticket triage:\n\n1. Pull the latest export from the shared drive.\n2. Remove duplicate rows and empty lines.\n3. Compare against the numbers from turn 66.\n4. Send the short summary to the team channel.\n\n- **Owner:** you\n- **Due:** Friday",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 159,
+ "duration_ms": 2550,
+ "created_at": "2026-01-05T10:59:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0160",
+ "role": "user",
+ "content": "Turn 68: can you help with the blog post outline?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 160,
+ "duration_ms": null,
+ "created_at": "2026-01-05T11:00:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0161",
+ "role": "assistant",
+ "content": "Here is what I found for the blog post outline. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 68 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 161,
+ "duration_ms": 1800,
+ "created_at": "2026-01-05T11:00:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0162",
+ "role": "user",
+ "content": "Turn 69: can you help with the invoice reconciliation?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 162,
+ "duration_ms": null,
+ "created_at": "2026-01-05T11:01:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0163",
+ "role": "assistant",
+ "content": "This script prepares the invoice reconciliation data:\n\n```ts\nexport function summarise(rows: { day: string; total: number }[]) {\n const total = rows.reduce((sum, row) => sum + row.total, 0);\n const best = rows.reduce((a, b) => (b.total > a.total ? b : a));\n return { total, best: best.day, turn: 69 };\n}\n```\n\nRun it once per day and paste the result here.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 163,
+ "duration_ms": 2100,
+ "created_at": "2026-01-05T11:02:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0164",
+ "role": "user",
+ "content": "Turn 70: can you help with the meeting notes summary?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 164,
+ "duration_ms": null,
+ "created_at": "2026-01-05T11:03:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0165",
+ "role": "assistant",
+ "content": "",
+ "tool_calls": [
+ {
+ "id": "call_perf_70",
+ "type": "function",
+ "function": {
+ "name": "perf_lookup",
+ "arguments": "{\"query\":\"meeting notes summary\",\"page\":70}"
+ }
+ }
+ ],
+ "tool_call_id": null,
+ "sequence": 165,
+ "duration_ms": 2400,
+ "created_at": "2026-01-05T11:03:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0166",
+ "role": "tool",
+ "content": "{\"query\":\"meeting notes summary\",\"results\":3,\"turn\":70}",
+ "tool_calls": null,
+ "tool_call_id": "call_perf_70",
+ "sequence": 166,
+ "duration_ms": null,
+ "created_at": "2026-01-05T11:04:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0167",
+ "role": "assistant",
+ "content": "Here is what I found for the meeting notes summary. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 70 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 167,
+ "duration_ms": 2700,
+ "created_at": "2026-01-05T11:05:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0168",
+ "role": "user",
+ "content": "Turn 71: can you help with the social media calendar?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 168,
+ "duration_ms": null,
+ "created_at": "2026-01-05T11:06:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0169",
+ "role": "assistant",
+ "content": "Next steps for the social media calendar:\n\n1. Pull the latest export from the shared drive.\n2. Remove duplicate rows and empty lines.\n3. Compare against the numbers from turn 70.\n4. Send the short summary to the team channel.\n\n- **Owner:** you\n- **Due:** Friday",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 169,
+ "duration_ms": 1950,
+ "created_at": "2026-01-05T11:06:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0170",
+ "role": "user",
+ "content": "Turn 72: can you help with the weekly sales report?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 170,
+ "duration_ms": null,
+ "created_at": "2026-01-05T11:07:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0171",
+ "role": "assistant",
+ "content": "Here is what I found for the weekly sales report. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 72 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 171,
+ "duration_ms": 2250,
+ "created_at": "2026-01-05T11:08:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0172",
+ "role": "user",
+ "content": "Turn 73: can you help with the customer onboarding emails?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 172,
+ "duration_ms": null,
+ "created_at": "2026-01-05T11:09:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0173",
+ "role": "assistant",
+ "content": "This script prepares the customer onboarding emails data:\n\n```ts\nexport function summarise(rows: { day: string; total: number }[]) {\n const total = rows.reduce((sum, row) => sum + row.total, 0);\n const best = rows.reduce((a, b) => (b.total > a.total ? b : a));\n return { total, best: best.day, turn: 73 };\n}\n```\n\nRun it once per day and paste the result here.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 173,
+ "duration_ms": 2550,
+ "created_at": "2026-01-05T11:09:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0174",
+ "role": "user",
+ "content": "Turn 74: can you help with the competitor price tracking?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 174,
+ "duration_ms": null,
+ "created_at": "2026-01-05T11:10:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0175",
+ "role": "assistant",
+ "content": "Breakdown for the competitor price tracking:\n\n| Day | Items | Change |\n| --- | ---: | ---: |\n| Monday | 194 | +4% |\n| Tuesday | 172 | -2% |\n| Wednesday | 217 | +11% |\n| Thursday | 234 | +9% |\n\nWednesday and Thursday carry most of the week.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 175,
+ "duration_ms": 1800,
+ "created_at": "2026-01-05T11:11:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0176",
+ "role": "user",
+ "content": "Turn 75: can you help with the support ticket triage?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 176,
+ "duration_ms": null,
+ "created_at": "2026-01-05T11:12:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0177",
+ "role": "assistant",
+ "content": "",
+ "tool_calls": [
+ {
+ "id": "call_perf_75",
+ "type": "function",
+ "function": {
+ "name": "perf_lookup",
+ "arguments": "{\"query\":\"support ticket triage\",\"page\":75}"
+ }
+ }
+ ],
+ "tool_call_id": null,
+ "sequence": 177,
+ "duration_ms": 2100,
+ "created_at": "2026-01-05T11:12:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0178",
+ "role": "tool",
+ "content": "{\"query\":\"support ticket triage\",\"results\":3,\"turn\":75}",
+ "tool_calls": null,
+ "tool_call_id": "call_perf_75",
+ "sequence": 178,
+ "duration_ms": null,
+ "created_at": "2026-01-05T11:13:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0179",
+ "role": "assistant",
+ "content": "Here is what I found for the support ticket triage. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 75 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 179,
+ "duration_ms": 2400,
+ "created_at": "2026-01-05T11:14:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0180",
+ "role": "user",
+ "content": "Turn 76: can you help with the blog post outline?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 180,
+ "duration_ms": null,
+ "created_at": "2026-01-05T11:15:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0181",
+ "role": "assistant",
+ "content": "Here is what I found for the blog post outline. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 76 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 181,
+ "duration_ms": 2700,
+ "created_at": "2026-01-05T11:15:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0182",
+ "role": "user",
+ "content": "Turn 77: can you help with the invoice reconciliation?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 182,
+ "duration_ms": null,
+ "created_at": "2026-01-05T11:16:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0183",
+ "role": "assistant",
+ "content": "This script prepares the invoice reconciliation data:\n\n```ts\nexport function summarise(rows: { day: string; total: number }[]) {\n const total = rows.reduce((sum, row) => sum + row.total, 0);\n const best = rows.reduce((a, b) => (b.total > a.total ? b : a));\n return { total, best: best.day, turn: 77 };\n}\n```\n\nRun it once per day and paste the result here.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 183,
+ "duration_ms": 1950,
+ "created_at": "2026-01-05T11:17:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0184",
+ "role": "user",
+ "content": "Turn 78: can you help with the meeting notes summary?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 184,
+ "duration_ms": null,
+ "created_at": "2026-01-05T11:18:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0185",
+ "role": "assistant",
+ "content": "Breakdown for the meeting notes summary:\n\n| Day | Items | Change |\n| --- | ---: | ---: |\n| Monday | 198 | +4% |\n| Tuesday | 176 | -2% |\n| Wednesday | 221 | +11% |\n| Thursday | 238 | +9% |\n\nWednesday and Thursday carry most of the week.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 185,
+ "duration_ms": 2250,
+ "created_at": "2026-01-05T11:18:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0186",
+ "role": "user",
+ "content": "Turn 79: can you help with the social media calendar?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 186,
+ "duration_ms": null,
+ "created_at": "2026-01-05T11:19:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0187",
+ "role": "assistant",
+ "content": "Next steps for the social media calendar:\n\n1. Pull the latest export from the shared drive.\n2. Remove duplicate rows and empty lines.\n3. Compare against the numbers from turn 78.\n4. Send the short summary to the team channel.\n\n- **Owner:** you\n- **Due:** Friday",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 187,
+ "duration_ms": 2550,
+ "created_at": "2026-01-05T11:20:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0188",
+ "role": "user",
+ "content": "Turn 80: can you help with the weekly sales report?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 188,
+ "duration_ms": null,
+ "created_at": "2026-01-05T11:21:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0189",
+ "role": "assistant",
+ "content": "",
+ "tool_calls": [
+ {
+ "id": "call_perf_80",
+ "type": "function",
+ "function": {
+ "name": "perf_lookup",
+ "arguments": "{\"query\":\"weekly sales report\",\"page\":80}"
+ }
+ }
+ ],
+ "tool_call_id": null,
+ "sequence": 189,
+ "duration_ms": 1800,
+ "created_at": "2026-01-05T11:21:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0190",
+ "role": "tool",
+ "content": "{\"query\":\"weekly sales report\",\"results\":3,\"turn\":80}",
+ "tool_calls": null,
+ "tool_call_id": "call_perf_80",
+ "sequence": 190,
+ "duration_ms": null,
+ "created_at": "2026-01-05T11:22:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0191",
+ "role": "assistant",
+ "content": "Here is what I found for the weekly sales report. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 80 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 191,
+ "duration_ms": 2100,
+ "created_at": "2026-01-05T11:23:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0192",
+ "role": "user",
+ "content": "Turn 81: can you help with the customer onboarding emails?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 192,
+ "duration_ms": null,
+ "created_at": "2026-01-05T11:24:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0193",
+ "role": "assistant",
+ "content": "This script prepares the customer onboarding emails data:\n\n```ts\nexport function summarise(rows: { day: string; total: number }[]) {\n const total = rows.reduce((sum, row) => sum + row.total, 0);\n const best = rows.reduce((a, b) => (b.total > a.total ? b : a));\n return { total, best: best.day, turn: 81 };\n}\n```\n\nRun it once per day and paste the result here.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 193,
+ "duration_ms": 2400,
+ "created_at": "2026-01-05T11:24:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0194",
+ "role": "user",
+ "content": "Turn 82: can you help with the competitor price tracking?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 194,
+ "duration_ms": null,
+ "created_at": "2026-01-05T11:25:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0195",
+ "role": "assistant",
+ "content": "Breakdown for the competitor price tracking:\n\n| Day | Items | Change |\n| --- | ---: | ---: |\n| Monday | 202 | +4% |\n| Tuesday | 180 | -2% |\n| Wednesday | 225 | +11% |\n| Thursday | 242 | +9% |\n\nWednesday and Thursday carry most of the week.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 195,
+ "duration_ms": 2700,
+ "created_at": "2026-01-05T11:26:15.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0196",
+ "role": "user",
+ "content": "Turn 83: can you help with the support ticket triage?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 196,
+ "duration_ms": null,
+ "created_at": "2026-01-05T11:27:00.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0197",
+ "role": "assistant",
+ "content": "Next steps for the support ticket triage:\n\n1. Pull the latest export from the shared drive.\n2. Remove duplicate rows and empty lines.\n3. Compare against the numbers from turn 82.\n4. Send the short summary to the team channel.\n\n- **Owner:** you\n- **Due:** Friday",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 197,
+ "duration_ms": 1950,
+ "created_at": "2026-01-05T11:27:45.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0198",
+ "role": "user",
+ "content": "Turn 84: can you help with the blog post outline?",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 198,
+ "duration_ms": null,
+ "created_at": "2026-01-05T11:28:30.000Z",
+ "metadata": {}
+ },
+ {
+ "id": "perf-msg-0199",
+ "role": "assistant",
+ "content": "Here is what I found for the blog post outline. The numbers from last week are steady, with a small rise on Thursday after the newsletter went out.\n\nI would keep the current plan and check again on Monday. If the trend holds, we can move turn 84 into the regular schedule.",
+ "tool_calls": null,
+ "tool_call_id": null,
+ "sequence": 199,
+ "duration_ms": 2250,
+ "created_at": "2026-01-05T11:29:15.000Z",
+ "metadata": {}
+ }
+ ]
+}
diff --git a/autogpt_platform/frontend/scripts/perf/lib/auth.ts b/autogpt_platform/frontend/scripts/perf/lib/auth.ts
new file mode 100644
index 0000000000..535a394f62
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/lib/auth.ts
@@ -0,0 +1,75 @@
+import type { APIRequestContext } from "@playwright/test";
+
+const DEFAULT_EMAIL = "[email protected]";
+const DEFAULT_PASSWORD = "perf-harness-password";
+/** First-visit cards that would cover the page the scenario measures. */
+const DONE_ONBOARDING_STEPS = [
+ "ONBOARDING_COMPLETE",
+ "AGENTS_TAB_INTRO",
+ "MARKETPLACE_TAB_INTRO",
+ "BUILD_TAB_INTRO",
+];
+
+interface Credentials {
+ email: string;
+ password: string;
+}
+
+function credentials(): Credentials {
+ return {
+ email: process.env.PERF_USER_EMAIL || DEFAULT_EMAIL,
+ password: process.env.PERF_USER_PASSWORD || DEFAULT_PASSWORD,
+ };
+}
+
+async function signInRequest(
+ request: APIRequestContext,
+ baseURL: string,
+ { email, password }: Credentials,
+) {
+ return request.post(`${baseURL}/api/auth/sign-in/email`, {
+ data: { email, password },
+ headers: { Origin: baseURL },
+ });
+}
+
+/**
+ * Signs the browser context in through Better Auth, creating the perf user
+ * the first time. With `--storage-state` (e.g. a `.auth/*.json` written by
+ * the Playwright global setup) the context is already signed in and this
+ * only reads the user id.
+ */
+export async function signIn(
+ request: APIRequestContext,
+ baseURL: string,
+ hasStorageState: boolean,
+) {
+ if (!hasStorageState) {
+ const creds = credentials();
+ let response = await signInRequest(request, baseURL, creds);
+ if (!response.ok()) {
+ await request.post(`${baseURL}/api/auth/sign-up/email`, {
+ data: { ...creds, name: "Perf Harness" },
+ headers: { Origin: baseURL },
+ });
+ response = await signInRequest(request, baseURL, creds);
+ }
+ if (!response.ok()) {
+ throw new Error(
+ `Could not sign in as ${creds.email} (${response.status()}). Set PERF_USER_EMAIL / PERF_USER_PASSWORD to an account that exists, or pass --storage-state.`,
+ );
+ }
+ }
+ const session = await request.get(`${baseURL}/api/auth/get-session`);
+ const body = (await session.json().catch(() => null)) as {
+ user?: { id?: string };
+ } | null;
+ const userID = body?.user?.id;
+ if (!userID) {
+ throw new Error("Signed in, but /api/auth/get-session returned no user.");
+ }
+ for (const step of DONE_ONBOARDING_STEPS) {
+ await request.post(`${baseURL}/api/proxy/api/onboarding/step?step=${step}`);
+ }
+ return userID;
+}
diff --git a/autogpt_platform/frontend/scripts/perf/lib/builder-fixture.ts b/autogpt_platform/frontend/scripts/perf/lib/builder-fixture.ts
new file mode 100644
index 0000000000..1e94673e69
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/lib/builder-fixture.ts
@@ -0,0 +1,156 @@
+import { fulfillJSON, type RouteHandlers } from "./routes";
+
+const FIXED_TIME = "2026-01-05T09:00:00.000Z";
+const COLUMNS = 10;
+const STORE_VALUE_BLOCK = "1ff065e9-88e8-4358-9d82-8dc91f622ba9";
+const OTHER_BLOCKS = [
+ { id: "b1ab9b19-67a6-406d-abf5-2dba76d00c79", input: { a: 1, b: 2 } },
+ { id: "db7d8f02-2f44-4c55-ab7a-eae0941f0c30", input: { format: "{{a}}" } },
+ { id: "3060088f-6ed9-4928-9ba7-9c92823a7ccd", input: { match: "x" } },
+ { id: "a912d5c7-6e00-4542-b2a9-8034136930e4", input: {} },
+ { id: "715696a0-e1da-45c8-b209-c2fa9c3b0be6", input: {} },
+];
+
+export const BUILDER_GRAPH_ID = "00000000-0000-4000-8000-0000000000b1";
+export const BUILDER_EXECUTION_ID = "00000000-0000-4000-8000-0000000000b2";
+
+function nodeID(index: number) {
+ return `00000000-0000-4000-8000-${String(index).padStart(12, "0")}`;
+}
+
+function isStoreValue(index: number) {
+ return index % 5 !== 4;
+}
+
+export function buildGraph(userID: string, nodeCount = 50) {
+ const nodes = Array.from({ length: nodeCount }, (_, index) => {
+ const other = OTHER_BLOCKS[Math.floor(index / 5) % OTHER_BLOCKS.length];
+ return {
+ id: nodeID(index),
+ block_id: isStoreValue(index) ? STORE_VALUE_BLOCK : other.id,
+ input_default: isStoreValue(index) ? { input: `value ${index}` } : {},
+ metadata: {
+ position: {
+ x: (index % COLUMNS) * 420,
+ y: Math.floor(index / COLUMNS) * 360,
+ },
+ },
+ input_links: [],
+ output_links: [],
+ graph_id: BUILDER_GRAPH_ID,
+ graph_version: 1,
+ webhook_id: null,
+ };
+ });
+ const links = nodes.slice(0, -1).flatMap((node, index) =>
+ isStoreValue(index) && isStoreValue(index + 1)
+ ? [
+ {
+ id: `00000000-0000-4000-9000-${String(index).padStart(12, "0")}`,
+ source_id: node.id,
+ sink_id: nodes[index + 1].id,
+ source_name: "output",
+ sink_name: "input",
+ is_static: true,
+ },
+ ]
+ : [],
+ );
+ return {
+ id: BUILDER_GRAPH_ID,
+ version: 1,
+ is_active: true,
+ name: "Perf: 50-step workflow",
+ description: "Fixture for the builder-drag-running scenario",
+ instructions: null,
+ recommended_schedule_cron: null,
+ forked_from_id: null,
+ forked_from_version: null,
+ user_id: userID,
+ created_at: FIXED_TIME,
+ organization_id: null,
+ team_id: null,
+ nodes,
+ links,
+ sub_graphs: [],
+ input_schema: { type: "object", properties: {}, required: [] },
+ output_schema: { type: "object", properties: {}, required: [] },
+ has_external_trigger: false,
+ has_human_in_the_loop: false,
+ has_sensitive_action: false,
+ trigger_setup_info: null,
+ credentials_input_schema: {
+ type: "object",
+ properties: {},
+ required: [],
+ },
+ };
+}
+
+function nodeStatus(index: number) {
+ if (index < 30) return "COMPLETED";
+ if (index < 33) return "RUNNING";
+ return "QUEUED";
+}
+
+export function buildRunningExecution(
+ graph: ReturnType<typeof buildGraph>,
+ userID: string,
+) {
+ const node_executions = graph.nodes.slice(0, 40).map((node, index) => ({
+ user_id: userID,
+ graph_id: graph.id,
+ graph_version: graph.version,
+ graph_exec_id: BUILDER_EXECUTION_ID,
+ node_exec_id: `00000000-0000-4000-a000-${String(index).padStart(12, "0")}`,
+ node_id: node.id,
+ block_id: node.block_id,
+ status: nodeStatus(index),
+ input_data: node.input_default,
+ output_data:
+ nodeStatus(index) === "COMPLETED" ? { output: [`value ${index}`] } : {},
+ add_time: FIXED_TIME,
+ queue_time: FIXED_TIME,
+ start_time: index < 33 ? FIXED_TIME : null,
+ end_time: index < 30 ? FIXED_TIME : null,
+ }));
+ return {
+ id: BUILDER_EXECUTION_ID,
+ user_id: userID,
+ graph_id: graph.id,
+ graph_version: graph.version,
+ inputs: {},
+ credential_inputs: {},
+ nodes_input_masks: null,
+ preset_id: null,
+ status: "RUNNING",
+ started_at: FIXED_TIME,
+ ended_at: null,
+ is_shared: false,
+ share_token: null,
+ is_dry_run: false,
+ stats: null,
+ outputs: {},
+ node_executions,
+ };
+}
+
+export function createBuilderFixture(userID: string) {
+ const graph = buildGraph(userID);
+ const execution = buildRunningExecution(graph, userID);
+ const handlers: RouteHandlers = {
+ graph: async (route, match) => {
+ if (match[1] !== graph.id || route.request().method() !== "GET") {
+ return route.fallback();
+ }
+ await fulfillJSON(route, graph);
+ },
+ graphExecution: async (route, match) => {
+ if (match[1] !== graph.id || match[2] !== execution.id) {
+ return route.fallback();
+ }
+ await fulfillJSON(route, execution);
+ },
+ };
+ return { handlers, graph, execution };
+}
diff --git a/autogpt_platform/frontend/scripts/perf/lib/cdp.ts b/autogpt_platform/frontend/scripts/perf/lib/cdp.ts
new file mode 100644
index 0000000000..50e8ba4a5b
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/lib/cdp.ts
@@ -0,0 +1,131 @@
+import type { BrowserContext, CDPSession, Page } from "@playwright/test";
+
+const TRACE_CATEGORIES =
+ "devtools.timeline,disabled-by-default-devtools.timeline";
+const LONG_TASK_US = 50_000;
+const GC_SETTLE_MS = 500;
+
+export interface TraceEvent {
+ name: string;
+ ph: string;
+ pid: number;
+ tid: number;
+ ts: number;
+ dur?: number;
+ args?: {
+ name?: string;
+ data?: { frames?: { processId?: number; parent?: string }[] };
+ };
+}
+
+type Metrics = Record<string, number>;
+
+export async function openCDP(context: BrowserContext, page: Page) {
+ const cdp = await context.newCDPSession(page);
+ await cdp.send("Performance.enable");
+ await cdp.send("HeapProfiler.enable");
+ return cdp;
+}
+
+export async function readMetrics(cdp: CDPSession): Promise<Metrics> {
+ const { metrics } = await cdp.send("Performance.getMetrics");
+ return Object.fromEntries(metrics.map(({ name, value }) => [name, value]));
+}
+
+function threadKey(event: TraceEvent) {
+ return `${event.pid}:${event.tid}`;
+}
+
+/**
+ * Main threads of the page's renderer: `CrRendererMain` in the process that
+ * hosts the top-level frame (falling back to every renderer main thread if
+ * the trace does not say which process that is).
+ */
+function mainThreads(events: TraceEvent[]) {
+ const frames =
+ events.find((event) => event.name === "TracingStartedInBrowser")?.args?.data
+ ?.frames ?? [];
+ const pagePIDs = new Set(
+ frames.filter((frame) => !frame.parent).map((frame) => frame.processId),
+ );
+ return new Set(
+ events
+ .filter(
+ (event) =>
+ event.ph === "M" &&
+ event.name === "thread_name" &&
+ event.args?.name === "CrRendererMain" &&
+ (pagePIDs.size === 0 || pagePIDs.has(event.pid)),
+ )
+ .map(threadKey),
+ );
+}
+
+export function summarizeLongTasks(events: TraceEvent[]) {
+ const threads = mainThreads(events);
+ const long = events.filter(
+ (event) =>
+ event.name === "RunTask" &&
+ event.ph === "X" &&
+ (event.dur ?? 0) >= LONG_TASK_US &&
+ threads.has(threadKey(event)),
+ );
+ return {
+ count: long.length,
+ totalMs: long.reduce((sum, event) => sum + (event.dur ?? 0), 0) / 1000,
+ };
+}
+
+function durationMs(before: Metrics, after: Metrics, name: string) {
+ return ((after[name] ?? 0) - (before[name] ?? 0)) * 1000;
+}
+
+export async function startWindow(cdp: CDPSession, profile: boolean) {
+ const events: TraceEvent[] = [];
+ function onData({ value }: { value: object[] }) {
+ events.push(...(value as TraceEvent[]));
+ }
+ cdp.on("Tracing.dataCollected", onData);
+ await cdp.send("Tracing.start", {
+ categories: TRACE_CATEGORIES,
+ transferMode: "ReportEvents",
+ });
+ if (profile) {
+ await cdp.send("Profiler.enable");
+ await cdp.send("Profiler.start");
+ }
+ const before = await readMetrics(cdp);
+ return { events, before, profile, onData };
+}
+
+type OpenWindow = Awaited<ReturnType<typeof startWindow>>;
+
+export async function stopWindow(cdp: CDPSession, window: OpenWindow) {
+ const after = await readMetrics(cdp);
+ const complete = new Promise<void>((resolve) =>
+ cdp.once("Tracing.tracingComplete", () => resolve()),
+ );
+ await cdp.send("Tracing.end");
+ await complete;
+ cdp.off("Tracing.dataCollected", window.onData);
+ const cpuProfile = window.profile
+ ? (await cdp.send("Profiler.stop")).profile
+ : undefined;
+ const longTasks = summarizeLongTasks(window.events);
+ return {
+ scriptMs: durationMs(window.before, after, "ScriptDuration"),
+ taskMs: durationMs(window.before, after, "TaskDuration"),
+ layoutMs: durationMs(window.before, after, "LayoutDuration"),
+ recalcStyleMs: durationMs(window.before, after, "RecalcStyleDuration"),
+ longTaskCount: longTasks.count,
+ longTaskMs: longTasks.totalMs,
+ cpuProfile,
+ };
+}
+
+export async function heapAfterGC(cdp: CDPSession, page: Page) {
+ await cdp.send("HeapProfiler.collectGarbage");
+ await page.waitForTimeout(GC_SETTLE_MS);
+ const metrics = await readMetrics(cdp);
+ return (metrics.JSHeapUsedSize ?? 0) / (1024 * 1024);
+}
diff --git a/autogpt_platform/frontend/scripts/perf/lib/copilot-fixture.ts b/autogpt_platform/frontend/scripts/perf/lib/copilot-fixture.ts
new file mode 100644
index 0000000000..0fd25e15a2
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/lib/copilot-fixture.ts
@@ -0,0 +1,246 @@
+import fs from "fs";
+import path from "path";
+import { FIXTURES_DIR } from "./paths";
+import { fulfillJSON, type RouteHandlers } from "./routes";
+import { readFixture, splitFrames, type StreamServer } from "./stream-server";
+
+const FIXED_TIME = "2026-01-05T09:00:00.000Z";
+const STREAM_TIMEOUT_MS = 120_000;
+const TURN_START_TIMEOUT_MS = 15_000;
+const POLL_MS = 50;
+/** How long to wait for the page to refetch the session after a turn. */
+const REFETCH_TIMEOUT_MS = 5_000;
+
+export interface SessionSpec {
+ id: string;
+ title: string;
+ messageCount: number;
+}
+
+interface SessionRow {
+ role: string;
+ content: string;
+ sequence: number;
+ [key: string]: unknown;
+}
+
+interface Args {
+ userID: string;
+ sessions: SessionSpec[];
+ stream: StreamServer;
+ replyFixture: string;
+ paceMs: number;
+}
+
+export const SESSION_L = "00000000-0000-4000-8000-0000000000a1";
+export const SESSION_M = "00000000-0000-4000-8000-0000000000a2";
+export const SESSION_S = "00000000-0000-4000-8000-0000000000a3";
+
+export const COPILOT_SESSIONS: SessionSpec[] = [
+ { id: SESSION_L, title: "Perf: long thread (200)", messageCount: 200 },
+ { id: SESSION_M, title: "Perf: medium thread (50)", messageCount: 50 },
+ { id: SESSION_S, title: "Perf: short thread (10)", messageCount: 10 },
+];
+
+function loadSessionRows(): SessionRow[] {
+ const file = path.join(FIXTURES_DIR, "session-200.json");
+ return (JSON.parse(fs.readFileSync(file, "utf8")) as { messages: [] })
+ .messages;
+}
+
+/** The reply's text, from the `data:` line of each frame (recorded frames
+ * also carry `id:` lines and `: comment` heartbeats). */
+export function replyText(sse: string) {
+ return splitFrames(sse)
+ .flatMap((frame) => frame.split("\n"))
+ .filter((line) => line.startsWith("data: {"))
+ .map((line) => line.slice("data: ".length))
+ .map((data) => JSON.parse(data) as { type: string; delta?: string })
+ .filter((event) => event.type === "text-delta")
+ .map((event) => event.delta ?? "")
+ .join("");
+}
+
+/**
+ * Serves the copilot session list, session detail and stream from fixtures.
+ * Stateful on purpose: once a streamed turn ends, the session detail returns
+ * the new user and assistant rows, as the backend would, so the page's
+ * post-turn refetch does not wipe the reply it just streamed.
+ */
+export function createCopilotFixture({
+ userID,
+ sessions,
+ stream,
+ replyFixture,
+ paceMs,
+}: Args) {
+ const allRows = loadSessionRows();
+ const reply = replyText(readFixture(replyFixture));
+ const extraRows = new Map<string, SessionRow[]>();
+ const pendingTurns: string[] = [];
+ const turnSessions: string[] = [];
+ const servedTurns = new Map<string, number>();
+
+ function find(id: string) {
+ return sessions.find((session) => session.id === id);
+ }
+
+ function rowsFor(spec: SessionSpec) {
+ const rows = [
+ ...allRows.slice(0, spec.messageCount),
+ ...(extraRows.get(spec.id) ?? []),
+ ];
+ return rows.map((row) => ({ ...row, session_id: spec.id }));
+ }
+
+ function detail(spec: SessionSpec) {
+ const messages = rowsFor(spec);
+ return {
+ id: spec.id,
+ created_at: FIXED_TIME,
+ updated_at: FIXED_TIME,
+ user_id: userID,
+ chat_status: "idle",
+ messages,
+ active_stream: null,
+ has_more_messages: false,
+ oldest_sequence: messages[0]?.sequence ?? null,
+ total_prompt_tokens: 0,
+ total_completion_tokens: 0,
+ metadata: { dry_run: false, kind: "normal" },
+ expert_id: null,
+ };
+ }
+
+ function summary(spec: SessionSpec) {
+ return {
+ id: spec.id,
+ created_at: FIXED_TIME,
+ updated_at: FIXED_TIME,
+ title: spec.title,
+ chat_status: "idle",
+ is_processing: false,
+ source_platform: null,
+ is_pinned: false,
+ expert_id: null,
+ };
+ }
+
+ function appendTurn(spec: SessionSpec, message: string) {
+ const rows = rowsFor(spec);
+ const next = (rows.at(-1)?.sequence ?? -1) + 1;
+ const added = [
+ { role: "user", content: message, sequence: next },
+ { role: "assistant", content: reply, sequence: next + 1 },
+ ].map((row) => ({
+ id: `perf-turn-${spec.id}-${row.sequence}`,
+ tool_calls: null,
+ tool_call_id: null,
+ duration_ms: null,
+ created_at: FIXED_TIME,
+ metadata: {},
+ ...row,
+ }));
+ extraRows.set(spec.id, [...(extraRows.get(spec.id) ?? []), ...added]);
+ }
+
+ const handlers: RouteHandlers = {
+ chatSessionList: async (route) => {
+ if (route.request().method() !== "GET") return route.fallback();
+ await fulfillJSON(route, {
+ sessions: sessions.map(summary),
+ total: sessions.length,
+ });
+ },
+ chatSession: async (route, match) => {
+ const spec = find(match[1]);
+ if (!spec || route.request().method() !== "GET") return route.fallback();
+ const olderPage = new URL(route.request().url()).searchParams.has(
+ "before_sequence",
+ );
+ if (!olderPage) {
+ servedTurns.set(spec.id, (extraRows.get(spec.id)?.length ?? 0) / 2);
+ }
+ await fulfillJSON(
+ route,
+ olderPage
+ ? { ...detail(spec), messages: [], has_more_messages: false }
+ : detail(spec),
+ );
+ },
+ chatSessionChild: async (route, match) => {
+ if (!find(match[1])) return route.fallback();
+ const child = match[2];
+ if (child === "messages/pending") {
+ return fulfillJSON(route, { messages: [], count: 0 });
+ }
+ if (child === "at-reset") return fulfillJSON(route, { jobs: [] });
+ if (child === "share/state") {
+ return fulfillJSON(route, { is_shared: false, share_token: null });
+ }
+ await fulfillJSON(route, {});
+ },
+ chatStream: async (route, match) => {
+ const spec = find(match[1]);
+ const request = route.request();
+ if (!spec) return route.fallback();
+ if (request.method() !== "POST") {
+ return route.fulfill({ status: 204 });
+ }
+ const { url, tag } = stream.open({ fixture: replyFixture, paceMs });
+ const body = request.postDataJSON() as { message?: string } | null;
+ pendingTurns.push(tag);
+ turnSessions.push(spec.id);
+ stream
+ .waitForDone(tag, STREAM_TIMEOUT_MS)
+ .then(() => appendTurn(spec, body?.message ?? ""))
+ .catch(() => undefined);
+ await route.continue({ url });
+ },
+ };
+
+ return {
+ handlers,
+ /**
+ * Resolves once turn number `turn` (1-based) has been fully streamed and
+ * the page has refetched the session with it. Ending the window on that
+ * refetch, rather than on a timer after the stream, keeps the page's
+ * post-turn re-render inside the window on every run. If the page never
+ * refetches, it gives up after REFETCH_TIMEOUT_MS and carries on.
+ */
+ async waitForTurn(turn: number) {
+ await until(
+ () => pendingTurns.length >= turn,
+ TURN_START_TIMEOUT_MS,
+ () => {
+ throw new Error(`Copilot turn ${turn} never reached the stream`);
+ },
+ );
+ await stream.waitForDone(pendingTurns[turn - 1], STREAM_TIMEOUT_MS);
+ const session = turnSessions[turn - 1];
+ const turnInSession = turnSessions
+ .slice(0, turn)
+ .filter((id) => id === session).length;
+ await until(
+ () => (servedTurns.get(session) ?? 0) >= turnInSession,
+ REFETCH_TIMEOUT_MS,
+ () =>
+ console.warn(
+ `⚠ the page did not refetch the session after turn ${turn}`,
+ ),
+ );
+ },
+ };
+}
+
+async function until(
+ condition: () => boolean,
+ timeoutMs: number,
+ onTimeout: () => void,
+) {
+ const deadline = Date.now() + timeoutMs;
+ while (!condition()) {
+ if (Date.now() > deadline) return onTimeout();
+ await new Promise((resolve) => setTimeout(resolve, POLL_MS));
+ }
+}
diff --git a/autogpt_platform/frontend/scripts/perf/lib/copilot-page.ts b/autogpt_platform/frontend/scripts/perf/lib/copilot-page.ts
new file mode 100644
index 0000000000..d8812306e3
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/lib/copilot-page.ts
@@ -0,0 +1,57 @@
+import { CopilotPage } from "../../../src/playwright/pages/copilot.page";
+import {
+ COPILOT_SESSIONS,
+ createCopilotFixture,
+ SESSION_L,
+} from "./copilot-fixture";
+import { installRoutes } from "./routes";
+import { settle, type ScenarioContext } from "./scenario";
+
+export const REPLY_FIXTURE = "reply-20-lines.sse";
+/** About 33 streamed chunks a second, the pace of a real reply. */
+export const LIVE_PACE_MS = 30;
+const READY_TIMEOUT_MS = 60_000;
+
+interface OpenArgs {
+ ctx: ScenarioContext;
+ paceMs?: number;
+}
+
+/**
+ * Serves the three fixture sessions, opens the 200-message one and waits
+ * until its newest message and the composer are on screen.
+ */
+export async function openLongSession({
+ ctx,
+ paceMs = LIVE_PACE_MS,
+}: OpenArgs) {
+ const fixture = createCopilotFixture({
+ userID: ctx.userID,
+ sessions: COPILOT_SESSIONS,
+ stream: ctx.stream,
+ replyFixture: REPLY_FIXTURE,
+ paceMs,
+ });
+ await installRoutes(ctx.page, fixture.handlers);
+ const copilot = new CopilotPage(ctx.page);
+ await copilot.open(SESSION_L);
+ await copilot
+ .getChatInput()
+ .waitFor({ state: "visible", timeout: READY_TIMEOUT_MS });
+ await ctx.page
+ .getByText(/^Turn \d+: can you help/)
+ .last()
+ .waitFor({ state: "visible", timeout: READY_TIMEOUT_MS });
+ await settle(ctx.page);
+ return { fixture, copilot };
+}
+
+export async function sendMessage(
+ copilot: CopilotPage,
+ message: string,
+): Promise<void> {
+ const input = copilot.getChatInput();
+ await input.click();
+ await input.fill(message);
+ await input.press("Enter");
+}
diff --git a/autogpt_platform/frontend/scripts/perf/lib/library-fixture.ts b/autogpt_platform/frontend/scripts/perf/lib/library-fixture.ts
new file mode 100644
index 0000000000..5ec855556f
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/lib/library-fixture.ts
@@ -0,0 +1,101 @@
+import { fulfillJSON, type RouteHandlers } from "./routes";
+
+const FIXED_TIME = "2026-01-05T09:00:00.000Z";
+
+function fixtureID(group: string, index: number) {
+ return `00000000-0000-4000-${group}-${String(index).padStart(12, "0")}`;
+}
+
+export function buildLibraryAgents(count = 20) {
+ return Array.from({ length: count }, (_, index) => ({
+ id: fixtureID("c000", index),
+ graph_id: fixtureID("c100", index),
+ graph_version: 1,
+ image_url: null,
+ creator_name: "Perf Harness",
+ creator_image_url: "",
+ status: "COMPLETED",
+ created_at: FIXED_TIME,
+ updated_at: FIXED_TIME,
+ last_run_at: FIXED_TIME,
+ name: `Perf workflow ${String(index + 1).padStart(2, "0")}`,
+ description: "Fixture for the library-running scenario",
+ instructions: null,
+ input_schema: { type: "object", properties: {}, required: [] },
+ output_schema: { type: "object", properties: {}, required: [] },
+ credentials_input_schema: null,
+ has_external_trigger: false,
+ has_human_in_the_loop: false,
+ has_sensitive_action: false,
+ trigger_setup_info: null,
+ new_output: false,
+ execution_count: 12,
+ success_rate: null,
+ avg_correctness_score: null,
+ recent_executions: [],
+ can_access_graph: true,
+ is_latest_version: true,
+ is_favorite: false,
+ folder_id: null,
+ folder_name: null,
+ is_hidden: false,
+ recommended_schedule_cron: null,
+ is_scheduled: false,
+ next_scheduled_run: null,
+ settings: {
+ human_in_the_loop_safe_mode: true,
+ sensitive_action_safe_mode: false,
+ builder_chat_session_id: null,
+ },
+ marketplace_listing: null,
+ }));
+}
+
+export function buildRunningExecutions(
+ agents: ReturnType<typeof buildLibraryAgents>,
+ userID: string,
+) {
+ return agents.map((agent, index) => ({
+ id: fixtureID("c200", index),
+ user_id: userID,
+ graph_id: agent.graph_id,
+ graph_version: agent.graph_version,
+ inputs: {},
+ credential_inputs: {},
+ nodes_input_masks: null,
+ preset_id: null,
+ status: "RUNNING",
+ started_at: FIXED_TIME,
+ ended_at: null,
+ is_shared: false,
+ share_token: null,
+ is_dry_run: false,
+ stats: null,
+ }));
+}
+
+export function createLibraryFixture(userID: string) {
+ const agents = buildLibraryAgents();
+ const executions = buildRunningExecutions(agents, userID);
+ const handlers: RouteHandlers = {
+ libraryAgents: async (route) => {
+ if (route.request().method() !== "GET") return route.fallback();
+ const params = new URL(route.request().url()).searchParams;
+ const pageSize = Number(params.get("page_size") ?? agents.length);
+ await fulfillJSON(route, {
+ agents: agents.slice(0, pageSize),
+ pagination: {
+ total_items: agents.length,
+ total_pages: 1,
+ current_page: 1,
+ page_size: pageSize,
+ },
+ });
+ },
+ executions: async (route) => {
+ if (route.request().method() !== "GET") return route.fallback();
+ await fulfillJSON(route, executions);
+ },
+ };
+ return { handlers, agents, executions };
+}
diff --git a/autogpt_platform/frontend/scripts/perf/lib/paths.ts b/autogpt_platform/frontend/scripts/perf/lib/paths.ts
new file mode 100644
index 0000000000..6b82a36f1e
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/lib/paths.ts
@@ -0,0 +1,9 @@
+import path from "path";
+
+export const FRONTEND_ROOT = path.resolve(__dirname, "../../..");
+export const PERF_OUTPUT_DIR = path.join(FRONTEND_ROOT, ".perf");
+export const FIXTURES_DIR = path.resolve(__dirname, "../fixtures");
+
+export function scenarioOutputDir(scenario: string) {
+ return path.join(PERF_OUTPUT_DIR, scenario);
+}
diff --git a/autogpt_platform/frontend/scripts/perf/lib/render-counter.ts b/autogpt_platform/frontend/scripts/perf/lib/render-counter.ts
new file mode 100644
index 0000000000..18cf5c9c9c
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/lib/render-counter.ts
@@ -0,0 +1,46 @@
+import type { Page } from "@playwright/test";
+import type { RankedEntry } from "./report";
+
+export interface CounterReport {
+ commits: number;
+ totalRenders: number;
+ rendersPerCommit: number;
+ maxRendersPerCommit: number;
+ components: RankedEntry[];
+ causes: RankedEntry[];
+}
+
+interface RenderCounter {
+ start(): void;
+ stop(): void;
+ reset(): void;
+ report(): CounterReport;
+}
+
+type CounterWindow = Window & { __renderCounter?: RenderCounter };
+
+export async function assertCounterLoaded(page: Page) {
+ const present = await page.evaluate(
+ () => typeof (window as CounterWindow).__renderCounter === "object",
+ );
+ if (!present) {
+ throw new Error(
+ "window.__renderCounter is missing. Start the dev server with NEXT_PUBLIC_RENDER_COUNTER=1 pnpm dev (see docs/engineering/frontend-perf-measurement.md).",
+ );
+ }
+}
+
+export function counter(page: Page, action: "start" | "stop" | "reset") {
+ return page.evaluate(
+ (name) => (window as CounterWindow).__renderCounter?.[name](),
+ action,
+ );
+}
+
+export async function counterReport(page: Page) {
+ const report = await page.evaluate(() =>
+ (window as CounterWindow).__renderCounter?.report(),
+ );
+ if (!report) throw new Error("window.__renderCounter disappeared mid-run");
+ return report;
+}
diff --git a/autogpt_platform/frontend/scripts/perf/lib/report.ts b/autogpt_platform/frontend/scripts/perf/lib/report.ts
new file mode 100644
index 0000000000..4eec3362d9
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/lib/report.ts
@@ -0,0 +1,294 @@
+import fs from "fs";
+import path from "path";
+
+export interface RunMetrics {
+ commits: number;
+ totalRenders: number;
+ rendersPerCommit: number;
+ maxRendersPerCommit: number;
+ scriptMs: number;
+ taskMs: number;
+ layoutMs: number;
+ recalcStyleMs: number;
+ longTaskCount: number;
+ longTaskMs: number;
+ heapUsedMB: number;
+}
+
+export interface RankedEntry {
+ key: string;
+ count: number;
+}
+
+export interface RunResult {
+ scenario: string;
+ label: string;
+ run: number;
+ startedAt: string;
+ gitSha: string | null;
+ baseURL: string;
+ windowMs: number;
+ metrics: RunMetrics;
+ components: RankedEntry[];
+ causes: RankedEntry[];
+ pageErrors: number;
+ cpuProfile?: string;
+}
+
+interface MetricRow {
+ key: keyof RunMetrics;
+ label: string;
+ digits: number;
+}
+
+export const METRIC_ROWS: MetricRow[] = [
+ { key: "commits", label: "commits", digits: 0 },
+ { key: "totalRenders", label: "total renders", digits: 0 },
+ { key: "rendersPerCommit", label: "renders per commit", digits: 1 },
+ { key: "maxRendersPerCommit", label: "max renders in one commit", digits: 0 },
+ { key: "scriptMs", label: "script time (ms)", digits: 0 },
+ { key: "taskMs", label: "task time (ms)", digits: 0 },
+ { key: "layoutMs", label: "layout time (ms)", digits: 0 },
+ { key: "recalcStyleMs", label: "style recalc time (ms)", digits: 0 },
+ { key: "longTaskCount", label: "long tasks (≥ 50 ms)", digits: 0 },
+ { key: "longTaskMs", label: "long task total (ms)", digits: 0 },
+ { key: "heapUsedMB", label: "heap used after GC (MB)", digits: 1 },
+];
+
+const TOP_N = 10;
+
+export function median(values: number[]): number {
+ if (values.length === 0) return 0;
+ const sorted = [...values].sort((a, b) => a - b);
+ const middle = Math.floor(sorted.length / 2);
+ return sorted.length % 2
+ ? sorted[middle]
+ : (sorted[middle - 1] + sorted[middle]) / 2;
+}
+
+function medianRanking(lists: RankedEntry[][]): RankedEntry[] {
+ const keys = new Set(lists.flatMap((list) => list.map((entry) => entry.key)));
+ const perRun = lists.map(
+ (list) => new Map(list.map((entry) => [entry.key, entry.count])),
+ );
+ return Array.from(keys, (key) => ({
+ key,
+ count: median(perRun.map((counts) => counts.get(key) ?? 0)),
+ }))
+ .filter((entry) => entry.count > 0)
+ .sort((a, b) => b.count - a.count || a.key.localeCompare(b.key));
+}
+
+export function summarize(runs: RunResult[]) {
+ const metrics = Object.fromEntries(
+ METRIC_ROWS.map(({ key }) => [
+ key,
+ median(runs.map((run) => run.metrics[key])),
+ ]),
+ ) as unknown as RunMetrics;
+ return {
+ metrics,
+ components: medianRanking(runs.map((run) => run.components)),
+ causes: medianRanking(runs.map((run) => run.causes)),
+ };
+}
+
+function formatNumber(value: number, digits: number) {
+ return value.toLocaleString("en-US", {
+ minimumFractionDigits: digits,
+ maximumFractionDigits: digits,
+ });
+}
+
+export function formatDelta(a: number, b: number, digits: number) {
+ const diff = b - a;
+ const sign = diff > 0 ? "+" : "";
+ const absolute = `${sign}${formatNumber(diff, digits)}`;
+ if (a === 0) return diff === 0 ? "0" : absolute;
+ const percent = (diff / Math.abs(a)) * 100;
+ return `${absolute} (${sign}${percent.toFixed(1)}%)`;
+}
+
+function table(header: string[], rows: string[][]) {
+ const line = (cells: string[]) => `| ${cells.join(" | ")} |`;
+ return [line(header), line(header.map(() => "---")), ...rows.map(line)].join(
+ "\n",
+ );
+}
+
+function rankingTable(title: string, entries: RankedEntry[]) {
+ const rows = entries
+ .slice(0, TOP_N)
+ .map((entry) => [`\`${entry.key}\``, formatNumber(entry.count, 0)]);
+ return `**${title}**\n\n${table(["name", "renders"], rows)}`;
+}
+
+export function formatRun(result: RunResult) {
+ const rows = METRIC_ROWS.map(({ key, label, digits }) => [
+ label,
+ formatNumber(result.metrics[key], digits),
+ ]);
+ return [
+ `### ${result.scenario} · ${result.label} · run ${result.run}`,
+ table(["metric", "value"], rows),
+ rankingTable("Top components", result.components),
+ rankingTable("Top render causes", result.causes),
+ ].join("\n\n");
+}
+
+interface LabelledRuns {
+ label: string;
+ runs: RunResult[];
+}
+
+interface CompareArgs {
+ scenario: string;
+ a: LabelledRuns;
+ b: LabelledRuns;
+}
+
+function sideBySideRanking(
+ title: string,
+ a: { label: string; entries: RankedEntry[] },
+ b: { label: string; entries: RankedEntry[] },
+) {
+ const countsA = new Map(a.entries.map((entry) => [entry.key, entry.count]));
+ const countsB = new Map(b.entries.map((entry) => [entry.key, entry.count]));
+ const keys = Array.from(
+ new Set([
+ ...a.entries.slice(0, TOP_N).map((entry) => entry.key),
+ ...b.entries.slice(0, TOP_N).map((entry) => entry.key),
+ ]),
+ ).sort(
+ (x, y) =>
+ Math.max(countsB.get(y) ?? 0, countsA.get(y) ?? 0) -
+ Math.max(countsB.get(x) ?? 0, countsA.get(x) ?? 0),
+ );
+ const rows = keys.map((key) => {
+ const valueA = countsA.get(key) ?? 0;
+ const valueB = countsB.get(key) ?? 0;
+ return [
+ `\`${key}\``,
+ formatNumber(valueA, 0),
+ formatNumber(valueB, 0),
+ formatDelta(valueA, valueB, 0),
+ ];
+ });
+ return `**${title}** (median renders)\n\n${table(["name", a.label, b.label, "Δ"], rows)}`;
+}
+
+function runsTable(sets: LabelledRuns[]) {
+ const rows = sets.flatMap(({ label, runs }) =>
+ runs.map((run) => [
+ label,
+ String(run.run),
+ run.gitSha?.slice(0, 9) ?? "?",
+ formatNumber(run.metrics.commits, 0),
+ formatNumber(run.metrics.totalRenders, 0),
+ formatNumber(run.metrics.rendersPerCommit, 1),
+ formatNumber(run.metrics.scriptMs, 0),
+ formatNumber(run.metrics.longTaskCount, 0),
+ formatNumber(run.metrics.heapUsedMB, 1),
+ ]),
+ );
+ return table(
+ [
+ "label",
+ "run",
+ "commit",
+ "commits",
+ "renders",
+ "renders/commit",
+ "script ms",
+ "long tasks",
+ "heap MB",
+ ],
+ rows,
+ );
+}
+
+export function formatComparison({ scenario, a, b }: CompareArgs) {
+ const summaryA = summarize(a.runs);
+ const summaryB = summarize(b.runs);
+ const metricRows = METRIC_ROWS.map(({ key, label, digits }) => [
+ label,
+ formatNumber(summaryA.metrics[key], digits),
+ formatNumber(summaryB.metrics[key], digits),
+ formatDelta(summaryA.metrics[key], summaryB.metrics[key], digits),
+ ]);
+ return [
+ `### ${scenario} — median of ${a.runs.length} (${a.label}) vs ${b.runs.length} (${b.label})`,
+ table(["metric", a.label, b.label, "Δ"], metricRows),
+ sideBySideRanking(
+ "Top components",
+ { label: a.label, entries: summaryA.components },
+ { label: b.label, entries: summaryB.components },
+ ),
+ sideBySideRanking(
+ "Top render causes",
+ { label: a.label, entries: summaryA.causes },
+ { label: b.label, entries: summaryB.causes },
+ ),
+ `<details><summary>Raw runs</summary>\n\n${runsTable([a, b])}\n\n</details>`,
+ ].join("\n\n");
+}
+
+export function spreadPercent(values: number[]) {
+ const middle = median(values);
+ if (values.length < 2 || middle === 0) return 0;
+ return ((Math.max(...values) - Math.min(...values)) / Math.abs(middle)) * 100;
+}
+
+export function formatSummary({ label, runs }: LabelledRuns) {
+ const rows = METRIC_ROWS.map(({ key, label: name, digits }) => {
+ const values = runs.map((run) => run.metrics[key]);
+ return [
+ name,
+ formatNumber(median(values), digits),
+ `${formatNumber(Math.min(...values), digits)} – ${formatNumber(Math.max(...values), digits)}`,
+ `${spreadPercent(values).toFixed(1)}%`,
+ ];
+ });
+ const scenario = runs[0]?.scenario ?? "?";
+ const summary = summarize(runs);
+ return [
+ `### ${scenario} · ${label} — median of ${runs.length} runs`,
+ table(["metric", "median", "range", "spread"], rows),
+ rankingTable("Top components (median renders)", summary.components),
+ rankingTable("Top render causes (median renders)", summary.causes),
+ ].join("\n\n");
+}
+
+export function safeLabel(label: string) {
+ if (!/^[A-Za-z0-9._-]+$/.test(label)) {
+ throw new Error(
+ `Label "${label}" may only contain letters, digits, ".", "_" and "-".`,
+ );
+ }
+ return label;
+}
+
+export function runFileName(result: RunResult) {
+ const stamp = result.startedAt.replace(/[:.]/g, "-");
+ return `${result.label}-${stamp}-${result.run}.json`;
+}
+
+export function writeRun(dir: string, result: RunResult) {
+ fs.mkdirSync(dir, { recursive: true });
+ const file = path.join(dir, runFileName(result));
+ fs.writeFileSync(file, `${JSON.stringify(result, null, 2)}\n`);
+ return file;
+}
+
+export function loadRuns(dir: string, label: string): RunResult[] {
+ if (!fs.existsSync(dir)) return [];
+ return fs
+ .readdirSync(dir)
+ .filter((name) => name.endsWith(".json"))
+ .map(
+ (name) =>
+ JSON.parse(fs.readFileSync(path.join(dir, name), "utf8")) as RunResult,
+ )
+ .filter((result) => result.label === label)
+ .sort((x, y) => x.startedAt.localeCompare(y.startedAt) || x.run - y.run);
+}
diff --git a/autogpt_platform/frontend/scripts/perf/lib/routes.ts b/autogpt_platform/frontend/scripts/perf/lib/routes.ts
new file mode 100644
index 0000000000..8644bd072d
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/lib/routes.ts
@@ -0,0 +1,76 @@
+import type { Page, Route } from "@playwright/test";
+
+/**
+ * Every URL the harness intercepts, in match order. Anything not listed goes
+ * to the real dev server and backend untouched.
+ *
+ * Generated API hooks reach the backend through the Next proxy
+ * (`/api/proxy/api/...`); the copilot stream goes straight to the backend
+ * (`http://localhost:8006/api/chat/sessions/{id}/stream`), so that pattern
+ * matches either host.
+ */
+const ROUTE_TABLE = [
+ ["featureFlags", /^\/api\/proxy\/api\/feature-flags$/],
+ ["onboardingCompleted", /^\/api\/proxy\/api\/onboarding\/completed$/],
+ ["chatStream", /\/api\/chat\/sessions\/([^/]+)\/stream$/],
+ ["chatSessionList", /^\/api\/proxy\/api\/chat\/sessions$/],
+ ["chatSession", /^\/api\/proxy\/api\/chat\/sessions\/([^/]+)$/],
+ ["chatSessionChild", /^\/api\/proxy\/api\/chat\/sessions\/([^/]+)\/(.+)$/],
+ [
+ "graphExecution",
+ /^\/api\/proxy\/api\/graphs\/([^/]+)\/executions\/([^/]+)$/,
+ ],
+ ["graph", /^\/api\/proxy\/api\/graphs\/([^/]+)$/],
+ ["libraryAgents", /^\/api\/proxy\/api\/library\/agents$/],
+ ["executions", /^\/api\/proxy\/api\/executions$/],
+] as const;
+
+export type RouteName = (typeof ROUTE_TABLE)[number][0];
+
+export type RouteHandler = (
+ route: Route,
+ match: RegExpMatchArray,
+) => Promise<void>;
+
+export type RouteHandlers = Partial<Record<RouteName, RouteHandler>>;
+
+export function matchRoute(url: string, handlers: RouteHandlers) {
+ const { pathname } = new URL(url);
+ for (const [name, pattern] of ROUTE_TABLE) {
+ const handler = handlers[name];
+ const match = handler ? pathname.match(pattern) : null;
+ if (handler && match) return { name, handler, match };
+ }
+ return null;
+}
+
+export async function installRoutes(page: Page, handlers: RouteHandlers) {
+ await page.route(
+ (url) => matchRoute(url.toString(), handlers) !== null,
+ async (route) => {
+ const hit = matchRoute(route.request().url(), handlers);
+ if (!hit) return route.fallback();
+ await hit.handler(route, hit.match);
+ },
+ );
+}
+
+export function fulfillJSON(route: Route, body: unknown, status = 200) {
+ return route.fulfill({
+ status,
+ contentType: "application/json",
+ body: JSON.stringify(body),
+ });
+}
+
+/**
+ * Pins the parts of every page that would otherwise differ between machines:
+ * feature flags fall back to their code defaults and onboarding counts as done.
+ */
+export function commonHandlers(): RouteHandlers {
+ return {
+ featureFlags: (route) =>
+ fulfillJSON(route, { flags: {}, configured: false }),
+ onboardingCompleted: (route) => fulfillJSON(route, { is_completed: true }),
+ };
+}
diff --git a/autogpt_platform/frontend/scripts/perf/lib/scenario.ts b/autogpt_platform/frontend/scripts/perf/lib/scenario.ts
new file mode 100644
index 0000000000..763a9fa026
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/lib/scenario.ts
@@ -0,0 +1,37 @@
+import type { BrowserContext, Page } from "@playwright/test";
+import type { StreamServer } from "./stream-server";
+
+export interface ScenarioContext {
+ page: Page;
+ context: BrowserContext;
+ baseURL: string;
+ userID: string;
+ stream: StreamServer;
+}
+
+export interface ScenarioRun {
+ /** The measured interaction. The window stays open `windowMs` after it. */
+ run(): Promise<void>;
+}
+
+export interface Scenario {
+ name: string;
+ description: string;
+ /** What setup waits for before the window opens, so runs are comparable. */
+ readyWhen: string;
+ windowMs: number;
+ setup(ctx: ScenarioContext): Promise<ScenarioRun>;
+}
+
+const NETWORK_IDLE_TIMEOUT_MS = 15_000;
+const SETTLE_MS = 1_000;
+
+/** Network idle (or 15 s of polling, whichever is first), then 1 s more. */
+export async function settle(page: Page) {
+ await page
+ .waitForLoadState("networkidle", { timeout: NETWORK_IDLE_TIMEOUT_MS })
+ .catch(() => undefined);
+ await page.waitForTimeout(SETTLE_MS);
+}
+
+export const noInteraction: ScenarioRun = { run: async () => undefined };
diff --git a/autogpt_platform/frontend/scripts/perf/lib/stream-server.ts b/autogpt_platform/frontend/scripts/perf/lib/stream-server.ts
new file mode 100644
index 0000000000..3251ef1821
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/lib/stream-server.ts
@@ -0,0 +1,121 @@
+import fs from "fs";
+import http from "http";
+import type { AddressInfo } from "net";
+import path from "path";
+import { FIXTURES_DIR } from "./paths";
+
+/**
+ * Replays a recorded `.sse` body one frame every `paceMs`, so a streamed
+ * reply arrives at a steady, repeatable cadence instead of all at once.
+ * The harness points the copilot stream request here with `route.continue`.
+ * The fixture and pace of each stream are registered in-process by `open()`,
+ * which hands out a tag that is unique for the life of the server; the
+ * request only carries that tag.
+ */
+export interface StreamServer {
+ open(args: { fixture: string; paceMs: number }): { url: string; tag: string };
+ waitForDone(tag: string, timeoutMs: number): Promise<void>;
+ close(): Promise<void>;
+}
+
+export function splitFrames(body: string) {
+ return body
+ .split(/\n\n+/)
+ .map((frame) => frame.trim())
+ .filter(Boolean);
+}
+
+export function readFixture(name: string) {
+ if (!/^[\w.-]+$/.test(name)) throw new Error(`Bad fixture name: ${name}`);
+ return fs.readFileSync(path.join(FIXTURES_DIR, name), "utf8");
+}
+
+function corsHeaders(request: http.IncomingMessage) {
+ return {
+ "Access-Control-Allow-Origin": request.headers.origin ?? "*",
+ "Access-Control-Allow-Credentials": "true",
+ "Access-Control-Allow-Headers": "*",
+ "Access-Control-Allow-Methods": "GET, POST, OPTIONS",
+ };
+}
+
+export async function startStreamServer(): Promise<StreamServer> {
+ const finished = new Set<string>();
+ const waiters = new Map<string, (() => void)[]>();
+ const timers = new Set<ReturnType<typeof setTimeout>>();
+ const streams = new Map<string, { frames: string[]; paceMs: number }>();
+ let opened = 0;
+
+ function markDone(tag: string) {
+ finished.add(tag);
+ waiters.get(tag)?.forEach((resolve) => resolve());
+ waiters.delete(tag);
+ }
+
+ const server = http.createServer((request, response) => {
+ if (request.method === "OPTIONS") {
+ response.writeHead(204, corsHeaders(request)).end();
+ return;
+ }
+ const params = new URL(request.url ?? "/", "http://localhost").searchParams;
+ const tag = params.get("tag") ?? "";
+ const stream = streams.get(tag);
+ if (!stream) {
+ response.writeHead(404, corsHeaders(request)).end();
+ return;
+ }
+ const { frames, paceMs } = stream;
+ response.writeHead(200, {
+ ...corsHeaders(request),
+ "Content-Type": "text/event-stream",
+ "Cache-Control": "no-cache",
+ "x-vercel-ai-ui-message-stream": "v1",
+ });
+ let index = 0;
+ const timer = setInterval(() => {
+ if (index >= frames.length) {
+ clearInterval(timer);
+ response.end();
+ markDone(tag);
+ return;
+ }
+ response.write(`${frames[index++]}\n\n`);
+ }, paceMs);
+ response.on("close", () => clearInterval(timer));
+ });
+
+ await new Promise<void>((resolve) => server.listen(0, "127.0.0.1", resolve));
+ const { port } = server.address() as AddressInfo;
+
+ return {
+ open({ fixture, paceMs }) {
+ const tag = `stream-${++opened}`;
+ streams.set(tag, { frames: splitFrames(readFixture(fixture)), paceMs });
+ const query = new URLSearchParams({ tag });
+ return { url: `http://127.0.0.1:${port}/stream?${query}`, tag };
+ },
+ waitForDone(tag, timeoutMs) {
+ if (finished.has(tag)) return Promise.resolve();
+ return new Promise((resolve, reject) => {
+ const timeout = setTimeout(() => {
+ timers.delete(timeout);
+ reject(new Error(`Stream "${tag}" did not finish`));
+ }, timeoutMs);
+ timers.add(timeout);
+ waiters.set(tag, [
+ ...(waiters.get(tag) ?? []),
+ () => {
+ clearTimeout(timeout);
+ timers.delete(timeout);
+ resolve();
+ },
+ ]);
+ });
+ },
+ close() {
+ timers.forEach((timer) => clearTimeout(timer));
+ server.closeAllConnections();
+ return new Promise((resolve) => server.close(() => resolve()));
+ },
+ };
+}
diff --git a/autogpt_platform/frontend/scripts/perf/measure.ts b/autogpt_platform/frontend/scripts/perf/measure.ts
new file mode 100644
index 0000000000..75159213e7
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/measure.ts
@@ -0,0 +1,225 @@
+/**
+ * Measures one scenario: React renders (via the dev render counter), main
+ * thread time, long tasks and heap after GC. Writes one JSON per run to
+ * .perf/<scenario>/ and prints a table. Docs:
+ * docs/engineering/frontend-perf-measurement.md
+ *
+ * NEXT_PUBLIC_RENDER_COUNTER=1 pnpm dev # in another terminal
+ * pnpm perf --scenario copilot-stream-reply --label before --runs 3
+ */
+import { execSync } from "child_process";
+import fs from "fs";
+import path from "path";
+import { parseArgs } from "util";
+import { chromium, type Browser } from "@playwright/test";
+import { signIn } from "./lib/auth";
+import { heapAfterGC, openCDP, startWindow, stopWindow } from "./lib/cdp";
+import { scenarioOutputDir } from "./lib/paths";
+import {
+ assertCounterLoaded,
+ counter,
+ counterReport,
+} from "./lib/render-counter";
+import {
+ formatRun,
+ formatSummary,
+ runFileName,
+ safeLabel,
+ writeRun,
+ type RunResult,
+} from "./lib/report";
+import { commonHandlers, installRoutes } from "./lib/routes";
+import type { Scenario } from "./lib/scenario";
+import { startStreamServer, type StreamServer } from "./lib/stream-server";
+import { SCENARIOS, findScenario } from "./scenarios/registry";
+
+const RANKING_LIMIT = 50;
+
+function parseOptions() {
+ const { values } = parseArgs({
+ options: {
+ scenario: { type: "string" },
+ label: { type: "string", default: "any" },
+ runs: { type: "string", default: "3" },
+ warmup: { type: "string", default: "1" },
+ "base-url": { type: "string", default: "http://localhost:3000" },
+ profile: { type: "boolean", default: false },
+ headed: { type: "boolean", default: false },
+ screenshot: { type: "boolean", default: false },
+ channel: { type: "string" },
+ "storage-state": { type: "string" },
+ list: { type: "boolean", default: false },
+ },
+ });
+ if (values.list) {
+ SCENARIOS.forEach((scenario) =>
+ console.log(`${scenario.name.padEnd(28)} ${scenario.description}`),
+ );
+ process.exit(0);
+ }
+ const runs = Number(values.runs);
+ const warmup = Number(values.warmup);
+ if (!values.scenario) throw new Error("Pass --scenario <name> (or --list).");
+ if (!Number.isInteger(runs) || runs < 1) throw new Error("Bad --runs.");
+ if (!Number.isInteger(warmup) || warmup < 0) throw new Error("Bad --warmup.");
+ return {
+ scenario: findScenario(values.scenario),
+ label: safeLabel(values.label ?? "any"),
+ runs,
+ warmup,
+ baseURL: (values["base-url"] ?? "").replace(/\/$/, ""),
+ profile: values.profile ?? false,
+ headed: values.headed ?? false,
+ screenshot: values.screenshot ?? false,
+ channel: values.channel ?? process.env.PERF_BROWSER_CHANNEL,
+ storageState: values["storage-state"],
+ };
+}
+
+type Options = ReturnType<typeof parseOptions>;
+
+function gitSha() {
+ try {
+ return execSync("git rev-parse HEAD", { encoding: "utf8" }).trim();
+ } catch {
+ return null;
+ }
+}
+
+interface RunArgs {
+ browser: Browser;
+ stream: StreamServer;
+ scenario: Scenario;
+ options: Options;
+ run: number;
+ warmup: boolean;
+}
+
+async function measureOnce({
+ browser,
+ stream,
+ scenario,
+ options,
+ run,
+ warmup,
+}: RunArgs) {
+ const context = await browser.newContext({
+ baseURL: options.baseURL,
+ viewport: { width: 1440, height: 900 },
+ locale: "en-US",
+ timezoneId: "UTC",
+ storageState: options.storageState,
+ });
+ try {
+ const userID = await signIn(
+ context.request,
+ options.baseURL,
+ Boolean(options.storageState),
+ );
+ const page = await context.newPage();
+ const pageErrors: string[] = [];
+ page.on("pageerror", (error) => pageErrors.push(error.message));
+ await installRoutes(page, commonHandlers());
+ const cdp = await openCDP(context, page);
+ const ctx = { page, context, baseURL: options.baseURL, userID, stream };
+ const interaction = await scenario.setup(ctx);
+ await assertCounterLoaded(page);
+
+ await counter(page, "reset");
+ const traceWindow = await startWindow(cdp, options.profile && !warmup);
+ await counter(page, "start");
+ await interaction.run();
+ await page.waitForTimeout(scenario.windowMs);
+ await counter(page, "stop");
+ const timings = await stopWindow(cdp, traceWindow);
+ const heapUsedMB = await heapAfterGC(cdp, page);
+ const report = await counterReport(page);
+ if (warmup) return null;
+
+ const result: RunResult = {
+ scenario: scenario.name,
+ label: options.label,
+ run,
+ startedAt: new Date().toISOString(),
+ gitSha: gitSha(),
+ baseURL: options.baseURL,
+ windowMs: scenario.windowMs,
+ metrics: {
+ commits: report.commits,
+ totalRenders: report.totalRenders,
+ rendersPerCommit: report.rendersPerCommit,
+ maxRendersPerCommit: report.maxRendersPerCommit,
+ scriptMs: timings.scriptMs,
+ taskMs: timings.taskMs,
+ layoutMs: timings.layoutMs,
+ recalcStyleMs: timings.recalcStyleMs,
+ longTaskCount: timings.longTaskCount,
+ longTaskMs: timings.longTaskMs,
+ heapUsedMB,
+ },
+ components: report.components.slice(0, RANKING_LIMIT),
+ causes: report.causes.slice(0, RANKING_LIMIT),
+ pageErrors: pageErrors.length,
+ };
+ const stem = path.join(
+ scenarioOutputDir(scenario.name),
+ runFileName(result).replace(/\.json$/, ""),
+ );
+ fs.mkdirSync(path.dirname(stem), { recursive: true });
+ if (timings.cpuProfile) {
+ fs.writeFileSync(
+ `${stem}.cpuprofile`,
+ JSON.stringify(timings.cpuProfile),
+ );
+ result.cpuProfile = path.basename(`${stem}.cpuprofile`);
+ }
+ if (options.screenshot) await page.screenshot({ path: `${stem}.png` });
+ const file = writeRun(scenarioOutputDir(scenario.name), result);
+ console.log(`\n${formatRun(result)}\n\nsaved ${file}`);
+ if (pageErrors.length) {
+ console.warn(
+ `⚠ ${pageErrors.length} uncaught page error(s), first: ${pageErrors[0]}`,
+ );
+ }
+ return result;
+ } finally {
+ await context.close();
+ }
+}
+
+async function main() {
+ const options = parseOptions();
+ const { scenario } = options;
+ const stream = await startStreamServer();
+ const browser = await chromium.launch({
+ headless: !options.headed,
+ channel: options.channel,
+ });
+ const results: RunResult[] = [];
+ try {
+ const total = options.warmup + options.runs;
+ for (let index = 1; index <= total; index++) {
+ const warmup = index <= options.warmup;
+ const run = index - options.warmup;
+ console.log(
+ warmup
+ ? `\n▶ ${scenario.name} · warm-up ${index}/${options.warmup} (not saved)`
+ : `\n▶ ${scenario.name} · ${options.label} · run ${run}/${options.runs}`,
+ );
+ const args = { browser, stream, scenario, options, run, warmup };
+ const result = await measureOnce(args);
+ if (result) results.push(result);
+ }
+ } finally {
+ await browser.close();
+ await stream.close();
+ }
+ if (results.length > 1) {
+ console.log(`\n${formatSummary({ label: options.label, runs: results })}`);
+ }
+}
+
+main().catch((error: unknown) => {
+ console.error(error instanceof Error ? error.message : error);
+ process.exit(1);
+});
diff --git a/autogpt_platform/frontend/scripts/perf/record.ts b/autogpt_platform/frontend/scripts/perf/record.ts
new file mode 100644
index 0000000000..e0e547e824
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/record.ts
@@ -0,0 +1,98 @@
+/**
+ * Re-records the copilot fixtures from a real local stack, for when the wire
+ * format changes. Saves the session's messages as fixtures/session-200.json
+ * and, with --message, one streamed reply as fixtures/reply-20-lines.sse.
+ * Use a throwaway chat: the fixtures are committed.
+ *
+ * npx tsx scripts/perf/record.ts --session-id <id> [--message "go"]
+ */
+import { randomUUID } from "crypto";
+import fs from "fs";
+import path from "path";
+import { parseArgs } from "util";
+import { request as playwrightRequest } from "@playwright/test";
+import { signIn } from "./lib/auth";
+import { FIXTURES_DIR } from "./lib/paths";
+
+const MAX_SESSION_ROWS = 200;
+
+function parseOptions() {
+ const { values } = parseArgs({
+ options: {
+ "session-id": { type: "string" },
+ message: { type: "string" },
+ "base-url": { type: "string", default: "http://localhost:3000" },
+ "backend-url": { type: "string", default: "http://localhost:8006" },
+ "storage-state": { type: "string" },
+ "session-out": { type: "string", default: "session-200.json" },
+ "reply-out": { type: "string", default: "reply-20-lines.sse" },
+ },
+ });
+ if (!values["session-id"]) throw new Error("Pass --session-id <id>.");
+ return {
+ sessionID: values["session-id"],
+ message: values.message,
+ baseURL: (values["base-url"] ?? "").replace(/\/$/, ""),
+ backendURL: (values["backend-url"] ?? "").replace(/\/$/, ""),
+ storageState: values["storage-state"],
+ sessionOut: path.join(FIXTURES_DIR, values["session-out"] ?? ""),
+ replyOut: path.join(FIXTURES_DIR, values["reply-out"] ?? ""),
+ };
+}
+
+async function main() {
+ const options = parseOptions();
+ const request = await playwrightRequest.newContext({
+ storageState: options.storageState,
+ });
+ try {
+ await signIn(request, options.baseURL, Boolean(options.storageState));
+ const session = await request.get(
+ `${options.baseURL}/api/proxy/api/chat/sessions/${options.sessionID}?limit=${MAX_SESSION_ROWS}`,
+ );
+ if (!session.ok()) {
+ throw new Error(`Session GET failed with ${session.status()}`);
+ }
+ const { messages } = (await session.json()) as { messages: unknown[] };
+ fs.writeFileSync(
+ options.sessionOut,
+ `${JSON.stringify({ messages }, null, 2)}\n`,
+ );
+ console.log(`wrote ${messages.length} rows to ${options.sessionOut}`);
+ if (!options.message) return;
+
+ const token = await request.get(`${options.baseURL}/api/auth/token`);
+ const { token: jwt } = (await token.json()) as { token?: string };
+ if (!jwt) throw new Error("Could not mint a backend token");
+ const stream = await request.post(
+ `${options.backendURL}/api/chat/sessions/${options.sessionID}/stream`,
+ {
+ headers: { Authorization: `Bearer ${jwt}` },
+ data: {
+ message: options.message,
+ is_user_message: true,
+ context: null,
+ file_ids: null,
+ folder_ids: null,
+ model: null,
+ message_id: randomUUID(),
+ voice: false,
+ expert_kickoff: false,
+ },
+ timeout: 300_000,
+ },
+ );
+ if (!stream.ok()) {
+ throw new Error(`Stream POST failed with ${stream.status()}`);
+ }
+ fs.writeFileSync(options.replyOut, await stream.text());
+ console.log(`wrote the streamed reply to ${options.replyOut}`);
+ } finally {
+ await request.dispose();
+ }
+}
+
+main().catch((error: unknown) => {
+ console.error(error instanceof Error ? error.message : error);
+ process.exit(1);
+});
diff --git a/autogpt_platform/frontend/scripts/perf/scenarios/builder-drag-running.ts b/autogpt_platform/frontend/scripts/perf/scenarios/builder-drag-running.ts
new file mode 100644
index 0000000000..3823fa5a21
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/scenarios/builder-drag-running.ts
@@ -0,0 +1,48 @@
+import { BuildPage } from "../../../src/playwright/pages/build.page";
+import { createBuilderFixture } from "../lib/builder-fixture";
+import { installRoutes } from "../lib/routes";
+import { settle, type Scenario } from "../lib/scenario";
+
+const MOVES = 60;
+const DRAG_MS = 2_000;
+const STEP_PX = 4;
+const READY_TIMEOUT_MS = 60_000;
+
+export const builderDragRunning: Scenario = {
+ name: "builder-drag-running",
+ description:
+ "Drag one node of a 50-node workflow for 2 s (60 pointer moves) while its run is RUNNING.",
+ readyWhen:
+ "all 50 nodes are on the canvas with the running execution loaded, then network idle + 1 s",
+ windowMs: 2_000,
+ async setup(ctx) {
+ const { page } = ctx;
+ const fixture = createBuilderFixture(ctx.userID);
+ await installRoutes(page, fixture.handlers);
+ const builder = new BuildPage(page);
+ await page.goto(
+ `/build?flowID=${fixture.graph.id}&flowExecutionID=${fixture.execution.id}`,
+ );
+ await builder.closeTutorial();
+ const nodes = page.locator('[data-id^="custom-node-"]');
+ await nodes
+ .nth(fixture.graph.nodes.length - 1)
+ .waitFor({ state: "attached", timeout: READY_TIMEOUT_MS });
+ await settle(page);
+ const box = await nodes.first().boundingBox();
+ if (!box) throw new Error("First node has no bounding box");
+ return {
+ async run() {
+ const x = box.x + box.width / 2;
+ const y = box.y + 12;
+ await page.mouse.move(x, y);
+ await page.mouse.down();
+ for (let move = 1; move <= MOVES; move++) {
+ await page.mouse.move(x + move * STEP_PX, y + move * (STEP_PX / 2));
+ await page.waitForTimeout(DRAG_MS / MOVES);
+ }
+ await page.mouse.up();
+ },
+ };
+ },
+};
diff --git a/autogpt_platform/frontend/scripts/perf/scenarios/copilot-background-stream.ts b/autogpt_platform/frontend/scripts/perf/scenarios/copilot-background-stream.ts
new file mode 100644
index 0000000000..d42edf8389
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/scenarios/copilot-background-stream.ts
@@ -0,0 +1,37 @@
+import { openLongSession, sendMessage } from "../lib/copilot-page";
+import { noInteraction, type Scenario } from "../lib/scenario";
+
+/** Slow enough that the reply is still streaming for the whole window. */
+const BACKGROUND_PACE_MS = 200;
+const READY_TIMEOUT_MS = 30_000;
+/** Home's entrance animations finish well inside this. */
+const SETTLE_MS = 3_000;
+
+export const copilotBackgroundStream: Scenario = {
+ name: "copilot-background-stream",
+ description:
+ "Start a reply in the 200-message chat, go to Home, and sit there while it keeps streaming.",
+ readyWhen:
+ "the first words of the reply are on screen, then the Home link is clicked, the chat is gone from the URL and Home's composer is visible, then 3 s for its entrance animations",
+ windowMs: 15_000,
+ async setup(ctx) {
+ const { copilot } = await openLongSession({
+ ctx,
+ paceMs: BACKGROUND_PACE_MS,
+ });
+ await sendMessage(copilot, "go");
+ await ctx.page
+ .getByText("Sure. Here is")
+ .waitFor({ state: "visible", timeout: READY_TIMEOUT_MS });
+ await ctx.page.getByRole("link", { name: "Home", exact: true }).click();
+ await ctx.page.waitForURL((url) => !url.searchParams.has("sessionId"), {
+ timeout: READY_TIMEOUT_MS,
+ });
+ await ctx.page
+ .getByRole("textbox")
+ .first()
+ .waitFor({ state: "visible", timeout: READY_TIMEOUT_MS });
+ await ctx.page.waitForTimeout(SETTLE_MS);
+ return noInteraction;
+ },
+};
diff --git a/autogpt_platform/frontend/scripts/perf/scenarios/copilot-idle.ts b/autogpt_platform/frontend/scripts/perf/scenarios/copilot-idle.ts
new file mode 100644
index 0000000000..0f8c542685
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/scenarios/copilot-idle.ts
@@ -0,0 +1,14 @@
+import { openLongSession } from "../lib/copilot-page";
+import { noInteraction, type Scenario } from "../lib/scenario";
+
+export const copilotIdle: Scenario = {
+ name: "copilot-idle",
+ description: "A 200-message chat sitting open with nothing happening.",
+ readyWhen:
+ "the newest user message and the composer are visible, then network idle + 1 s",
+ windowMs: 20_000,
+ async setup(ctx) {
+ await openLongSession({ ctx });
+ return noInteraction;
+ },
+};
diff --git a/autogpt_platform/frontend/scripts/perf/scenarios/copilot-stream-reply.ts b/autogpt_platform/frontend/scripts/perf/scenarios/copilot-stream-reply.ts
new file mode 100644
index 0000000000..a9a6b9f0d1
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/scenarios/copilot-stream-reply.ts
@@ -0,0 +1,20 @@
+import { openLongSession, sendMessage } from "../lib/copilot-page";
+import type { Scenario } from "../lib/scenario";
+
+export const copilotStreamReply: Scenario = {
+ name: "copilot-stream-reply",
+ description:
+ 'Send "go" in a 200-message chat and stream the 20-line fixture reply at ~33 chunks/s.',
+ readyWhen:
+ "the newest user message and the composer are visible, then network idle + 1 s",
+ windowMs: 1_000,
+ async setup(ctx) {
+ const { fixture, copilot } = await openLongSession({ ctx });
+ return {
+ async run() {
+ await sendMessage(copilot, "go");
+ await fixture.waitForTurn(1);
+ },
+ };
+ },
+};
diff --git a/autogpt_platform/frontend/scripts/perf/scenarios/copilot-switch-threads.ts b/autogpt_platform/frontend/scripts/perf/scenarios/copilot-switch-threads.ts
new file mode 100644
index 0000000000..30dfdda912
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/scenarios/copilot-switch-threads.ts
@@ -0,0 +1,42 @@
+import { COPILOT_SESSIONS } from "../lib/copilot-fixture";
+import { openLongSession } from "../lib/copilot-page";
+import { settle, type Scenario } from "../lib/scenario";
+
+const ROUNDS = 3;
+const DWELL_MS = 2_000;
+const READY_TIMEOUT_MS = 15_000;
+
+export const copilotSwitchThreads: Scenario = {
+ name: "copilot-switch-threads",
+ description:
+ "Switch between chats of 200, 50 and 10 messages from the sidebar, three rounds, 2 s on each.",
+ readyWhen:
+ "the 200-message chat is open and all three chats are listed in the expanded sidebar, then network idle + 1 s",
+ windowMs: 0,
+ async setup(ctx) {
+ const { page } = ctx;
+ await openLongSession({ ctx });
+ const expand = page.getByRole("button", { name: "Expand sidebar" });
+ if (await expand.isVisible()) await expand.click();
+ const loadAll = page.getByRole("button", { name: "Load all Otto chats" });
+ if (await loadAll.isVisible()) await loadAll.click();
+ const links = COPILOT_SESSIONS.map((session) =>
+ page.getByRole("link", { name: session.title, exact: true }),
+ );
+ for (const link of links) {
+ await link.waitFor({ state: "visible", timeout: READY_TIMEOUT_MS });
+ }
+ await settle(page);
+ const [long, medium, short] = links;
+ return {
+ async run() {
+ for (let round = 0; round < ROUNDS; round++) {
+ for (const link of [medium, short, long]) {
+ await link.click();
+ await page.waitForTimeout(DWELL_MS);
+ }
+ }
+ },
+ };
+ },
+};
diff --git a/autogpt_platform/frontend/scripts/perf/scenarios/copilot-type.ts b/autogpt_platform/frontend/scripts/perf/scenarios/copilot-type.ts
new file mode 100644
index 0000000000..d154996488
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/scenarios/copilot-type.ts
@@ -0,0 +1,23 @@
+import { openLongSession } from "../lib/copilot-page";
+import type { Scenario } from "../lib/scenario";
+
+const TEXT = "check the last week";
+const KEY_DELAY_MS = 50;
+
+export const copilotType: Scenario = {
+ name: "copilot-type",
+ description: `Type ${TEXT.length} characters into the composer of a 200-message chat, ${KEY_DELAY_MS} ms apart.`,
+ readyWhen:
+ "the newest user message and the composer are visible and focused, then network idle + 1 s",
+ windowMs: 2_000,
+ async setup(ctx) {
+ const { copilot } = await openLongSession({ ctx });
+ const input = copilot.getChatInput();
+ await input.click();
+ return {
+ async run() {
+ await input.pressSequentially(TEXT, { delay: KEY_DELAY_MS });
+ },
+ };
+ },
+};
diff --git a/autogpt_platform/frontend/scripts/perf/scenarios/library-running.ts b/autogpt_platform/frontend/scripts/perf/scenarios/library-running.ts
new file mode 100644
index 0000000000..87b59cf092
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/scenarios/library-running.ts
@@ -0,0 +1,24 @@
+import { createLibraryFixture } from "../lib/library-fixture";
+import { installRoutes } from "../lib/routes";
+import { noInteraction, settle, type Scenario } from "../lib/scenario";
+
+const READY_TIMEOUT_MS = 60_000;
+
+export const libraryRunning: Scenario = {
+ name: "library-running",
+ description: "The library with 20 workflows, all of them RUNNING.",
+ readyWhen: "the 20th workflow is listed, then network idle + 1 s",
+ windowMs: 30_000,
+ async setup(ctx) {
+ const { page } = ctx;
+ const fixture = createLibraryFixture(ctx.userID);
+ await installRoutes(page, fixture.handlers);
+ await page.goto("/library");
+ await page
+ .getByText(fixture.agents[fixture.agents.length - 1].name)
+ .first()
+ .waitFor({ state: "visible", timeout: READY_TIMEOUT_MS });
+ await settle(page);
+ return noInteraction;
+ },
+};
diff --git a/autogpt_platform/frontend/scripts/perf/scenarios/registry.ts b/autogpt_platform/frontend/scripts/perf/scenarios/registry.ts
new file mode 100644
index 0000000000..20b8b6063d
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/scenarios/registry.ts
@@ -0,0 +1,27 @@
+import type { Scenario } from "../lib/scenario";
+import { builderDragRunning } from "./builder-drag-running";
+import { copilotBackgroundStream } from "./copilot-background-stream";
+import { copilotIdle } from "./copilot-idle";
+import { copilotStreamReply } from "./copilot-stream-reply";
+import { copilotSwitchThreads } from "./copilot-switch-threads";
+import { copilotType } from "./copilot-type";
+import { libraryRunning } from "./library-running";
+
+export const SCENARIOS: Scenario[] = [
+ copilotIdle,
+ copilotStreamReply,
+ copilotBackgroundStream,
+ copilotType,
+ copilotSwitchThreads,
+ builderDragRunning,
+ libraryRunning,
+];
+
+export function findScenario(name: string) {
+ const scenario = SCENARIOS.find((candidate) => candidate.name === name);
+ if (!scenario) {
+ const names = SCENARIOS.map((candidate) => candidate.name).join(", ");
+ throw new Error(`Unknown scenario "${name}". Available: ${names}`);
+ }
+ return scenario;
+}
diff --git a/autogpt_platform/frontend/src/app/layout.tsx b/autogpt_platform/frontend/src/app/layout.tsx
index cafcb31135..e652cc1f41 100644
--- a/autogpt_platform/frontend/src/app/layout.tsx
+++ b/autogpt_platform/frontend/src/app/layout.tsx
@@ -74,6 +74,12 @@ export default async function RootLayout({
suppressHydrationWarning
>
<body className="min-h-screen">
+ {process.env.NEXT_PUBLIC_RENDER_COUNTER === "1" ? (
+ <Script
+ src="/devtools/render-counter.js"
+ strategy="beforeInteractive"
+ />
+ ) : null}
{/* Without a Cookiebot domain group there is no banner and every
optional category stays denied. With one, the Consent Mode
defaults are queued before anything else can reach the Google
diff --git a/autogpt_platform/frontend/vitest.config.mts b/autogpt_platform/frontend/vitest.config.mts
index 2dbb925374..672ee8ac9b 100644
--- a/autogpt_platform/frontend/vitest.config.mts
+++ b/autogpt_platform/frontend/vitest.config.mts
@@ -6,7 +6,12 @@ export default defineConfig({
plugins: [tsconfigPaths(), react()],
test: {
environment: "happy-dom",
- include: ["src/**/*.test.tsx", "src/**/*.test.ts", "scripts/**/*.test.ts"],
+ include: [
+ "src/**/*.test.tsx",
+ "src/**/*.test.ts",
+ "scripts/**/*.test.ts",
+ "scripts/**/*.test.tsx",
+ ],
setupFiles: ["./src/tests/integrations/vitest.setup.tsx"],
coverage: {
provider: "v8",
diff --git a/docs/engineering/frontend-perf-baseline.md b/docs/engineering/frontend-perf-baseline.md
new file mode 100644
index 0000000000..dc8c12966e
--- /dev/null
+++ b/docs/engineering/frontend-perf-baseline.md
@@ -0,0 +1,343 @@
+# Frontend performance baseline
+
+Medians of `pnpm perf` for every scenario on `dev`, saved so later work has something to compare against. How to produce and read these tables: [frontend-perf-measurement.md](frontend-perf-measurement.md).
+
+| | |
+| --- | --- |
+| App code | `dev` at `03dfdcabf` (2026-10-19). Measured on the branch that added the tooling, which changes no app behaviour. |
+| Build | `NEXT_PUBLIC_RENDER_COUNTER=1 pnpm dev` (Next 15.5 with Turbopack, React 18.3 development build) |
+| Browser | Playwright Chromium headless shell 141, 1440 × 900, `en-US`, UTC |
+| Machine | Linux cloud sandbox, 8 vCPU Intel Xeon 2.9 GHz, 16 GB RAM, Node 24 |
+| Runs | 1 warm-up, then 3 saved runs per scenario (`--label baseline`) |
+
+Absolute timings depend on the machine, so compare a branch against these numbers only on similar hardware. To compare against your own machine, run the same scenarios on `dev` first with `--label baseline`. Render counts and commits do not depend on the machine.
+
+What stands out:
+
+- **Streaming a reply re-renders the whole conversation.** In `copilot-stream-reply`, one reply costs about 210,000 renders and 5.7 s of script time over about 55 commits. The biggest commits render more than 11,000 components: the 200 existing rows, mostly their tooltips, icons and Radix wrappers. Most of the cost comes after the stream ends, when the page refetches the session and re-renders the transcript several times. `copilot-idle` shows the same chat at rest: about 40 renders per commit.
+- **The end of a turn is not fully deterministic.** One run in three to five does one fewer full-transcript re-render (about 11,000 renders, 5%), whatever the run's timing. The median absorbs it; use `--runs 5` when a change to this scenario is close to that size.
+- **Switching threads is the most expensive scenario:** about 270,000 renders and 11.7 s of script time over nine switches.
+- **Dragging a node during a running execution** renders about 500 components per pointer move, with 39 long tasks in 2 s.
+- **The library with 20 running workflows** and **Home with a reply streaming in the background** are quiet.
+
+## builder-drag-running · baseline — median of 3 runs
+
+| metric | median | range | spread |
+| --- | --- | --- | --- |
+| commits | 251 | 249 – 258 | 3.6% |
+| total renders | 128,816 | 128,768 – 128,857 | 0.1% |
+| renders per commit | 513.2 | 499.4 – 517.1 | 3.4% |
+| max renders in one commit | 11,029 | 11,029 – 11,029 | 0.0% |
+| script time (ms) | 5,327 | 5,254 – 5,354 | 1.9% |
+| task time (ms) | 6,811 | 6,676 – 6,838 | 2.4% |
+| layout time (ms) | 37 | 37 – 38 | 3.3% |
+| style recalc time (ms) | 112 | 112 – 115 | 2.8% |
+| long tasks (≥ 50 ms) | 39 | 38 – 47 | 23.1% |
+| long task total (ms) | 5,319 | 5,220 – 5,567 | 6.5% |
+| heap used after GC (MB) | 103.5 | 103.4 – 103.6 | 0.2% |
+
+**Top components (median renders)**
+
+| name | renders |
+| --- | --- |
+| `Presence` | 6,501 |
+| `Text` | 6,150 |
+| `HugeiconsIcon` | 5,560 |
+| `Icon` | 5,560 |
+| `Tooltip` | 5,023 |
+| `TooltipContent` | 5,021 |
+| `TooltipProvider` | 4,949 |
+| `Primitive.div` | 4,275 |
+| `Popper` | 3,608 |
+| `PopperAnchor` | 3,608 |
+
+**Top render causes (median renders)**
+
+| name | renders |
+| --- | --- |
+| `Presence props:children` | 6,501 |
+| `HugeiconsIcon parent-same-props<-Icon` | 5,560 |
+| `Tooltip props:children` | 5,023 |
+| `TooltipProvider props:children` | 4,949 |
+| `Primitive.div props:children` | 3,489 |
+| `Primitive.div.Slot props:children` | 3,096 |
+| `Primitive.div.SlotClone props:children` | 3,096 |
+| `TooltipContent props:children` | 2,876 |
+| `Primitive.button.Slot props:children,onPointerMove,onPointerLeave,onPointerDown,+4` | 2,654 |
+| `Primitive.button.SlotClone props:onPointerMove,onPointerLeave,onPointerDown,onFocus,+4` | 2,654 |
+
+## copilot-background-stream · baseline — median of 3 runs
+
+| metric | median | range | spread |
+| --- | --- | --- | --- |
+| commits | 6 | 6 – 6 | 0.0% |
+| total renders | 443 | 443 – 443 | 0.0% |
+| renders per commit | 73.8 | 73.8 – 73.8 | 0.0% |
+| max renders in one commit | 275 | 275 – 275 | 0.0% |
+| script time (ms) | 62 | 53 – 71 | 30.1% |
+| task time (ms) | 230 | 229 – 294 | 28.3% |
+| layout time (ms) | 0 | 0 – 0 | 0.0% |
+| style recalc time (ms) | 0 | 0 – 0 | 0.0% |
+| long tasks (≥ 50 ms) | 1 | 1 – 1 | 0.0% |
+| long task total (ms) | 73 | 65 – 81 | 21.5% |
+| heap used after GC (MB) | 56.0 | 55.9 – 56.3 | 0.7% |
+
+**Top components (median renders)**
+
+| name | renders |
+| --- | --- |
+| `Text` | 35 |
+| `motion.div` | 21 |
+| `Card` | 18 |
+| `motion.g` | 18 |
+| `Presence` | 18 |
+| `HugeiconsIcon` | 15 |
+| `Icon` | 15 |
+| `Primitive.div` | 13 |
+| `Primitive.button` | 12 |
+| `Popper` | 11 |
+
+**Top render causes (median renders)**
+
+| name | renders |
+| --- | --- |
+| `motion.div props:initial,animate,transition,children` | 21 |
+| `Card parent-same-props<-motion.g` | 18 |
+| `motion.g props:initial,animate,transition,children` | 18 |
+| `Presence props:children` | 18 |
+| `HugeiconsIcon parent-same-props<-Icon` | 15 |
+| `Primitive.div props:children` | 12 |
+| `Text parent-same-props<-motion.div` | 12 |
+| `Primitive.div.Slot props:children` | 11 |
+| `Primitive.div.SlotClone props:children` | 11 |
+| `Tooltip props:children` | 10 |
+
+## copilot-idle · baseline — median of 3 runs
+
+| metric | median | range | spread |
+| --- | --- | --- | --- |
+| commits | 5 | 5 – 5 | 0.0% |
+| total renders | 201 | 201 – 201 | 0.0% |
+| renders per commit | 40.2 | 40.2 – 40.2 | 0.0% |
+| max renders in one commit | 100 | 100 – 100 | 0.0% |
+| script time (ms) | 22 | 21 – 22 | 4.1% |
+| task time (ms) | 52 | 49 – 52 | 5.4% |
+| layout time (ms) | 0 | 0 – 0 | 0.0% |
+| style recalc time (ms) | 0 | 0 – 0 | 0.0% |
+| long tasks (≥ 50 ms) | 0 | 0 – 0 | 0.0% |
+| long task total (ms) | 0 | 0 – 0 | 0.0% |
+| heap used after GC (MB) | 83.7 | 83.6 – 84.8 | 1.4% |
+
+**Top components (median renders)**
+
+| name | renders |
+| --- | --- |
+| `Presence` | 12 |
+| `Primitive.div` | 10 |
+| `Primitive.button` | 8 |
+| `Anonymous` | 6 |
+| `HugeiconsIcon` | 6 |
+| `Icon` | 6 |
+| `Popper` | 6 |
+| `PopperAnchor` | 6 |
+| `PopperProvider` | 6 |
+| `Primitive.button.Slot` | 6 |
+
+**Top render causes (median renders)**
+
+| name | renders |
+| --- | --- |
+| `Presence props:children` | 12 |
+| `Primitive.div props:children` | 8 |
+| `HugeiconsIcon parent-same-props<-Icon` | 6 |
+| `Primitive.div.Slot props:children` | 6 |
+| `Primitive.div.SlotClone props:children` | 6 |
+| `Tooltip props:children` | 6 |
+| `LinkComponent props:children,onPointerMove,onPointerLeave,onPointerDown,+4` | 4 |
+| `MenuProvider props:scope,children` | 4 |
+| `Popper props:children` | 4 |
+| `PopperAnchor props:children` | 4 |
+
+## copilot-stream-reply · baseline — median of 3 runs
+
+| metric | median | range | spread |
+| --- | --- | --- | --- |
+| commits | 53 | 52 – 55 | 5.7% |
+| total renders | 209,396 | 198,389 – 209,496 | 5.3% |
+| renders per commit | 3,815.2 | 3,809.0 – 3,950.9 | 3.7% |
+| max renders in one commit | 11,149 | 11,149 – 11,149 | 0.0% |
+| script time (ms) | 5,709 | 5,396 – 5,760 | 6.4% |
+| task time (ms) | 6,158 | 5,842 – 6,252 | 6.7% |
+| layout time (ms) | 20 | 19 – 24 | 22.8% |
+| style recalc time (ms) | 186 | 185 – 202 | 9.5% |
+| long tasks (≥ 50 ms) | 18 | 17 – 18 | 5.6% |
+| long task total (ms) | 5,867 | 5,549 – 5,931 | 6.5% |
+| heap used after GC (MB) | 86.4 | 85.9 – 86.6 | 0.9% |
+
+**Top components (median renders)**
+
+| name | renders |
+| --- | --- |
+| `Tooltip` | 16,230 |
+| `TooltipContent` | 16,228 |
+| `HugeiconsIcon` | 9,061 |
+| `Icon` | 9,061 |
+| `Presence` | 8,299 |
+| `Primitive.div` | 8,196 |
+| `Popper` | 8,194 |
+| `PopperAnchor` | 8,194 |
+| `PopperProvider` | 8,194 |
+| `Primitive.div.Slot` | 8,194 |
+
+**Top render causes (median renders)**
+
+| name | renders |
+| --- | --- |
+| `Tooltip props:children` | 16,183 |
+| `HugeiconsIcon parent-same-props<-Icon` | 9,054 |
+| `Presence props:children` | 8,293 |
+| `Primitive.div props:children` | 8,188 |
+| `Primitive.div.Slot props:children` | 8,187 |
+| `Primitive.div.SlotClone props:children` | 8,187 |
+| `PopperAnchor props:children` | 8,169 |
+| `Popper props:children` | 8,164 |
+| `PopperProvider props:children` | 8,164 |
+| `TooltipProvider props:children` | 8,141 |
+
+## copilot-switch-threads · baseline — median of 3 runs
+
+| metric | median | range | spread |
+| --- | --- | --- | --- |
+| commits | 288 | 286 – 310 | 8.3% |
+| total renders | 269,370 | 261,379 – 295,570 | 12.7% |
+| renders per commit | 935.3 | 913.9 – 953.5 | 4.2% |
+| max renders in one commit | 13,364 | 13,364 – 13,364 | 0.0% |
+| script time (ms) | 11,714 | 11,169 – 11,978 | 6.9% |
+| task time (ms) | 13,451 | 12,973 – 13,686 | 5.3% |
+| layout time (ms) | 143 | 140 – 148 | 5.8% |
+| style recalc time (ms) | 376 | 355 – 381 | 6.8% |
+| long tasks (≥ 50 ms) | 26 | 23 – 27 | 15.4% |
+| long task total (ms) | 9,939 | 9,240 – 10,108 | 8.7% |
+| heap used after GC (MB) | 90.4 | 90.4 – 92.6 | 2.4% |
+
+**Top components (median renders)**
+
+| name | renders |
+| --- | --- |
+| `Tooltip` | 19,082 |
+| `TooltipContent` | 19,024 |
+| `HugeiconsIcon` | 10,827 |
+| `Icon` | 10,827 |
+| `Presence` | 10,554 |
+| `Primitive.div` | 10,049 |
+| `Popper` | 9,955 |
+| `PopperAnchor` | 9,955 |
+| `PopperProvider` | 9,955 |
+| `Primitive.div.Slot` | 9,955 |
+
+**Top render causes (median renders)**
+
+| name | renders |
+| --- | --- |
+| `Tooltip props:children` | 13,934 |
+| `HugeiconsIcon parent-same-props<-Icon` | 8,920 |
+| `Presence props:children` | 8,763 |
+| `Primitive.div props:children` | 8,265 |
+| `Primitive.div.Slot props:children` | 8,218 |
+| `Primitive.div.SlotClone props:children` | 8,218 |
+| `PopperAnchor props:children` | 8,095 |
+| `Primitive.button props:children,ref,onPointerMove,onPointerLeave,+4` | 7,962 |
+| `Primitive.button.Slot props:children,onPointerMove,onPointerLeave,onPointerDown,+4` | 7,962 |
+| `Primitive.button.SlotClone props:onPointerMove,onPointerLeave,onPointerDown,onFocus,+4` | 7,962 |
+
+## copilot-type · baseline — median of 3 runs
+
+| metric | median | range | spread |
+| --- | --- | --- | --- |
+| commits | 38 | 38 – 38 | 0.0% |
+| total renders | 2,869 | 2,869 – 2,869 | 0.0% |
+| renders per commit | 75.5 | 75.5 – 75.5 | 0.0% |
+| max renders in one commit | 151 | 151 – 151 | 0.0% |
+| script time (ms) | 302 | 298 – 331 | 11.0% |
+| task time (ms) | 490 | 488 – 523 | 7.2% |
+| layout time (ms) | 34 | 32 – 34 | 5.4% |
+| style recalc time (ms) | 27 | 26 – 28 | 7.0% |
+| long tasks (≥ 50 ms) | 0 | 0 – 0 | 0.0% |
+| long task total (ms) | 0 | 0 – 0 | 0.0% |
+| heap used after GC (MB) | 85.3 | 84.3 – 85.4 | 1.3% |
+
+**Top components (median renders)**
+
+| name | renders |
+| --- | --- |
+| `Presence` | 171 |
+| `Popper` | 133 |
+| `PopperAnchor` | 133 |
+| `PopperProvider` | 133 |
+| `Primitive.div` | 133 |
+| `Primitive.div.Slot` | 133 |
+| `Primitive.div.SlotClone` | 133 |
+| `Tooltip` | 114 |
+| `TooltipContent` | 114 |
+| `Primitive.button` | 95 |
+
+**Top render causes (median renders)**
+
+| name | renders |
+| --- | --- |
+| `Presence props:children` | 171 |
+| `Primitive.div props:children` | 133 |
+| `Primitive.div.Slot props:children` | 133 |
+| `Primitive.div.SlotClone props:children` | 133 |
+| `Popper props:children` | 114 |
+| `PopperAnchor props:children` | 114 |
+| `PopperProvider props:children` | 114 |
+| `Tooltip props:children` | 114 |
+| `HugeiconsIcon parent-same-props<-Icon` | 76 |
+| `Icon parent-same-props<-Primitive.button.SlotClone` | 57 |
+
+## library-running · baseline — median of 3 runs
+
+| metric | median | range | spread |
+| --- | --- | --- | --- |
+| commits | 30 | 30 – 30 | 0.0% |
+| total renders | 516 | 516 – 516 | 0.0% |
+| renders per commit | 17.2 | 17.2 – 17.2 | 0.0% |
+| max renders in one commit | 100 | 100 – 100 | 0.0% |
+| script time (ms) | 69 | 64 – 75 | 14.9% |
+| task time (ms) | 496 | 496 – 575 | 16.0% |
+| layout time (ms) | 0 | 0 – 0 | 0.0% |
+| style recalc time (ms) | 91 | 91 – 91 | 0.3% |
+| long tasks (≥ 50 ms) | 0 | 0 – 0 | 0.0% |
+| long task total (ms) | 0 | 0 – 0 | 0.0% |
+| heap used after GC (MB) | 47.1 | 47.0 – 47.2 | 0.6% |
+
+**Top components (median renders)**
+
+| name | renders |
+| --- | --- |
+| `u0` | 60 |
+| `Presence` | 20 |
+| `on` | 18 |
+| `oo` | 18 |
+| `Primitive.div` | 15 |
+| `da` | 12 |
+| `em` | 12 |
+| `oC` | 12 |
+| `Primitive.button` | 12 |
+| `r$` | 12 |
+
+**Top render causes (median renders)**
+
+| name | renders |
+| --- | --- |
+| `u0 context` | 60 |
+| `Presence props:children` | 20 |
+| `da state#0` | 12 |
+| `em props:children` | 12 |
+| `oC parent-same-props<-r$` | 12 |
+| `on context` | 12 |
+| `oo props:isDevBuilding` | 12 |
+| `Primitive.div props:children` | 12 |
+| `r$ props:state,children` | 12 |
+| `rV props:state,children` | 12 |
diff --git a/docs/engineering/frontend-perf-measurement.md b/docs/engineering/frontend-perf-measurement.md
new file mode 100644
index 0000000000..cb415e689f
--- /dev/null
+++ b/docs/engineering/frontend-perf-measurement.md
@@ -0,0 +1,182 @@
+# Frontend performance measurement
+
+How to show that a frontend change made the app faster or slower: run a fixed scenario before and after the change and compare the medians. The tooling lives in `autogpt_platform/frontend` and only ever runs on a developer machine. It is not part of CI, and nothing it adds reaches a production bundle.
+
+Saved baseline tables for the current scenarios: [frontend-perf-baseline.md](frontend-perf-baseline.md).
+
+## The three numbers
+
+- **Re-renders.** React draws the screen from small components (a chat row, a button, a sidebar entry). When data changes, React redraws the affected components; each redraw is a *render*, and one batch of them is a *commit*. Code often redraws far more than it needs to, for example every row of a 200-message chat when only the streaming row changed. Every wasted render costs CPU time.
+- **JS CPU.** The milliseconds the browser's main thread spends running our JavaScript. The main thread also handles clicks, layout and painting, so 80 ms of our code in one go freezes the page for 80 ms. A task of 50 ms or more is a *long task*, which is what people feel as jank: stuttering, typing lag, jerky scrolling.
+- **JS heap.** The memory our JavaScript holds after garbage collection. A heap that grows and never shrinks slows the tab down and eventually crashes it. It grows when code keeps references it no longer needs, such as a finished chat session that is never dropped.
+
+They are one problem seen from three sides: wasted renders burn CPU, CPU burns the 16 ms frame budget, and leftover renders hold memory.
+
+## What is there
+
+| Piece | Where | What it does |
+| --- | --- | --- |
+| Render counter | `public/devtools/render-counter.js` | Hooks into React and, after every commit, records which components rendered and why. Loaded only when `NEXT_PUBLIC_RENDER_COUNTER=1`. |
+| Measurement script | `scripts/perf/measure.ts` (`pnpm perf`) | Opens the app in Chromium, runs one scenario, and reads the counter plus Chrome DevTools Protocol metrics. Writes one JSON per run. |
+| Compare script | `scripts/perf/compare.ts` (`pnpm perf:compare`) | Prints the medians of two labelled sets side by side as markdown. |
+| Scenarios | `scripts/perf/scenarios/*.ts` | One file per scenario: setup, the measured interaction, and the window length. |
+| Fixtures | `scripts/perf/fixtures/`, `scripts/perf/lib/*-fixture.ts` | Recorded or generated API responses served with `page.route`, so every run sees the same data and the same streamed reply. |
+| Intercepted URLs | `scripts/perf/lib/routes.ts` | The one list of URLs the harness answers itself. Everything else goes to the real dev server and backend. |
+
+## Run one scenario
+
+1. Start the backend as usual (Postgres for Better Auth, plus `rest_server` and `websocket_server`). Copilot, builder and library data come from fixtures, so the executors, ClamAV and the LLM are not needed. On a 16 GB machine, stop `clamav`, `executor`, `copilot_executor`, `scheduler_server` and `notification_server`: the dev server needs about 5 GB and gets killed for memory otherwise.
+2. Start the frontend with the counter. `NEXT_PUBLIC_*` values are read when the dev server starts, so restart it after changing the flag:
+
+ ```bash
+ cd autogpt_platform/frontend
+ NEXT_PUBLIC_RENDER_COUNTER=1 pnpm dev
+ ```
+
+3. Install Playwright's Chromium once (`npx playwright install chromium`), or pass `--channel chrome` to use an installed Chrome.
+4. In another terminal:
+
+ ```bash
+ pnpm perf --list # scenarios
+ pnpm perf --scenario copilot-stream-reply --label before # 1 warm-up + 3 runs
+ ```
+
+Each run prints a table and saves `.perf/<scenario>/<label>-<timestamp>-<run>.json` (`.perf/` is gitignored). When there is more than one run, the script also prints the median, range and spread of each metric.
+
+| Flag | Default | Meaning |
+| --- | --- | --- |
+| `--scenario <name>` | required | Which scenario to run. |
+| `--label <text>` | `any` | Name of the set, e.g. `before`, `after`, `baseline`. Letters, digits, `.`, `_`, `-`. |
+| `--runs <n>` | `3` | Saved runs. |
+| `--warmup <n>` | `1` | Unsaved runs first, so a dev-server compile or a cold cache after a restart or a code edit does not land in a saved run. |
+| `--base-url <url>` | `http://localhost:3000` | Frontend to measure. |
+| `--profile` | off | Also save a `.cpuprofile` for each run. Open it in Chrome DevTools → Performance → Load profile. |
+| `--screenshot` | off | Save a PNG of the page at the end of each window, to check the scenario did what it says. |
+| `--headed` | off | Show the browser. |
+| `--channel <name>` | Playwright Chromium | Browser channel, e.g. `chrome`. Also `PERF_BROWSER_CHANNEL`. |
+| `--storage-state <file>` | none | Reuse a signed-in Playwright state, e.g. `.auth/states/smokeLibrary.json` from the e2e global setup. |
+
+Without `--storage-state`, the script signs in through Better Auth as `[email protected]` and creates that account the first time. Set `PERF_USER_EMAIL` and `PERF_USER_PASSWORD` to use another account. It also marks onboarding and the first-visit tab intros as done, so no welcome card covers the page being measured.
+
+If `window.__renderCounter` is missing, the script stops and tells you to restart the dev server with the flag.
+
+## Before and after
+
+1. Check out the commit **before** the change and run the scenario the change targets with `--label before`.
+2. Check out the commit **with** the change and run it with `--label after`.
+3. Compare, and paste the output in the PR description:
+
+ ```bash
+ pnpm perf:compare --a before --b after --scenario copilot-stream-reply
+ ```
+
+Leave out `--scenario` to compare every scenario that has runs under both labels.
+
+The output has three tables (metrics, top components and top render causes), each with `before`, `after` and `Δ` columns, followed by the raw runs in a collapsed block. Every value is the median of the runs, not the average.
+
+Tips for numbers you can trust:
+
+- Compare on the same machine and the same build type. Dev React is slower than production React, but a before/after delta on the same build type is still valid.
+- Alternate the two checkouts when you can (before, after, before, after) so a machine that slows down over time does not favour one side.
+- Keep the rest of the setup equal on both sides. `.env.default` turns on the React Query devtools and the token devtool, and they render too, so leave them as they are or change them for both runs.
+- Read total renders and the per-component counts first: they are deterministic, and on the baseline most scenarios repeat them exactly from run to run. The exception is the end of a copilot turn, which now and then does one full-transcript re-render fewer (see the baseline). Commits, and so renders per commit, depend on how React batches updates into frames, so they can shift once a change makes rendering cheaper. Timing metrics move by a few percent. Treat any change smaller than the spread the script prints as noise.
+
+## Reading the causes column
+
+Each render is attributed to one cause, checked in this order:
+
+| Cause | Meaning | Where to look |
+| --- | --- | --- |
+| `mount` | The component appeared this commit. | Expected on navigation; suspicious if it repeats while nothing appears (a changing `key`, or a parent that unmounts and remounts it). |
+| `state#N` | Its own `useState`/`useReducer` (or a store read through `useSyncExternalStore`, such as zustand or React Query) changed. `N` is the hook's position in the component, counting every hook. | The Nth hook call in the component. |
+| `props:a,b` | Its parent passed different values for these props (up to four, then `+N`). | Usually a new object, array or function created on every parent render, or an over-broad prop. |
+| `parent-same-props<-Parent` | `Parent` re-rendered and passed props with identical values, but the component is not memoised. | Wrapping in `memo`, or moving state down so `Parent` stops re-rendering. |
+| `context` | Nothing above changed, so a context it reads did. | A provider whose `value` is a new object every render, or a context that carries too much. |
+
+A long run of `props:children` usually means the parent rebuilds its JSX every commit. Look for the first component in the list that is not a design-system wrapper (Radix `Presence`, `Popper` and `Slot` mostly pass through what they are given).
+
+Names come from the component function. Third-party code bundled already minified shows short names such as `u0`; it still counts, but the name does not help.
+
+## Scenarios
+
+| Name | Setup | Measured | Window |
+| --- | --- | --- | --- |
+| `copilot-idle` | Open the 200-message chat | Nothing | 20 s |
+| `copilot-stream-reply` | Open the 200-message chat | Type "go", press Enter, stream the 20-line fixture reply at about 33 chunks a second | Until the reply has been sent and the page has refetched the session, + 1 s |
+| `copilot-background-stream` | Start the same reply slowly (200 ms a chunk) in the 200-message chat, click Home, and wait 3 s for Home's entrance animations | Nothing | 15 s |
+| `copilot-type` | Open the 200-message chat and focus the composer | Type 19 characters, 50 ms apart | 2 s after the last key |
+| `copilot-switch-threads` | Open the 200-message chat and list the 200 / 50 / 10-message chats in the sidebar | Click 50 → 10 → 200, three rounds, 2 s on each | Until done |
+| `builder-drag-running` | Open a 50-node workflow whose run is RUNNING (the page polls it every second) | Drag one node for 2 s with 60 pointer moves | 2 s |
+| `library-running` | Open the library with 20 workflows, all with a RUNNING run | Nothing | 30 s |
+
+Each scenario's `readyWhen` field says exactly what setup waits for before the window opens. Most wait for the page's own content, then for network idle (at most 15 s, because some pages poll), then one more second.
+
+Each run uses a fresh browser context at 1440 × 900, with the `en-US` locale and UTC time. Feature flags are pinned to their code defaults (`/api/feature-flags` answers `{flags: {}, configured: false}`), so a PostHog setup on one machine does not change what renders.
+
+## What a run measures
+
+1. Sign in, open the page, set up the scenario (`scenario.setup`).
+2. Reset the counter, start a Chrome trace (`devtools.timeline`), optionally start the CPU profiler, read `Performance.getMetrics`, start the counter.
+3. Run the interaction, then wait `windowMs`.
+4. Stop the counter, read `Performance.getMetrics` again, stop the trace and the profiler.
+5. Force a garbage collection (`HeapProfiler.collectGarbage`), wait 500 ms and read `JSHeapUsedSize`.
+
+| Metric | Source |
+| --- | --- |
+| commits, total renders, renders per commit, max renders in one commit | render counter |
+| top components, top render causes | render counter (the JSON keeps the top 50) |
+| script, task, layout and style recalc time (ms) | `Performance.getMetrics` after minus before |
+| long tasks (count and total ms) | trace `RunTask` events of 50 ms or more on the page's renderer main thread |
+| heap used after GC (MB) | `JSHeapUsedSize` after a forced GC |
+
+## Using the render counter by hand
+
+With the dev server started with the flag, open the browser console on any page:
+
+```js
+__renderCounter.reset();
+// …click around…
+__renderCounter.print(); // console.table of the top components and causes
+__renderCounter.report(); // { commits, totalRenders, rendersPerCommit, maxRendersPerCommit, components, causes }
+```
+
+`stop()` and `start()` pause and resume recording. It records from page load until you call `stop()`.
+
+How it works: React reports every commit to `window.__REACT_DEVTOOLS_GLOBAL_HOOK__` if that object exists before React loads, which is why the script is loaded with `strategy="beforeInteractive"`. The script wraps an existing hook (the React DevTools extension, or Fast Refresh in dev) or installs a minimal one. On each commit it walks the fiber tree and counts function, class, `forwardRef` and simple `memo` components whose `PerformedWork` flag is set. It skips subtrees React bailed out of, because their fibers keep stale flags from older commits. `memo` wrappers that hold another component (tag 14) are not counted, because React flags both the wrapper and the component inside it and one render would count twice.
+
+Production stays untouched: the file is in `public/` and is never bundled, and the `<Script>` tag in `src/app/layout.tsx` is only rendered when `NEXT_PUBLIC_RENDER_COUNTER` is exactly `"1"`. The root layout is a server component, so a production server reads the variable from its own environment at request time; no deployment sets it. After `pnpm build` without the flag, `grep -r __renderCounter .next/static` finds nothing.
+
+## Fixtures
+
+The copilot scenarios do not need an LLM:
+
+- `fixtures/session-200.json`: 200 message rows (text, code blocks, tables, lists and tool calls). The 50- and 10-message chats are its first 50 and 10 rows.
+- `fixtures/reply-20-lines.sse`: one streamed reply in the backend's SSE format, one word per `text-delta`.
+- `lib/stream-server.ts`: a small local HTTP server that replays the `.sse` file one frame every N ms. The stream request is redirected there with `route.continue({ url })`, so the reply arrives at a steady, repeatable pace. The copilot's own word-by-word smoothing (`copilotStreamSmoothing.ts`) then runs on top, as it does in production.
+- `lib/copilot-fixture.ts` keeps state: once a streamed turn ends, the session GET returns the new user and assistant rows, as the backend would. Without that, the page's refetch after each turn would wipe the reply it just streamed.
+
+The builder and library fixtures (`lib/builder-fixture.ts`, `lib/library-fixture.ts`) are built in code: a 50-node workflow owned by the signed-in user with a RUNNING run (30 nodes done, 3 running, 7 queued), and 20 workflows each with a RUNNING run. Block schemas still come from the real backend.
+
+**Regenerating the synthetic copilot fixtures** (deterministic, same output every time):
+
+```bash
+npx tsx scripts/perf/fixtures/generate.ts
+```
+
+**Re-recording from a real stack** when the wire format changes:
+
+```bash
+npx tsx scripts/perf/record.ts --session-id <id> # the chat's messages → session-200.json
+npx tsx scripts/perf/record.ts --session-id <id> --message "go" # …and one streamed reply → reply-20-lines.sse
+```
+
+The session is saved before the message is sent, so it holds the history the reply follows. Use a throwaway chat, because the files are committed. To record without paying for a model, start `rest_server` and `copilot_executor` with `CHAT_TEST_MODE=true`, which swaps the LLM for the backend's dummy service. `--session-out` and `--reply-out` write to other file names under `fixtures/`. A recorded fixture breaks the `fixtures.test.ts` check that the committed files match the generator, so update that test when you commit one.
+
+## Adding a scenario
+
+1. Add `scripts/perf/scenarios/<name>.ts` exporting a `Scenario` (`lib/scenario.ts`): a `name`, a `description`, a `readyWhen` sentence, a `windowMs`, and `setup(ctx)`. `setup` navigates and waits until the page is ready, then returns `{ run() }` with the measured interaction (`noInteraction` for an idle window).
+2. Serve its data from a fixture: add the URL pattern to `ROUTE_TABLE` in `lib/routes.ts`, and the handler next to the other fixtures. Call `route.fallback()` for requests the fixture does not own.
+3. Reuse the Playwright page objects in `src/playwright/pages/` for selectors.
+4. Register it in `scenarios/registry.ts` and add a row to the table above.
+5. Run it with `--runs 3 --screenshot`, check the screenshot, and check that renders per commit is stable across runs.
+6. Add its baseline to [frontend-perf-baseline.md](frontend-perf-baseline.md).