Python
Reviewer follows model switches; retire the dropdown metering line
Devika Verma88bc5c5a36a8
diff --git a/coworker/engine.py b/coworker/engine.pyindex 46b7eba7..9dfd7d5b 100644--- a/coworker/engine.py+++ b/coworker/engine.py@@ -308,6 +308,12 @@ class TurnEngine:return Nonehad_history = any(m.get("role") != "system" for m in self.messages)self.model = model+ # The reviewer judges with the session's own model (§1.5: "if it's trusted to+ # drive the agent, it's strong enough to review it"). Bound once at session build,+ # it would otherwise keep the OLD model for the rest of the session after a+ # switch — silently reviewing with a model the user moved away from.+ if self.reviewer is not None:+ self.reviewer.model = modelif not had_history:return Nonefrom .providers.matrix import model_labelsdiff --git a/surfaces/gui/src/components/Composer.tsx b/surfaces/gui/src/components/Composer.tsxindex 26e52da3..64c9f398 100644--- a/surfaces/gui/src/components/Composer.tsx+++ b/surfaces/gui/src/components/Composer.tsx@@ -955,26 +955,6 @@ function ModeMenu({<span className="text-[11px] text-faint leading-snug">{o.description}</span></button>))}- {mode === "auto-approve" && !!reviewerStats?.checks && (- <>- <div className="my-1 border-t border-line" />- <div className="px-2.5 py-1.5 text-[11px] text-faint leading-snug" data-testid="reviewer-summary">- This session: {reviewerStats.checks} {reviewerStats.checks === 1 ? "check" : "checks"} ·{" "}- {reviewerStats.allow} cleared · {reviewerStats.deny} blocked · {reviewerStats.unsure} asked you- {reviewerStats.tokens_in + reviewerStats.tokens_out > 0 && (- // Fresh and cached shown separately: cached input bills at ~10%, so- // one blended number would either overstate cost or hide most of the- // work. Two honest figures beat one misleading one.- <>- {" "}· ~{Math.round((reviewerStats.tokens_in + reviewerStats.tokens_out) / 100) / 10}k tokens- {(reviewerStats.cache_read ?? 0) > 0 && (- <> (+{Math.round((reviewerStats.cache_read ?? 0) / 100) / 10}k cached)</>- )}- </>- )}- </div>- </>- )}{onUnattendedChange && (<><div className="my-1 border-t border-line" />diff --git a/tests/test_auto_approve.py b/tests/test_auto_approve.pyindex cb69bc29..b70113d2 100644--- a/tests/test_auto_approve.py+++ b/tests/test_auto_approve.py@@ -963,3 +963,26 @@ def test_verdict_audit_rows_carry_the_verdicts_cache_figures(tmp_path):verdict_rows = [r for r in rows if r.get("stage") == "reviewer_verdict"]assert verdict_rows and verdict_rows[0]["cache_read"] == 1400assert verdict_rows[0]["cache_write"] == 25+++def test_reviewer_follows_a_model_switch(tmp_path):+ # The reviewer is bound at session build with the session's model (§1.5). Before this,+ # switch_model() updated the ENGINE's model only, so after a mid-session switch the+ # reviewer silently kept judging with the model the user had moved away from — old+ # capabilities, old pricing, and metering attributed to the wrong model.+ engine, _rows, _approvals = _engine(tmp_path, [AssistantTurn(text="ok", finish_reason="stop")])+ engine.reviewer = Reviewer(provider=_Scripted([]), model="openai:gpt-5.6-sol")+ engine.messages.append({"role": "user", "content": "hi"}) # a real switch, not first bind++ engine.switch_model("anthropic:claude-sonnet-5")++ assert engine.model == "anthropic:claude-sonnet-5"+ assert engine.reviewer.model == "anthropic:claude-sonnet-5"+++def test_model_switch_with_no_reviewer_attached_still_works(tmp_path):+ engine, _rows, _approvals = _engine(tmp_path, [AssistantTurn(text="ok", finish_reason="stop")])+ engine.reviewer = None+ engine.messages.append({"role": "user", "content": "hi"})+ engine.switch_model("anthropic:claude-sonnet-5") # must not raise+ assert engine.model == "anthropic:claude-sonnet-5"