: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
feat(review-hog): make codex gpt-5.6-sol the default review model (#81797)
Alex Lebedev277aef21fa5c
diff --git a/products/review_hog/ARCHITECTURE.md b/products/review_hog/ARCHITECTURE.mdindex fd8418c616b1..edd7ba4ed874 100644--- a/products/review_hog/ARCHITECTURE.md+++ b/products/review_hog/ARCHITECTURE.md@@ -260,10 +260,16 @@ session** per chunk via the sibling helpers `start_sandbox_session` / `continue_`output_path` / `_error.txt` and no manual JSON extraction — persistence is the caller's job. The runnerpersists the full agent log at `task_run.log_url` (S3 / Tasks UI), so the executor never copies it locally.-The perspective review runs on a different model family than the rest — **OpenAI Codex `gpt-5.5` @ `xhigh`**,-pinned by `REVIEW_{RUNTIME_ADAPTER,MODEL,REASONING_EFFORT}` constants and passed as optional kwargs to-`run_sandbox_review`; chunking, dedup, and the validator stay on the Claude default. See [DECISIONS.md](./DECISIONS.md)-for why (and the `full-access` permission-mode gotcha headless Codex needs), and+The perspective review (the blind-spot sweep rides the same activity) runs on a different model family than the+rest — **OpenAI Codex `gpt-5.6-sol` @ `xhigh`**, with `initial_permission_mode="full-access"`. The pins are per+**report**, not per process: each `ReviewReport` persists a **review arm** (adapter / model / effort / permission+mode), drawn once at report creation from the weighted `REVIEW_EXPERIMENT_ARMS` (`constants.py`; currently the+single default arm above) and kept for the report's life, so a model A/B never mixes arms within one report.+`load_review_arm` → `resolve_review_arm` honors a persisted assignment only while it stays a registry-supported+combo — anything else falls back to the default pins and stamps `review_arm_fallback` on the run's analytics+events — so reports assigned an arm that later left the lineup keep running it while its combo stays registered.+Chunking, dedup, and the validator stay on Claude. See [DECISIONS.md](./DECISIONS.md) for the Sonnet-vs-Sol+production A/B that picked this default (and the `full-access` permission-mode gotcha headless Codex needs), and[Selecting the sandbox model & reasoning effort](#selecting-the-sandbox-model--reasoning-effort) below for thetwo-repo path that applies these knobs.@@ -305,15 +311,17 @@ Read this before testing another model (Sonnet, a new Codex model, a different e**`posthog/posthog` — where the knobs are set + validated.**-- **Pick the values (ReviewHog):** `reviewer/constants.py` `REVIEW_{RUNTIME_ADAPTER,MODEL,REASONING_EFFORT}` →- passed at the `review_chunk_activity` `run_sandbox_review(...)` call → `run_sandbox_review`- (`reviewer/sandbox/executor.py`) threads them onto the `CustomPromptSandboxContext`. To test another model, change- these constants (the executor kwargs exist for every single-turn stage).+- **Pick the values (ReviewHog):** `reviewer/constants.py` `REVIEW_{RUNTIME_ADAPTER,MODEL,REASONING_EFFORT,INITIAL_PERMISSION_MODE}`+ feed `DEFAULT_REVIEW_ARM`; `review_chunk_activity` loads the report's persisted arm (`load_review_arm` →+ `resolve_review_arm`) and passes it as kwargs to `run_sandbox_review` (`reviewer/sandbox/executor.py`), which+ threads them onto the `CustomPromptSandboxContext`. To change the reviewer fleet-wide, change the pins; to A/B+ another model, add a weighted arm to `REVIEW_EXPERIMENT_ARMS` (the executor kwargs exist for every single-turn stage).- **The registry (source of truth for what's allowed)** — `products/tasks/backend/temporal/process_task/utils.py`,re-exported framework-free from the facade `products/tasks/backend/facade/run_config.py` (import from the facade):`RuntimeAdapter` (`claude|codex`), `LLMProvider`, `ReasoningEffort`, `RUNTIME_PROVIDER_BY_ADAPTER`,- `CLAUDE_REASONING_EFFORTS_BY_MODEL`, `CODEX_MODELS` + `CODEX_REASONING_EFFORTS` + `CODEX_XHIGH_REASONING_MODELS`- (only `gpt-5.5` allows `xhigh`), and the pure checks `get_provider_for_runtime_adapter` /+ `CLAUDE_REASONING_EFFORTS_BY_MODEL`, `CODEX_MODELS` + `CODEX_REASONING_EFFORTS` + the+ `CODEX_XHIGH/MAX_REASONING_MODELS` tiers (`gpt-5.5` caps at `xhigh`; the `gpt-5.6-*` models allow up to+ `max`), and the pure checks `get_provider_for_runtime_adapter` /`get_supported_reasoning_efforts` / `get_reasoning_effort_error`. A new model/effort must be added here or the combois rejected. `test_constants.py` locks the ReviewHog combo to this registry at unit time.- **Transport into the sandbox:** `Task._build_task` writes `extra_state[{runtime_adapter, provider, model,@@ -329,15 +337,15 @@ reasoning_effort}]` → `get_task_processing_context` reads it back → `start_aregistry; hard-errors server startup on an unsupported combo), then constructs the `AgentServer`.- **Adapter split `src/server/agent-server.ts`:** Codex → `src/adapters/codex/spawn.ts::buildConfigArgs` pushes`-c model="…"` **and** `-c model_reasoning_effort="…"` onto the Codex CLI (this is the line that applies `xhigh` to- `gpt-5.5`); Claude → `buildClaudeCodeSessionMeta` sets `options.model` + `options.effort` (effort only for the+ `gpt-5.6-sol`); Claude → `buildClaudeCodeSessionMeta` sets `options.model` + `options.effort` (effort only for theclaude adapter). `agent.ts` fetches the gateway model allow-list and **silently drops the model if it isn't served**(`sanitizedModel` / `allowedModelIds`), so a typo'd/unavailable model falls back to a default rather than erroring —verify `$ai_model` on every run when switching.**Recipe — testing e.g. Sonnet.** Set `runtime_adapter = "claude"`, `model` a key in `CLAUDE_REASONING_EFFORTS_BY_MODEL`,and an effort that model supports; provider auto-derives to `anthropic`. For a new Codex model: `runtime_adapter =-"codex"`, `model` in `CODEX_MODELS`, effort in `CODEX_REASONING_EFFORTS` (`xhigh` only if the model is in-`CODEX_XHIGH_REASONING_MODELS`). A brand-new model/effort must be added to the registry in **both** repos (`utils.py`+"codex"`, `model` in `CODEX_MODELS`, effort in `CODEX_REASONING_EFFORTS` (`xhigh`/`max` only for models in the+`CODEX_XHIGH/MAX_REASONING_MODELS` tiers). A brand-new model/effort must be added to the registry in **both** repos (`utils.py`here + `reasoning-effort.ts` / the gateway model list in `@posthog/agent`) or startup validation rejects it on one side.---@@ -425,8 +433,10 @@ IDOR rule) via `class X(UUIDModel, TeamScopedRootMixin)`:rendered `report_markdown`, `acting_user`, `author_login` (the PR author's GitHub login, refreshed from thefetched metadata every turn — powers the "For you" scope's authored-PRs match), `run_urgency_threshold` (thegate the last **completed** turn's body/publish ran under, stamped at finalize alongside `run_count` — what- the drawer buckets findings by; null for pre-column turns), and the `signal_report_id` / `trigger_source`- provenance.+ the drawer buckets findings by; null for pre-column turns), the persisted review arm+ (`review_runtime_adapter` / `review_model` / `review_reasoning_effort` / `review_initial_permission_mode`,+ drawn once at creation — see [Sandbox execution layer](#sandbox-execution-layer)), and the+ `signal_report_id` / `trigger_source` provenance.- **`ReviewReportArtefact`** — the append-only work log mirroring `SignalReportArtefact`, with a funnel thatderives `type` from the content-model class and maps `ArtefactAttribution` → `created_by_id` / `task_id`.`ArtefactType`: `issue_finding`, `validation_verdict`, `task_run`, `commit`, `code_reference`, `note`, plusdiff --git a/products/review_hog/DECISIONS.md b/products/review_hog/DECISIONS.mdindex 5649f3141daa..3bce568a9e28 100644--- a/products/review_hog/DECISIONS.md+++ b/products/review_hog/DECISIONS.md@@ -225,6 +225,43 @@ LLM-written PR prose is blunt: people skip it. Decisions:nobody), and shortening it with another LLM call (paying per review to generate text we just establishedpeople skip).+### ✅ DECIDED 2026-08-12 — reviewer model: Codex GPT-5.6 Sol @ xhigh (production A/B vs Sonnet 5)++The review-stage default moved from Claude Sonnet 5 @ xhigh to **OpenAI Codex `gpt-5.6-sol` @ `xhigh`**+(`full-access`), settling the first production reviewer-model experiment. Mechanics: since early August every+new report drew a sticky per-report arm from `REVIEW_EXPERIMENT_ARMS` (50/50 Sonnet 5 vs GPT-5.6 Sol, both+@ xhigh), labeled on the `reviewhog_review_completed` / `_failed` events (`review_model`, `review_arm_fallback`)+and tracked on the "ReviewHog — usage & health" dashboard (us.posthog.com/project/2/dashboard/1922705,+auth-gated). About a week of dogfood traffic split roughly evenly; PR-size and trigger mixes balanced across+arms; zero fallback turns; `$ai_model` on the review generations confirmed both arms ran their assigned model.++What the split showed (experiment window only, per arm):++- **Cost:** Sol reviews cost roughly a third of Sonnet's all-in per PR, and the gap is wider on the+ arm-controlled review stage alone. Sonnet's ~2x candidate volume also roughly doubles the shared Opus+ validation spend, so its junk flows straight into the pipeline's biggest cost line.+- **Latency:** Sol turns finish in roughly a third of the wall-clock, at p50 and p90 alike.+- **Precision (the item-9 lever above):** Sol emitted well under half the candidates per turn at a validator+ keep rate near double Sonnet's (~41% vs ~24%) — the "stop spamming the validator" direction, achieved by the+ finder model rather than by skill tuning.+- **Quality:** Sonnet kept more valid findings per turn overall, but the surplus was should-fix/consider;+ valid must-fix per turn leaned Sol (not significant). Author engagement with published findings (the+ finding-outcome telemetry: addressed/reacted vs ignored) was level, directionally favoring Sol. Steady-state+ completion was indistinguishable — the dashboard's lower Sol completion rate is rollout-day failures from+ before its first successful turn.++Decision notes:++- The experiment ended the sanctioned way: `REVIEW_EXPERIMENT_ARMS` collapsed to the single default arm,+ nothing deregistered in `products/tasks` — so reports that drew Sonnet keep finishing on Sonnet (persisted+ assignments stay honored while registry-valid, for the report's life).+- The outcome judge (`OUTCOME_JUDGE_MODEL`, claude-opus-5) stays cross-family from the reviewer, now from the+ other side: Claude judges an OpenAI reviewer's findings. Validator, chunking, dedup, and one-shot pins stay+ Claude.+- What a week could NOT settle: whether Sol is strictly better at must-fix coverage — too few must-fix findings+ for significance. Watch the dashboard's importance-mix and precision tiles; re-open with a weighted arm if+ the must-fix trend inverts.+### ✅ BUILT 2026-07-27 — reviews surface exposed as MCP tools (grantable `review_hog` scope)Agents needed to drive ReviewHog over MCP — kick off a review, poll progress, pull the finished findingsdiff --git a/products/review_hog/backend/reviewer/constants.py b/products/review_hog/backend/reviewer/constants.pyindex 475dec81ec70..7f480dc21a22 100644--- a/products/review_hog/backend/reviewer/constants.py+++ b/products/review_hog/backend/reviewer/constants.py@@ -13,12 +13,13 @@ from products.tasks.backend.facade.run_config import (logger = logging.getLogger(__name__)# REVIEW MODEL-REVIEW_RUNTIME_ADAPTER = RuntimeAdapter.CLAUDE-REVIEW_MODEL = "claude-sonnet-5"+REVIEW_RUNTIME_ADAPTER = RuntimeAdapter.CODEX+REVIEW_MODEL = "gpt-5.6-sol"REVIEW_REASONING_EFFORT = ReasoningEffort.XHIGH-# Claude sandboxes run with bypassPermissions by default, so headless MCP skill pulls need no-# extra approval mode. (Only Codex's default "auto" stalls on MCP calls and needs "full-access".)-REVIEW_INITIAL_PERMISSION_MODE = None+# Codex's default "auto" approval mode does not auto-approve MCP tool calls, so a headless reviewer+# stalls on the skill pull without "full-access". (Claude sandboxes bypass permissions by default+# and take None here.)+REVIEW_INITIAL_PERMISSION_MODE = "full-access"@dataclass(frozen=True)@@ -43,24 +44,15 @@ DEFAULT_REVIEW_ARM = ReviewArm(initial_permission_mode=REVIEW_INITIAL_PERMISSION_MODE,)-# The reviewer-model experiment: each new report draws its arm once at creation and keeps it for+# The reviewer-model arm draw: each new report draws its arm once at creation and keeps it for# life, because a per-turn redraw would feed one arm's findings into the other arm's-# "already covered" injection. Weights are relative shares (`random.choices` normalizes them). End-# the experiment by dropping arms HERE, never by deregistering the model in products/tasks:-# persisted assignments resolve against the live registry per unit, so a mid-experiment-# deregistration silently falls in-flight turns back to the default pins, unit by unit.-REVIEW_EXPERIMENT_ARMS: tuple[tuple[float, ReviewArm], ...] = (- (0.5, DEFAULT_REVIEW_ARM),- (- 0.5,- ReviewArm(- runtime_adapter=RuntimeAdapter.CODEX,- model="gpt-5.6-sol",- reasoning_effort=ReasoningEffort.XHIGH,- initial_permission_mode="full-access",- ),- ),-)+# "already covered" injection. Weights are relative shares (`random.choices` normalizes them).+# Run a model experiment by adding weighted arms here; end it by dropping arms HERE, never by+# deregistering the model in products/tasks: persisted assignments resolve against the live+# registry per unit, so a mid-experiment deregistration silently falls in-flight turns back to+# the default pins, unit by unit. Reports that drew a now-dropped arm keep running it while its+# combo stays registered, by design.+REVIEW_EXPERIMENT_ARMS: tuple[tuple[float, ReviewArm], ...] = ((1.0, DEFAULT_REVIEW_ARM),)def draw_review_arm() -> ReviewArm:@@ -223,10 +215,10 @@ CHUNK_SOFT_MAX_ADDITIONS = 600# OUTCOME TELEMETRY# The outcome-classifier judge decides whether the commits that landed after review actually-# addressed a finding. Pinned to a model DIFFERENT from the reviewer's (`REVIEW_MODEL` /-# `ONESHOT_MODEL` = claude-sonnet-5): a judge sharing the reviewer's model family would inherit the-# same blind spots the telemetry exists to measure. Effort is "high" — a focused yes/no on a small-# diff, not the reviewer's exhaustive xhigh pass.+# addressed a finding. Pinned to a model family DIFFERENT from the reviewer's (`REVIEW_MODEL`):+# a judge sharing the reviewer's model family would inherit the same blind spots the telemetry+# exists to measure. Effort is "high" — a focused yes/no on a small diff, not the reviewer's+# exhaustive xhigh pass.OUTCOME_JUDGE_MODEL = "claude-opus-5"OUTCOME_JUDGE_REASONING_EFFORT = "high"# The judge's stated reason is persisted with the outcome so a classification can be explained later.diff --git a/products/review_hog/backend/reviewer/tests/test_constants.py b/products/review_hog/backend/reviewer/tests/test_constants.pyindex 5ef782b3b2e3..00562d723749 100644--- a/products/review_hog/backend/reviewer/tests/test_constants.py+++ b/products/review_hog/backend/reviewer/tests/test_constants.py@@ -9,7 +9,6 @@ from products.review_hog.backend.reviewer.constants import (DEDUP_RUNTIME_ADAPTER,DEFAULT_REVIEW_ARM,REVIEW_EXPERIMENT_ARMS,- REVIEW_INITIAL_PERMISSION_MODE,REVIEW_MODEL,REVIEW_REASONING_EFFORT,REVIEW_RUNTIME_ADAPTER,@@ -35,7 +34,7 @@ def test_review_runtime_is_a_registry_supported_combo() -> None:# that doesn't support the pinned effort — or flipping the adapter — would make the agent server# reject/misroute the run, surfacing only at e2e. Lock the combo to the Tasks registry that gates it.assert get_reasoning_effort_error(REVIEW_RUNTIME_ADAPTER, REVIEW_MODEL, REVIEW_REASONING_EFFORT) is None- assert get_provider_for_runtime_adapter(REVIEW_RUNTIME_ADAPTER) == LLMProvider.ANTHROPIC+ assert get_provider_for_runtime_adapter(REVIEW_RUNTIME_ADAPTER) == LLMProvider.OPENAIdef test_validation_runtime_is_a_registry_supported_combo_when_pinned() -> None:@@ -64,12 +63,6 @@ def test_sandbox_fallback_runtime_is_a_registry_supported_combo(assert get_provider_for_runtime_adapter(adapter) == LLMProvider.ANTHROPIC-def test_review_permission_mode_defaults_to_sandbox_bypass() -> None:- # Claude sandboxes bypass permissions by default, so the review needs no explicit approval mode.- # Pinning a mode here would only be needed for Codex, whose default "auto" stalls on MCP calls.- assert REVIEW_INITIAL_PERMISSION_MODE is None--@pytest.mark.parametrize("arm", [pytest.param(arm, id=arm.model) for _, arm in REVIEW_EXPERIMENT_ARMS])def test_experiment_arm_is_a_registry_supported_combo(arm: ReviewArm) -> None:# Same lock as the pinned combos, per experiment arm: a bad combo is drawn onto half the fleet's@@ -91,7 +84,15 @@ def test_draw_review_arm_draws_from_the_arm_list() -> None:assert draw_review_arm() in {arm for _, arm in REVIEW_EXPERIMENT_ARMS}-_SOL_ARM = next(arm for _, arm in REVIEW_EXPERIMENT_ARMS if arm.runtime_adapter == RuntimeAdapter.CODEX)+# A registry-valid arm that differs from the default pins on every field, so honored-verbatim+# assertions cannot pass by falling back to the default. This is also the live prod scenario:+# reports that drew the Claude arm while it was in the experiment keep it for life.+_SONNET_ARM = ReviewArm(+ runtime_adapter=RuntimeAdapter.CLAUDE,+ model="claude-sonnet-5",+ reasoning_effort=ReasoningEffort.XHIGH,+ initial_permission_mode=None,+)@pytest.mark.parametrize(@@ -99,8 +100,8 @@ _SOL_ARM = next(arm for _, arm in REVIEW_EXPERIMENT_ARMS if arm.runtime_adapter[# Pre-experiment rows carry NULLs and must run the default pins.pytest.param((None, None, None, None), DEFAULT_REVIEW_ARM, id="null-bundle"),- # A persisted assignment is honored verbatim.- pytest.param(("codex", "gpt-5.6-sol", "xhigh", "full-access"), _SOL_ARM, id="persisted-codex-arm"),+ # A persisted assignment that differs from the default pins is honored verbatim.+ pytest.param(("claude", "claude-sonnet-5", "xhigh", None), _SONNET_ARM, id="persisted-claude-arm"),# A model that outlived its registration must degrade to the default reviewer, not send an# unroutable pin into a paid sandbox turn. Pinned at "high" deliberately: the Codex effort# registry accepts any unknown model at <=high, so only the membership check catches this.diff --git a/products/review_hog/backend/tests/test_persistence.py b/products/review_hog/backend/tests/test_persistence.pyindex a7620bc0f8da..96c1e4430222 100644--- a/products/review_hog/backend/tests/test_persistence.py+++ b/products/review_hog/backend/tests/test_persistence.py@@ -110,16 +110,17 @@ class TestUpsertReviewReport(BaseTest):assert report.completed_head_sha == "sha-2" # what the finished turn reviewed, for read anchoringdef test_review_arm_is_drawn_once_and_sticky_across_turns(self) -> None:- # Sticky-per-report is the experiment's core invariant: a redraw on the update path would+ # Sticky-per-report is the arm draw's core invariant: a redraw on the update path would# flip a report's reviewer between turns, poisoning per-arm metrics and feeding one arm's- # findings into the other's "already covered" injection.- sol = ReviewArm(- runtime_adapter=RuntimeAdapter.CODEX,- model="gpt-5.6-sol",+ # findings into the other's "already covered" injection. The drawn arm deliberately differs+ # from the default pins on every field so a loader that silently falls back cannot pass.+ sonnet = ReviewArm(+ runtime_adapter=RuntimeAdapter.CLAUDE,+ model="claude-sonnet-5",reasoning_effort=ReasoningEffort.XHIGH,- initial_permission_mode="full-access",+ initial_permission_mode=None,)- with patch("products.review_hog.backend.reviewer.persistence.draw_review_arm", return_value=sol):+ with patch("products.review_hog.backend.reviewer.persistence.draw_review_arm", return_value=sonnet):report_id = upsert_review_report(team_id=self.team.id, repository="o/r", pr_url="u", pr_metadata=_pr_metadata())@@ -129,10 +130,10 @@ class TestUpsertReviewReport(BaseTest):report.review_model,report.review_reasoning_effort,report.review_initial_permission_mode,- ) == ("codex", "gpt-5.6-sol", "xhigh", "full-access")+ ) == ("claude", "claude-sonnet-5", "xhigh", None)# Through the real loader, not just the raw columns: the values_list → resolve positional- # coupling would otherwise silently fall every Codex report back to the default pins.- assert load_review_arm(team_id=self.team.id, report_id=report_id) == sol+ # coupling would otherwise silently fall every off-default report back to the default pins.+ assert load_review_arm(team_id=self.team.id, report_id=report_id) == sonnetassert load_review_arm(team_id=self.team.id, report_id=str(uuid.uuid4())) == DEFAULT_REVIEW_ARMwith patch(@@ -144,7 +145,7 @@ class TestUpsertReviewReport(BaseTest):)assert redraw.call_count == 0 # the update path must not even drawreport.refresh_from_db()- assert report.review_model == "gpt-5.6-sol"+ assert report.review_model == "claude-sonnet-5"def test_author_login_is_stamped_on_create_and_refreshed_each_turn(self) -> None:# The "For you" scope's authored-PRs match rides this stamp. It must track the PR's currentdiff --git a/products/review_hog/backend/tests/test_review_activity.py b/products/review_hog/backend/tests/test_review_activity.pyindex d36263d6607f..3d88a35afab5 100644--- a/products/review_hog/backend/tests/test_review_activity.py+++ b/products/review_hog/backend/tests/test_review_activity.py@@ -144,16 +144,17 @@ async def test_split_chunks_activity_routes_llm_chunking_by_oneshot_gate(additio@pytest.mark.asyncioasync def test_review_chunk_activity_runs_on_the_reports_persisted_arm() -> None:- # The change's core contract: the perspective-review sandbox turn runs on the REPORT's persisted- # experiment arm. The pin kwargs default to None, so dropping them at this one call site would+ # The arm plumbing's core contract: the perspective-review sandbox turn runs on the REPORT's+ # persisted arm. The pin kwargs default to None, so dropping them at this one call site would# silently fall back to the sandbox default with every plumbing-level test still passing — and a- # site that re-reads the module pins instead of the arm would run every Codex-assigned report on- # Sonnet while its analytics claim Sol.+ # site that re-reads the module pins instead of the arm would run every Claude-assigned report+ # on the Codex default while its analytics claim Sonnet. The arm here deliberately differs from+ # the default pins on every field so either regression fails the kwargs assertion.arm = ReviewArm(- runtime_adapter=RuntimeAdapter.CODEX,- model="gpt-5.6-sol",+ runtime_adapter=RuntimeAdapter.CLAUDE,+ model="claude-sonnet-5",reasoning_effort=ReasoningEffort.XHIGH,- initial_permission_mode="full-access",+ initial_permission_mode=None,)mock_review = AsyncMock(return_value=IssuesReview(issues=[]))env = ActivityEnvironment()