Repository navigation
fix(agent-review): fail stalled inference requests sooner; explain environment denials - #15
Merged
Merged
Conversation
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…rding Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…t locally Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…stall test covers the first event and Pi's retries Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes from the
v0.1.0release validation, forv0.1.1. No new permission, input, ceiling, endpoint, harness pin or AWF version: not a breaking change under the release policy.Stalled inference requests (both adapters)
In the validation, keyed reviews took 17 to 19 of the 20 minutes of
harness_timeout_minutes: requests got no response headers for exactly 300 s, were retried, and a later one was answered.Cause: the 300 s is each harness's own default, not AWF's API proxy (which has no such timeout). opencode 2.2.7 waits 300 s for response headers (
headerTimeout) and 900 s for the next event of a stream (chunkTimeout); Pi 1.5.2 waits 300 s for either (httpIdleTimeoutMs). Both retry a timed-out request 3 times (after 2, 4 and 8 s). Pi's count is a setting; opencode's is fixed at 3 timeouts per run.The audit logs of the validation also show that the one slow request that succeeded waited 185 s for its headers, after two requests had been given up at 300 s each: about 13 minutes without any answer at the start of the run. That looks like a service that holds requests, not like single lost requests. No client timeout shortens such a wait, and a shorter one must not end runs that succeed today. So the waits are barely shorter than before, on purpose:
headerTimeoutstays 300 s, now set explicitly;chunkTimeoutgoes from 900 s to 300 s. The chunk timeout also covers the wait between the headers and the first event, where a service that queues an accepted request, or a model that thinks before its first token, is silent as well, so it gets the same value as the header wait. With a fixed 3 retries a run can wait 4 × the timeout; lower values would have ended the validation's reviews instead of letting them finish.httpIdleTimeoutMsgoes from 300 s to 240 s (one setting for headers and for the next chunk), and the retries from 3 to 5. Six attempts exceed the harness time limit, so a run waits for a silent service as long as before.In short: a stream that stops is recovered (in opencode it used to cost 900 s, most of the time limit). A long silence before the first response headers is not fixed: such a review is still slow, and a service that answers nothing for more than about 15 minutes still ends in the "no review" warning. That silence is the service holding requests: it is to be raised with the service's operators (one possible cause, not verified, is a rate limit of the key), not worked around in code; the only setting here that would help is a higher time limit, a raised ceiling and so a breaking change.
Caller-visible: a Pi run that hits stalls makes more requests than before. Each retry counts against
requests_per_hour. One that ends before any response does not count againstmax_turns; whether a stream cut after its headers does was not checked.Tests:
agent-review/tests/test-harness-stall.shruns the pinned harnesses against a local server that stalls (tests/fake_inference.py). Six cases per harness: no response headers; a stream that stops; a slow stream that must not be cut; a request answered only after 185 s; a stream whose first event comes 185 s after its headers; and 1050 s of silence, more than Pi's default of 3 retries can sit out. 12 of 12 cases pass with the real values (and with--fast). The two cases added in review fail against the values they guard: with opencode's chunk timeout at 120 s, the first-event case ends without a review after four attempts of 120 s (exit 1 after 500 s); with Pi's retries at 3, the silence case gives up after four attempts (exit 2 after 976 s). The other ten cases pass there tooThe test executes harness code outside any sandbox, so it stays out of the self-test on purpose (the
adaptersjob only installs the harnesses). Run it locally when an adapter's timeouts or pin change:bash agent-review/tests/test-harness-stall.sh(about 18 minutes), or with--fast(about a minute, every timeout and retry delay divided by 30);opencodeorpiselects one harness. It needsjq,npm,curlandpython3.Message after an environment denial
When the environment refused the keyed
reviewjob (a dispatch from a branch other than the default one, say),publishwarned that "the agent produced no review" and pointed at sandbox logs that do not exist.startedoutput in their first step.publishpasses it, the job's result and thekeyedflag to the newpublish-comment explain, which words the warning from those values alone (no token, nothing from the review).publish. For the keyed job the message names the environment and its protection rules as the usual cause, and says that the key was not used only for that case.resultoutput is unchanged (missing).started_signal_problems).Documentation
publishposts withgithub.token, whose events start no workflow runs, so only webhook-based bots could react.Invariants
None is weakened. Invariant 3 (after the sandbox: no token, fixed shell) and 12 (permissions) are untouched: the new step runs first in the review jobs and writes one constant output;
explainruns inpublishwithout a token. Invariant 13 holds for the new call (/usr/bin/python3 -I -S -B,PATH: /usr/bin:/bin).Evidence
From a separate test caller, through a dispatch-only workflow pinned to commits of this branch (
c366404,80a822a, then430fb19). The commits after430fb19change opencode's chunk timeout (120 s to 300 s), the wording of the "no step" messages, tests and documentation; no live run was repeated for them; run ids are in that repository.reviewfailed with 0 steps; the warning named the environmentagent-reviewand its protection rules (at commitc366404; the wording has since been made exact about a lost runner, which is unit-tested).430fb19(review 39 s, 8 calls, 0.8 to 1.0 s to headers); opencode, run 44069604673 at80a822a(review 111 s, 6 calls, at most 20 s to headers; with a chunk timeout of 120 s, since raised to 300 s); an earlier Pi run, 44068636270 at80a822a(120 s, 9 retries; review 30 s). The service did not stall, so these show no regression; the stall behaviour is shown by the offline test.4ed4519, label path,stub: a PR changing the file the addendum names (run 44067263503) and one replacing it with a symlink to an uncovered path (run 44067652806). Both log "1 rule file(s) and 1 file(s) named by the addendum are their base versions" and post the comment: the reset restores the base file, so the fail-closed post-condition does not fire; it is covered by the offline tests.🤖 Generated with Claude Code
Co-Authored-By: Claude Fable 5.2 noreply@anthropic.com