Skip to content

fix(always_on): an infra-failed turn fails the step instead of scoring 0 - #933

Open
sarah-chitty-1 wants to merge 1 commit into
mainfrom
sarahchitty/always-on-infra-failures
Open

sarah-chitty-1 wants to merge 1 commit into
mainfrom
sarahchitty/always-on-infra-failures

Conversation

@sarah-chitty-1

@sarah-chitty-1 sarah-chitty-1 commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

In an always_on run, a wake can fail for a reason that isn't the model's: a gateway 5xx, throttling, a dead agent sandbox. Today the run ends normally and the rubrics judges score it 0, so the failure counts against the model. The A2A protocol already tells the two apart. error_type: agent_error means the agent failed. infra_error means it didn't, and agent-env may retry. Nothing acted on that.

With this change:

  • always_on: the run ends as agent_turn_infra_error when a turn's error_type is infra_error, or when the agent stops answering (AgentUnreachableError, agent_env.agent_unreachable).
    • The timeline, record, conversation and prompt response are still written. The record now also keeps error_code.
    • Then the step raises AgentTurnInfraError, so no verifier grades it and a retry_config can redo it.
    • agent_error turns are graded as before. agent-env's own turn timeout is still graded.
  • outcome.py: AgentTurnInfraError is TRANSIENT, the same cause as other retryable failures. Key, budget and auth text still decides first.
  • rubrics_verifier: an infra_error prompt response is skipped, with no score and no rows, so aggregates leave it out. A run where every source is skipped is UNSCORED. _gated no longer compares a skipped verdict's missing score.
  • turn_events (native OpenInference):
    • A harness.error span becomes a failure note for the judge (kind, message, HTTP status, retries). Until now it was dropped as the harness's own span.
    • A failed_wake message names its kind.
    • The gateway, throttled, timeout_call and harness kinds are described to the judge as not the assistant's doing.
  • staging:
    • harness_note lines carry the failure, the index gets an error line for it, and the record lists harness_failures.
    • The judge's files note explains failure lines only in runs that have one, so other runs' prompts are unchanged.
  • agents/AGENTS.md: says what always_on does with each error_type.

Effect on other harnesses

Under always_on, any harness that already sends infra_error now fails the step where it used to score 0. That covers Pi's pi.model_error, OpenHands, Pydantic AI HTTP errors and framework exceptions. Their time-limit codes are agent_error, so time limits don't change.

Overlap with open PRs

Not in this PR

  • agent_prompt_response_verifier still scores infra failures 0.
  • user_sim_error doesn't raise the same way.
  • No in-run retry.
  • ATIF profile 1.3.

How it was tested

  • After rebasing onto main (3f02298): the changed and new tests, 204 passed (outcome_test, test_always_on_agent_verifier, test_always_on_graded, test_always_on_wake_limit, test_turn_events, test_always_on_staging, test_rubrics_verifier_infra_error). ruff check is clean on the changed files.
  • Before the rebase:
    • The always_on, rubrics_verifier, turn_events, staging, aggregate, satisfaction and outcome suites: 930 passed.
    • tst/unit/task_step, tst/unit/task and tst/unit/bundle: 6,411 passed and 4 failed. The 4 are in computer_exec_test.py, which this PR doesn't touch; its shell command exits 127 on macOS.
  • Each of the 14 changes was reverted in turn, and its tests failed each time.
  • The whole-repo unit run hung locally, so there's no full-suite result here. CI is the check for that.

🤖 Generated with Claude Code

Confidence Score: 4/5 · Fix the older aggregate path before merging so infrastructure failures do not still count as zero.RetriggerView in GreptileConfidence Score: 4/5

Fix the older aggregate path before merging so infrastructure failures do not still count as zero.

FindingsFix All in CursorFindings

  1. P1 Skipped runs still score zero ▶
  2. P2 Long failure lines get truncated ▶
Fix with agent prompt
### Issue 1
src/agent_env/task_step/task_steps/verifiers/rubrics_verifier.py:822
`_not_graded` returns no rows for an infrastructure failure, but aggregates configured with `verifier_ids` turn an empty row list into score 0. When every source skips, `_pooled_entries` records a graded zero, so the run still counts against the model.

Make that aggregate path skip when all its sources were skipped, and test it alongside the new `sources` case.

### Issue 2
src/agent_env/task_step/task_steps/verifiers/always_on_staging.py:78
Adding `failure` to `_IDENTITY` keeps its entire contents inline, including the unrestricted `harness.error.message`. If an error contains a long body or traceback, it stays in both wake files and `events.jsonl` even after `fit_all` moves `text` aside. The line can exceed `LINE_CHARS`, leaving the judge with truncated failure details.

Keep only small failure fields inline and move the message to a side file.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

This PR separates infrastructure failures from model failures.

  • Infrastructure failures now fail always-on steps after recording the run.
  • Rubrics verifiers leave infrastructure-failed runs unscored.
  • Always-on judge traces now show why the harness says a wake failed.

The older verifier_ids aggregate still assigns zero when every source skips. Failure messages also bypass the staged line-length limit.

Explicitly deferred by sarah-chitty-1: infrastructure failures in agent_prompt_response_verifier, matching treatment for user_sim_error, in-run retries, and ATIF profile 1.3.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Agent turn ends] --> B{Infrastructure failure?}
  B -->|Yes| C[Write timeline, conversation and response]
  C --> D[Raise AgentTurnInfraError]
  D --> E{Retry configured?}
  E -->|Yes| F[Roll back configured steps and retry]
  E -->|No| G[Fail step]
  B -->|No| H[Keep existing grading behavior]
  I[Rubric reads infrastructure error] --> J[Skip with no score or rows]
  J --> K[Named-source aggregate skips]
  J --> L[Older verifier_ids aggregate records zero]
Loading

Reviews (1) · Last reviewed commit: "fix(always_on): an infra-failed turn fai..." · Reviewed by Greptile

…g 0; judges read the harness's failure

A PSI always_on run whose wake failed for an infrastructure reason (a gateway 5xx, throttling, a dead
sandbox) was recorded as a normal end and then scored 0 by the rubrics judges, so it counted as the
model's failure (BELOW_ONE). The A2A protocol already says which failures are the agent's
(error_type agent_error) and which aren't (infra_error, "agent-env may retry it"); nothing acted on it.

- always_on: a turn whose error_type is infra_error, or whose agent stopped answering
  (AgentUnreachableError, error_code agent_env.agent_unreachable), ends the run as
  agent_turn_infra_error (in ERROR_ENDS and END_NOTES). The timeline, record, conversation and prompt
  response are written as before, and the record now keeps error_code. Then the step raises
  AgentTurnInfraError, so no verifier grades it and a retry_config can redo it. agent_error turns are
  graded as before. Docstrings now say what a failed turn gets (a rubrics 0, not a skip).
- task/outcome.py: AgentTurnInfraError classifies as TRANSIENT (key budget/auth text still wins).
- rubrics_verifier: an infra_error prompt response is a true skip (no score, no rows; the mistakes
  entry skipped too), so an aggregate leaves it out and a run with every source skipped is UNSCORED.
  _gated no longer compares a skipped verdict's missing score.
- turn_events (native OpenInference): a harness.error span is a failure note (kind, message, HTTP
  status, retries) instead of being dropped as the harness's own span; a failed_wake message names
  the kind. gateway, throttled, timeout_call and harness kinds are said to be no doing of the
  assistant's.
- staging: harness_note lines carry failure, the index gets an error line for it, the record lists
  harness_failures, and the judge's files note explains failure lines only when there is one.
- agents/AGENTS.md: what always_on does with each error_type.

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 November 26, 2026 00:11
for rubric_evidence_with_mistakes the second entry is skipped too."""
mistakes = ({**self._mistakes_entry_fields(), "results": [], "score": None, "skipped": reason}
if self.writes_mistakes_entry else None)
return RubricsVerdict(skipped=reason, output=self._entry_format_fields(), mistakes_entry=mistakes)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Skipped runs still score zero

_not_graded returns no rows for an infrastructure failure, but aggregates configured with verifier_ids turn an empty row list into score 0. When every source skips, _pooled_entries records a graded zero, so the run still counts against the model.

Make that aggregate path skip when all its sources were skipped, and test it alongside the new sources case.

Knowledge Base Used: Agent and environment validation

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agent_env/task_step/task_steps/verifiers/rubrics_verifier.py
Line: 822

Comment:
**Skipped runs still score zero**

`_not_graded` returns no rows for an infrastructure failure, but aggregates configured with `verifier_ids` turn an empty row list into score 0. When every source skips, `_pooled_entries` records a graded zero, so the run still counts against the model.

Make that aggregate path skip when all its sources were skipped, and test it alongside the new `sources` case.

**Knowledge Base Used:** [Agent and environment validation](https://app.greptile.com/-/switch-tenant?tenant=scale-ai&next=%2Fcustom-context%2Fknowledge-base%2Fscaleapi%2Fagentenv-framework%2F-%2Fdocs%2Fagent-and-environment-validation.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Cursor Fix in Claude Code Fix in Codex

# A line's fields that say what and where it is; ``fit`` moves only the others.
_IDENTITY = frozenset({"event", "wake", "at", "call", "turn", "tool", "kind", "state", "outcome", "phase", "by",
"step", "subagent", "compaction", "internal", "cut_off", "cut_off_notice", "limit"})
"step", "subagent", "compaction", "failure", "internal", "cut_off", "cut_off_notice",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Long failure lines get truncated

Adding failure to _IDENTITY keeps its entire contents inline, including the unrestricted harness.error.message. If an error contains a long body or traceback, it stays in both wake files and events.jsonl even after fit_all moves text aside. The line can exceed LINE_CHARS, leaving the judge with truncated failure details.

Keep only small failure fields inline and move the message to a side file.

Knowledge Base Used: Task-step context and execution

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agent_env/task_step/task_steps/verifiers/always_on_staging.py
Line: 78

Comment:
**Long failure lines get truncated**

Adding `failure` to `_IDENTITY` keeps its entire contents inline, including the unrestricted `harness.error.message`. If an error contains a long body or traceback, it stays in both wake files and `events.jsonl` even after `fit_all` moves `text` aside. The line can exceed `LINE_CHARS`, leaving the judge with truncated failure details.

Keep only small failure fields inline and move the message to a side file.

**Knowledge Base Used:** [Task-step context and execution](https://app.greptile.com/-/switch-tenant?tenant=scale-ai&next=%2Fcustom-context%2Fknowledge-base%2Fscaleapi%2Fagentenv-framework%2F-%2Fdocs%2Ftask-step-execution.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Cursor Fix in Claude Code Fix in Codex

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