Skip to content

fix(always_on): a failed wake ends only that wake; the whole run is judged - #981

Open
sarah-chitty-1 wants to merge 3 commits into
sarahchitty/always-on-infra-failuresfrom
sarahchitty/always-on-carry-on-after-failed-wake
Open

sarah-chitty-1 wants to merge 3 commits into
sarahchitty/always-on-infra-failuresfrom
sarahchitty/always-on-carry-on-after-failed-wake

Conversation

@sarah-chitty-1

@sarah-chitty-1 sarah-chitty-1 commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Stacks on #933 (sarahchitty/always-on-infra-failures). Merge that first.

What was broken

In the always_on step, one failed wake ended the whole multi-day run. The judges then skipped the run, or scored it 0 without reading it. Hark's audit found 43 of 210 graded runs ended early this way. Those runs averaged 0.11 rubric satisfaction, against 0.65 for runs that finished. In one example, a turn cap in wake 1 of a 10-day task scored 0.

What each failure kind does now

  • The agent's own failure (agent_error, a crash, canceled, rejected, a turn cap with continue_after_wake_limit off): only that wake ends. The failure is recorded and the run goes on to its next wake, check or user message. The prompt response keeps no error_type.
  • Infra failure (infra_error, an agent that stopped answering): unchanged from fix(always_on): an infra-failed turn is redone from its env deploy instead of scoring 0 #933. The run ends as agent_turn_infra_error, the step fails with AgentTurnInfraError, and the run is redone.
  • Three failed turns in a row end the run as agent_turn_failed. The run is still judged.
  • A turn agent-env gave up waiting on (agent_turn_timeout) still ends the run. It is now judged, not skipped.

The cap of 3

One failure is the case a run should survive. The harness can recover: the PSI neutral harness writes the next wake a note and compacts. A second failure in a row can still be the same condition clearing. A third means two chances to recover are gone. Ending there stops a dead agent spinning through every scheduled wake, each of which can cost up to timeout_seconds of the budget. A completed turn, or one cut off at a limit, starts the count again. The cap is a module constant, FAILED_TURNS_IN_A_ROW_MAX.

Why agent-env's own timeout still ends the run

No end state says the turn stopped, so it may still be running. A next wake would share its session and its world. Its tool calls and app changes would land in another wake's record. With continue_after_wake_limit on, the step still cancels such a turn and goes on once the agent confirms it stopped, as before.

Verifiers that now judge these runs

A run that ended on its agent's own failure is judged as a whole, and its failed turns count against the agent.

  • always_on_agent_verifier, through a new rubrics_verifier hook, _judges_failed_run.
  • user_sim_judge.
  • agent_prompt_response_verifier.
  • rate_user_satisfaction.
  • env_outcome never skipped.

A run that the user sim or the step broke is still scored 0 without being judged. A plain rubrics_verifier on a prompt_agent turn is unchanged.

New record fields and the step note

  • metadata["always_on"][step_id] gains:
    • failed_turns: each failed turn's wake, turn, error_type, error_code, message, went_on and told_in_wake.
    • counts.failed_turns and counts.failed_turn_kinds, keyed by error_code, else error_type.
    • reached_scheduled_end, true for end_time, user_done and finished_nothing_pending.
  • The timeline gets a turn_failed event for each failed turn.
  • The judge's wake-by-wake text and the staged index say which turn failed and whether the run went on.
  • After a failed turn the run went on from, the next wake opens with the step's own note, as it does after a cut-off. The note is the same for every harness and failure kind. It never carries the error text, which can name the infrastructure: "(Your last turn ended with an error before you finished. What you did before then stands; anything you were in the middle of did not finish.)"
    • It is recorded as the cut-off note is: failed_turn_notice on the wake event and on the staged woke line.
    • The judge's index labels it as the run's note, not the user's words.

Tests

  • New: tst/unit/task_step/test_always_on_failed_turns.py, 25 tests. Every new test fails against the base source.
    • Hark's test 1: a fake agent fails wake 2 of 5, for each failure kind. Wakes 3 to 5 still run and the judges read the whole run.
    • An infra failure still follows fix(always_on): an infra-failed turn is redone from its env deploy instead of scoring 0 #933.
    • The cap ends the run, and the run is still judged.
    • A completed turn starts the count again.
    • The timeout ends the run, and the run is judged.
    • The per-run report fields.
    • The next-wake note: it is sent after a failed turn, a completed turn adds none, and the judge's view labels it as the run's.
  • New tests in other files:
    • In test_user_sim_judge.py, user_sim_judge judges a run ended by the cap.
    • In test_user_sim_satisfaction.py, rate_user_satisfaction rates a run ended by the cap.
  • Updated: the old tests that pinned "a failed turn ends the run".
  • Golden file: one case is re-recorded. It now reaches the prompt_error path through a user-sim error, and only its message changed.
  • tst/unit/task_step plus the other always_on-touching unit tests (agents/claude_code, bundle, cli, env/gateway/triggers_fires_test.py, task, training): 7418 passed, 6 failed. The 6 also fail on the base branch: computer_exec_test.py (4) and test_mcp_cli_builder.py (2).
  • ruff check is clean.

🤖 Generated with Claude Code

Confidence Score: 5/5RetriggerView in Greptile

The changes appear safe to merge; the earlier grading failure is addressed.

Summary

always_on now continues after an agent's failed wake and judges the whole run. Infrastructure failures still stop the step for retry.

  • An agent-owned failure ends its wake, not the whole always_on run.
  • Always-on graders evaluate runs ended by the agent's own failures.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Agent turn ends] --> B{How did it end?}
  B -->|Completed or cut off| C[Reset failure count]
  B -->|Agent failed| D[Record failure]
  D --> E{Three failures in a row?}
  E -->|No| F[Continue to next wake]
  E -->|Yes| G[End run and judge it]
  B -->|No answer before timeout| G
  B -->|Infrastructure failed| H[Fail step for retry]
  G --> I[Stage available records]
  I --> J[Mark missing trajectories explicitly]
Loading

Reviews (2) · Last reviewed commit: "fix(always_on): a judged run whose faile..." · Reviewed by Greptile

sarah-chitty-1 and others added 2 commits December 1, 2026 12:18
… is judged

A turn that fails as the agent's own failure (error_type agent_error, or
anything but infra_error) no longer ends the multi-day run. It is recorded
(a turn_failed timeline event, and the record's failed_turns with its
error_type, error_code and message), what it sent the user is taken as any
wake's is, and the run goes on to its next wake, check or user message, the
prompt response keeping no error_type.

- Infra failures keep #933's behaviour: the run ends as
  agent_turn_infra_error and the step fails with AgentTurnInfraError.
- FAILED_TURNS_IN_A_ROW_MAX (3) failed turns in a row end the run as
  agent_turn_failed, so a dead agent can't spin through every scheduled wake.
  A completed or cut-off turn starts the count again.
- A turn agent-env gave up waiting on (agent_turn_timeout) still ends the
  run: no terminal state says it stopped, so a next wake would share its
  session and world with it.
- A run that ended on its agent's own failure (AGENT_FAILURE_ENDS) is judged
  as a whole, not skipped: always_on_agent_verifier (via a rubrics_verifier
  hook), user_sim_judge, agent_prompt_response_verifier and
  rate_user_satisfaction. env_outcome never skipped. A run the user sim or
  the step broke is still scored 0 unjudged.
- The record reports early ends per run: failed_turns,
  counts.failed_turns, counts.failed_turn_kinds (by error_code, else
  error_type) and reached_scheduled_end. The judge's wake-by-wake text and
  the staged index say which turn failed and whether the run went on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…th an error

After a failed turn the run went on from, the next wake opens with the step's
own note (FAILED_TURN_TEXT), as it does after a cut-off (CUT_OFF_TEXT). It is
the same for every harness and failure kind and never carries the error's text,
which can name the infrastructure. It is recorded as the cut-off note is:
failed_turn_notice on the wake event and the staged "woke" line, told_in_wake
on the failed turn's entry, and the judge's index says it is the run's note,
not the user's words.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sarah-chitty-1
sarah-chitty-1 requested a review from a team as a code owner December 1, 2026 22:14
…reaches staging, never "No trajectory available"

A turn agent-env gave up waiting on returns before its trajectory is read, so a run whose opening wake timed out
stored none; with use_trajectory, rubrics_verifier then raised "No trajectory available" (and _compact_trajectory
would again) instead of judging the run #981 now judges. The same held for a run its failed turns in a row ended, and
for one that went on after failed turns (ended at its wake cap, no error on its response), whenever none stored one.

rubrics_verifier gets a hook, _judges_without_trajectory (never in the base): when it says so, a run with no
trajectory skips the guard and the single-file compaction and goes to stage_trajectory, refused still if nothing was
staged. always_on_agent_verifier says so for a run with any failed turn of its agent's own; each such wake is staged
from the run's record with a trajectory_missing line and named in the judge's prompt. A run that failed no turn and
stored none is still refused. Staged by position (no timeline kept), the turn agent-env gave up waiting on, sent but
with no per-turn trajectory entry, is now staged as a turn whose trajectory is missing instead of left out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant