: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(review-hog): keep sandbox completion with the caller (#110248)
Alex Lebedev9b8f83572518
diff --git a/docs/internal/sandboxes-setup-guide.md b/docs/internal/sandboxes-setup-guide.mdindex e704d920d7cb..51ff3c632686 100644--- a/docs/internal/sandboxes-setup-guide.md+++ b/docs/internal/sandboxes-setup-guide.md@@ -112,6 +112,10 @@ orchestrates these activities:The activities live in`products/tasks/backend/temporal/process_task/activities/`.+The agent's `finish` tool marks a TaskRun terminal and triggers sandbox cleanup.+ReviewHog and scout suggestion tasks do not expose it because their callers own session completion.+ReviewHog receives and validates each turn's JSON before ending the session, and validation can use multiple turns in the same sandbox.+Credential refresh runs in the background. For workflow histories with the `tasks-credential-refresh-propagate-cancel` patch, cancellation stops the loop even during an in-flight refresh activity.Other refresh failures retry on the default cadence.diff --git a/packages/agent/packages/harness/src/extensions/local-tools/tools/finish.test.ts b/packages/agent/packages/harness/src/extensions/local-tools/tools/finish.test.tsindex 704a0db1e8a8..98aaec6b6460 100644--- a/packages/agent/packages/harness/src/extensions/local-tools/tools/finish.test.ts+++ b/packages/agent/packages/harness/src/extensions/local-tools/tools/finish.test.ts@@ -90,6 +90,37 @@ describe("finish tool", () => {},expected: true,},+ {+ name: "caller-managed ReviewHog run",+ ctx: { cwd: "/repo", requestFinish },+ meta: {+ environment: "cloud",+ background: true,+ taskOriginProduct: "review_hog",+ },+ expected: false,+ },+ {+ name: "ReviewHog run with run ids only (out-of-process adapter)",+ ctx: { cwd: "/repo", taskId: "task-1", taskRunId: "run-1" },+ meta: {+ environment: "cloud",+ background: true,+ taskOriginProduct: "review_hog",+ },+ expected: false,+ },+ {+ name: "ReviewHog 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: "review_hog",+ endRunWhenDone: true,+ },+ expected: false,+ },{name: "caller-managed scout suggestions run",ctx: { cwd: "/repo", requestFinish },diff --git a/packages/agent/packages/harness/src/extensions/local-tools/tools/finish.ts b/packages/agent/packages/harness/src/extensions/local-tools/tools/finish.tsindex af7e9c1231e1..c758521c9319 100644--- a/packages/agent/packages/harness/src/extensions/local-tools/tools/finish.ts+++ b/packages/agent/packages/harness/src/extensions/local-tools/tools/finish.ts@@ -98,12 +98,13 @@ 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.+ // ReviewHog and suggestions callers own completion. An agent-side finish can+ // interrupt structured output, follow-up turns, or persistence.isEnabled: (ctx, meta) =>meta?.environment === "cloud" &&meta?.background === true &&meta?.taskOriginProduct !== "scout_suggestions" &&+ meta?.taskOriginProduct !== "review_hog" &&((meta?.taskOriginProduct !== undefined &&meta?.taskOriginProduct !== "workflow") ||meta?.endRunWhenDone === true) &&diff --git a/products/review_hog/ARCHITECTURE.md b/products/review_hog/ARCHITECTURE.mdindex 60c4874ebd50..c1ef9d42b89c 100644--- a/products/review_hog/ARCHITECTURE.md+++ b/products/review_hog/ARCHITECTURE.md@@ -387,6 +387,10 @@ because its tasks carry `origin_product=REVIEW_HOG` (see `SELF_DRIVING_ORIGIN_PRthe app is resolved inside the Tasks provisioning activity. Same image and resources as any other run — the splitonly separates the fleet's Modal cost from user-driven runs.+ReviewHog owns each session's lifecycle.+Tasks with `origin_product=review_hog` do not expose the agent's `finish` tool, because it marks the TaskRun terminal and tears down the sandbox before the caller can validate the final JSON or send another validation turn.+The agent returns JSON at the end of each turn; the caller validates it and ends the session when its work is complete.+`run_sandbox_review(team_id, user_id, repository, branch, prompt, system_prompt, model_to_validate, step_name) -> Model | None`:1. Does **not** own concurrency — the caller bounds it: each fan-out child workflow wraps its per-unit sandbox