Fix subagent and Gemini break classification

Task 9470 · Done · Coder · created · updated

## Epic requirement (verbatim, Task 9453 body) Task 9440 analysed prod's broken sessions for Oct 18–23 (28 breaks, 12 incidents). The attached report has the evidence and code references. Fix these root causes: 1. Relaunch into the task's own held slot dies after an operator Stop or a runner's task_fail (16 breaks: tasks 7456, 7543, 8212, 8683, 9255). The pane log attached to the "vanished" attempt is the predecessor's. - Fence kill_runner intents on launch_session_id / slot generation, not task id alone (apps/api/app/fleet_verdicts.py build_kill_intent; apps/api/app/routes/tasks/slots.py). An intent minted for a predecessor must never kill a successor launched into the same slot. - Lease drain relaunches into a held slot only after the node reports the predecessor gone. - Do not auto-retry a runner's own task_fail when it follows an answered question round; land it system_failed with the runner's reason. - A vanished incident records the node, the launch id and whether the pane log is the predecessor's. 2. A retry returns to the node that just failed the launch (7 breaks; 7789 failed 4× on h5-3 across 3 accounts). - launch_failed counts toward the per-node skip (apps/api/app/launch_failures.py). - When one node fails the same task's launch across different accounts, refund the attempt. 3. Silent stalls are never recorded (8683 sat active 27 h 35 m, 9255 1 h 4 m, after "Runner started" with no session). - Add a task-level silence detector: an active task with no session attached, heartbeat or transcript write for ~20 min records a break and is reclaimed. 4. The merge lane retries a forge auth rejection ("Invalid username or token", task 7765) until its attempts run out. - Treat it as a credential blocker: one fresh credential mint and one retry in place, then stop re-dispatching and alert the operator, naming the credential. 5. Misclassified breaks. - Break classification on the settle/transcript path skips background-subagent task-notification records (apps/jaahd/hooks/break_cause.py), as rs_stopfailure already skips agent_id events. - Gemini "This client is no longer supported for Gemini Code Assist for individuals" becomes a terminal cause, not auth_expired. Out of scope: the broken-session collection UI; purge/archival of old incidents; dev control plane; investigating h5-3's hardware/OS beyond what item 2 needs; any other break causes. Done means: - Each item ships with a test that reproduces its failure first: a kill minted for launch A does not kill launch B in the same slot; a second launch_failed on node N places the retry on another node; an active task silent past the threshold records a break; a lane auth rejection does not re-dispatch more than once; a subagent limit notification does not classify the session as usage_limit; the Gemini sentence maps to the terminal cause. - After deploy, `tools/broken_sessions.py list` on prod shows no new held-slot "vanished" incidents following a Stop→Run or task_fail over a 5-day window. Required checks: ./dc check full (Item 1c — task_fail after an answered blocker round lands system_failed — already shipped in Task 9264 (`58b8ffd9b`); NOT part of any child.) Settled inputs: the full PRD (Task 9451) and Architecture (Task 9452) are the epic's `prd` / `architecture` artifacts; this child is the Architecture's section named below. Evidence report: attachment 9076_report.html (Task 9440). Every new test must FAIL on today's develop first — cite the red run in the PR. --- # Child C7 — Fix subagent and Gemini break classification ## Scope (this child) Epic item 5 (PRD R5a, R5b, end-reason label; Architecture §C7, decisions D11, D12). Verbatim asks: "Break classification on the settle/transcript path skips background-subagent task-notification records (apps/jaahd/hooks/break_cause.py), as rs_stopfailure already skips agent_id events." and "Gemini "This client is no longer supported for Gemini Code Assist for individuals" becomes a terminal cause, not auth_expired." PRD (verbatim): - R5a. Every break classification that reads a transcript (`classify_transcript`, `classify_turn_end`, and any other reader of transcript record text in `break_cause.py`) ignores records that are background-subagent task notifications (a record whose text is a `<task-notification>` block). The main session's own limit/auth/error records still classify exactly as today. - R5b. The sentence "This client is no longer supported for Gemini Code Assist for individuals" maps, wherever it is classified (Google ACP dialect error text; vendor-error records via `classify_vendor_error`), to a cause in `runner_breaks.TERMINAL_CAUSES` — the attempt ends `system_failed` at once with the sentence as its reason, and **no `auth_rejected` account verdict is written**. - Decided: a new cause **`client_unsupported`** in both cause mirrors (`runner_breaks.CAUSES`, `break_cause.CAUSES`) and in `TERMINAL_CAUSES`. Matched off vendor-written error text only, never prose, like `MODEL_REFUSED`. - The Sessions end-reason label for the new causes (`stalled`, `client_unsupported`) renders a human label, not the raw slug (`apps/api/app/routes/sessions.py:370-393`, `end_reason_label`). - Constraint: cause vocabulary stays single-homed: `runner_breaks.CAUSES` is SSOT, `break_cause.CAUSES` its node mirror; a test pins them in step. ## Approach (Architecture, settled) - 5a (D12): one predicate `_is_task_notification(record)` in `apps/jaahd/hooks/break_cause.py` — true when the record's own text, left-stripped, STARTS WITH `<task-notification>` (not "contains": a main-session record quoting one must still classify). Skip it in `_record_text` (`:319-330`), `_last_api_error_text` (`:305-316`) and `classify_turn_end`'s last-text-carrying-record scan (`:286-295`). - 5b node (D11): `CLIENT_UNSUPPORTED_CAUSE = "client_unsupported"`, `CLIENT_UNSUPPORTED = re.compile(r"This client is no longer supported for Gemini Code Assist", re.I)`, checked first in `classify_api_error` (before `MODEL_REFUSED`); `classify_transcript`'s API-error early return fires on it; added to `break_cause.CAUSES`. Google ACP dialect (`apps/jaahd/agent_providers.py:797-801`) gets a first row `(r"(?:Onboarding failed: )?This client is no longer supported for Gemini Code Assist", "client_unsupported")` ahead of `auth_expired`. `acp/events.py::_CAUSE_CLASSES` gets `"client_unsupported": ""` (not record-only). - 5b CP: `runner_breaks.CAUSES` + `client_unsupported`; `TERMINAL_CAUSES = {"model_refused", "client_unsupported"}`; `runner_terminations` label "client no longer supported". Also add it to `runner_terminations.CAUSES` and `RESTART_HINT_CAUSES` as required by `apps/api/tests/test_runner_terminations.py`. Do NOT add it to `_ACCOUNT_BREAK_VERDICTS` (`routes/agent/runner_liveness.py:91-95`) — no `auth_rejected` verdict; the terminal path (`runner_liveness.py:199`) fails the attempt with the sentence as reason. - Label: `end_reason_label` renders readable words for `client_unsupported` (C5 owns `stalled`'s label; if C5 has not merged yet, the mirror/label test covers only what exists — append, file overlap resolves at rebase). - Mirror test: CREATE one (none exists today) as an API test that loads `apps/jaahd/hooks/break_cause.py` by path, pinning `break_cause.CAUSES == runner_breaks.CAUSES − {vanished, launch_failed, stalled}` (tolerating `stalled` whether or not C5 has landed). ## Credentials & reach | Oracle | Credential / identity / environment | Status | |---|---|---| | AC5a, AC5b, AC-L (unit and API tests) | Nothing beyond the worktree's own `./dc` stack | verified — runs in any leased worktree, no roster credential needed | | AC-RC `./dc check full` | Merge lane's worktree, no credential | verified — the lane runs it per project config | Out of scope (PRD §7, verbatim) — do NOT touch: - MUST NOT change the broken-session collection UI (console pages listing runner-break incidents) beyond the incident **body text** R1d requires. - MUST NOT add purge/archival of old incidents or change `tools/broken_sessions.py purge` / `runner_breaks.stale_escalations`. - MUST NOT change dev control plane config or data; no dev-only behaviour. - MUST NOT investigate or change h5-3's hardware/OS, node packaging or host setup beyond what item 2's placement/refund needs. - MUST NOT add or reclassify any other break cause (e.g. `timeout`, `api_error`, `crashed`, `unknown` rules) beyond `stalled` and `client_unsupported`; the unexplained 8569 break is not addressed. - MUST NOT re-implement 1c (Task 9264 shipped it) or widen it to non-blocker interview rounds. - MUST NOT change coder-runner push/credential handling (merge lane only for item 4). Epic out of scope: the broken-session collection UI; purge/archival of old incidents; dev control plane; investigating h5-3's hardware/OS beyond what item 2 needs; any other break causes. No feature flag, setting or operator toggle may gate the fix (PRD: on by default once deployed). Architecture boundary: no other cause rules change; no Gemini provider re-introduction. Done means: - AC5a: A transcript whose only limit text is in a subagent `<task-notification>` record classifies `unknown` (not `usage_limit`) on both `classify_transcript` and `classify_turn_end`; a main-session limit record still classifies `usage_limit`. — New cases in `apps/jaahd/tests/test_break_cause.py` → pass (red on `develop`, as reproduced in the PRD §5a). Also: a main-session record quoting `<task-notification>` mid-text still classifies `usage_limit` (pins starts-with, not contains). - AC5b: The Gemini sentence (alone, after `Onboarding failed:`, and after `HTTP 401`) classifies `client_unsupported` on the ACP dialect and `classify_vendor_error`; `client_unsupported ∈ TERMINAL_CAUSES`; recording it ends the attempt `system_failed` and writes no `auth_rejected` verdict; cause mirrors stay in step. — Tests in `apps/jaahd/tests/test_break_cause.py`, `apps/jaahd/tests/test_acp_events.py`, API runner-break route test → pass. - AC-L (client_unsupported half): The Sessions end-reason filter/label shows a readable label for `client_unsupported` (no raw slug). — API test over `end_reason_label` → pass. - Epic done-means (item 5): a subagent limit notification does not classify the session as usage_limit; the Gemini sentence maps to the terminal cause — the AC5a/AC5b tests above. - AC-RC: Full gate green — `./dc check full` (merge lane) → green. Required checks: ./dc check full

Outcome

Subagent <task-notification> records no longer classify breaks; Gemini "client no longer supported" is new terminal cause client_unsupported (no auth verdict, readable label). New tests red on develop, green on branch; quick gate green. PR #6764 queued (merged with #6762).

Pull request

Artifacts

Activity

  • Draft
  • Ready
  • Runner started
  • Runner ended (done)