stage: retry pre-admission harness reach failures and widen repair deadline

Treat a failure to reach the harness before any prompt or tool call is
admitted (connecting or creating the session) as a distinct retryable
reach failure, so a transport blip at the first stage no longer ends a
mutating run; keep post-admission readback/poll/agent failures retried
only on an explicit read-only stage and never replay admitted tool work.
Preserve the true cause when the context is already done (join ctx.Err
with the typed transport error) and report a sanitized unknown provider
error name/status instead of a blanket summary.

Make the isolated format-repair deadline proportional to the stage
timeout (floored, capped and clamped to remaining minus a margin) so a
slow-but-repairable result is recovered without ever extending the stage
deadline; the bounded ladder, value guard, deny-all formatter session,
cumulative usage accounting and no-tool-replay rule are unchanged.

Update docs/model-results.md, docs/pipeline-performance-review.md and the
packaged skill references; add stage, opencode and server fixtures.
This commit is contained in:
2026-10-17 14:51:09 +01:00
parent 5adc961f88
commit 7b72b8f20f
15 changed files with 563 additions and 63 deletions
+14 -9
View File
@@ -20,14 +20,18 @@ Each playbook is *symptom → how to confirm → what to do*.
the model may have done work but no final result was read.
- **Confirm** `inspect --json` shows the category on the failed stage. A request
failure, an active-session poll failure and a final-readback failure all carry this
one category.
one category. A request that failed while the context was still in flight shows
both the sanitized transport detail and `context deadline exceeded`; an execution
error names the sanitized error name/tag and any HTTP status, not a provider body.
- **Do** Treat it as a transport failure, not a task failure. Distinguish a
pre-admission failure (nothing executed) from a post-admission one (tools may have
run). An explicit read-only stage may retry; a stage whose tools include `edit`/
`shell`, or that has no tools block, **never replays admitted work**. Do not re-run
a full agent stage merely to recover a response's formatting. If it recurs, check
the service and harness health (`references/operations.md`); do not weaken the
stage to get past it.
pre-admission reach failure (connecting or creating the session; nothing executed)
from a post-admission one (tools may have run). A pre-admission reach failure
replays nothing, so it is retried automatically within `retries` for any stage; a
post-admission failure is retried only on an explicit read-only stage. A stage
whose tools include `edit`/`shell`, or that has no tools block, **never replays
admitted work**. Do not re-run a full agent stage merely to recover a response's
formatting. If it recurs, check the service and harness health
(`references/operations.md`); do not weaken the stage to get past it.
## Malformed model results
@@ -39,8 +43,9 @@ Each playbook is *symptom → how to confirm → what to do*.
- **Do** Recovery is bounded and work-preserving. A deterministic local pass first
appends missing closers, drops one trailing comma, or inserts the single
comma/colon the parser expected; only if that is ambiguous does one deny-all
formatter request run, with a deadline derived from the payload size and the
attempt's remaining budget. Each path records a `repaired`, `partial` or
formatter request run, with a deadline derived from the payload size, the stage
timeout and the attempt's remaining budget, clamped so it never extends the
stage's own deadline. Each path records a `repaired`, `partial` or
`unrecoverable` status in `format_repairs`; a partial or unrecoverable payload
is never accepted as complete. On an explicit read-only stage a malformed result
may be re-emitted up to `retries`; a stage with `edit`/`shell` or no tools block
@@ -350,7 +350,11 @@ admitted tool-using stage: completed edits and tool side effects are retained an
not undone, so a full retry repeats work. An explicit read-only stage is the one
exception: a malformed result there mutates nothing, so it may be re-emitted up
to `retries` with its `format_repairs` evidence retained, and a post-admission
deadline or transport failure may be retried. A stage whose tools include
deadline or transport failure may be retried. A failure to reach the harness
before any prompt or tool call is admitted (connecting, or creating the session)
replays nothing, so it is retried within `retries` for any stage, mutating or not.
A stage whose tools include
`edit`/`shell`, or that has no tools block (the legacy read/glob/grep/edit/shell
bundle), is never replayed. Neither category exposes provider/model bodies or
credentials.
credentials. The isolated formatter's deadline is proportional to the stage
timeout and clamped so it never extends the stage's own deadline.
@@ -80,7 +80,10 @@ specific authorization.
Retained model-stage failures now carry a fixed sanitized category. A strictly
invalid final result (a duplicate nested field, or malformed/ambiguous JSON with a
byte offset) is labeled `FINAL RESULT VALIDATION`; request, V2 active-session poll
and final-readback failures are labeled `HARNESS TRANSPORT`. A validation failure
and final-readback failures are labeled `HARNESS TRANSPORT`. A pre-admission
request failure replays nothing and is retried for any stage; a post-admission
failure is retried only on an explicit read-only stage (see the 2026-10-17 section
below). A validation failure
preserves the admitted session, transcript and evidence and performs no second tool
execution. Confirmed ordinary-endpoint failures on 2026-10-11: an all-history
readback of exactly 262144 bytes of incomplete JSON (`invalid agent messages`), a
@@ -100,8 +103,9 @@ Source-level, mocked `internal/stage` regression coverage (not live-provider
evidence and not a deployment): malformed final-result recovery now tries a
deterministic local pass first (append missing closers, drop one trailing comma,
or insert the single comma/colon the parser expected), then at most one deny-all
formatter request whose deadline is derived from the payload size and the
attempt's remaining budget rather than a fixed 30-second constant. Every path
formatter request whose deadline is derived from the payload size, the stage
timeout and the attempt's remaining budget rather than a fixed 30-second
constant. Every path
records `repaired`, `partial` or `unrecoverable` in `format_repairs`; a `partial`
or `unrecoverable` payload is never returned as a completed result, and an
ambiguous payload (an unescaped quote/colon inside a string value) is never
@@ -112,6 +116,26 @@ unchanged. The run-55 `ui_reviewer` payload was retrieved read-only with
ambiguous error class, so it is reported unrecoverable rather than repaired. This
does not update or restart any running server.
## Harness transport reach retry and repair deadline: 2026-10-17
Source-level, mocked `internal/stage`, `internal/opencode` and `internal/server`
regression coverage (not live-provider evidence and not a deployment): the
harness transport path now distinguishes a pre-admission reach failure
(connecting or creating the session) from a post-admission readback/poll/agent
failure under the one `HARNESS TRANSPORT` category. A pre-admission reach failure
replays nothing, so it is retried within `retries` for any stage with a fresh
session and no replayed prompt; a post-admission failure is retried only on an
explicit read-only stage, and an `edit`/`shell`/legacy stage still never replays
admitted work. A context that expires during a request keeps both the sanitized
transport detail (operation/status/exit) and
`errors.Is(err, context.DeadlineExceeded)`; a bare attempt-boundary deadline is
not treated as a reach failure and stays terminal for a mutating stage. An
unrecognized provider execution-error name is reported as a bounded, sanitized
identifier plus any HTTP status. The isolated formatter deadline is now
proportional to the stage timeout (floored, capped, and clamped to
`remaining - margin` so it can never extend the stage/attempt deadline). These are
mocked fixtures; a deployed server is not updated by this change.
## Failure-handling source changes: 2026-10-15
Source-level, mocked `internal/stage` and `internal/server` regression coverage