:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(tasks): let scout suggestion callers finish sessions (#107828)
Alex Lebedev7df28833a8d9
diff --git a/docs/published/handbook/engineering/ai/sandboxed-agents.md b/docs/published/handbook/engineering/ai/sandboxed-agents.mdindex 23691cb6f777..89663538590c 100644--- a/docs/published/handbook/engineering/ai/sandboxed-agents.md+++ b/docs/published/handbook/engineering/ai/sandboxed-agents.md@@ -295,6 +295,8 @@ summary = await session.send_followup(await session.end()```+Sessions with the `scout_suggestions` origin hide the agent's `finish` tool so the caller can validate and save the result before closing the sandbox.+### Reference implementationSee `products/tasks/backend/logic/services/mts_example/` for a complete working example.diff --git a/products/desktop/packages/harness/src/extensions/local-tools/tools/finish.test.ts b/products/desktop/packages/harness/src/extensions/local-tools/tools/finish.test.tsindex 8361fe80afc5..704a0db1e8a8 100644--- a/products/desktop/packages/harness/src/extensions/local-tools/tools/finish.test.ts+++ b/products/desktop/packages/harness/src/extensions/local-tools/tools/finish.test.ts@@ -90,6 +90,27 @@ describe("finish tool", () => {},expected: true,},+ {+ name: "caller-managed scout suggestions run",+ ctx: { cwd: "/repo", requestFinish },+ meta: {+ environment: "cloud",+ background: true,+ taskOriginProduct: "scout_suggestions",+ },+ expected: false,+ },+ {+ name: "scout suggestions run with an end-run opt-in and run ids",+ ctx: { cwd: "/repo", taskId: "task-1", taskRunId: "run-1" },+ meta: {+ environment: "cloud",+ background: true,+ taskOriginProduct: "scout_suggestions",+ endRunWhenDone: true,+ },+ expected: false,+ },{name: "no gate meta",ctx: { cwd: "/repo", requestFinish },diff --git a/products/desktop/packages/harness/src/extensions/local-tools/tools/finish.ts b/products/desktop/packages/harness/src/extensions/local-tools/tools/finish.tsindex d0cffb6f41af..af7e9c1231e1 100644--- a/products/desktop/packages/harness/src/extensions/local-tools/tools/finish.ts+++ b/products/desktop/packages/harness/src/extensions/local-tools/tools/finish.ts@@ -98,9 +98,12 @@ export const finishTool = defineLocalTool({// runs pay the timeout. An unknown origin also hides the tool: the origin// fetch fails soft, and exposing `finish` on a blip would silently eat a// workflow run's reply, while hiding it only costs a bounded idle window.+ // Suggestions callers own completion after all turns and persistence;+ // an agent-side finish would close the run before that work completes.isEnabled: (ctx, meta) =>meta?.environment === "cloud" &&meta?.background === true &&+ meta?.taskOriginProduct !== "scout_suggestions" &&((meta?.taskOriginProduct !== undefined &&meta?.taskOriginProduct !== "workflow") ||meta?.endRunWhenDone === true) &&