Stop a run when the model provider refuses for balance or quota

Ten runs each burned five visits in seconds on "OpenCode agent reported an
execution error": the provider answered HTTP 402 provider.quota and the
classifier read neither field. That refusal is now its own error with fixed
text, is not retried inside the stage, and ends the run instead of
following the error edge.
This commit is contained in:
2026-11-11 10:10:40 +00:00
parent 0392f57b08
commit 16643b9f1b
4 changed files with 52 additions and 4 deletions
+6
View File
@@ -16,6 +16,7 @@ import (
"git.a-wan.net/alan/pipelines/internal/filediff"
"git.a-wan.net/alan/pipelines/internal/harness"
"git.a-wan.net/alan/pipelines/internal/opencode"
"git.a-wan.net/alan/pipelines/internal/pipeline"
"git.a-wan.net/alan/pipelines/internal/protocol"
"git.a-wan.net/alan/pipelines/internal/stage"
@@ -2106,6 +2107,11 @@ func (r *runner) runLoop(ctx context.Context, id int64, graph protocol.Graph, na
step.Transcript = stage.RetainSession(step.Transcript, stageSession)
}
step.Target = def.Edges[step.Outcome]
if errors.Is(err, opencode.ErrProviderQuota) {
// Another visit would be refused the same way: stop the run on the
// provider's refusal instead of following the error edge again.
step.Target = protocol.FailureEnd
}
if errors.Is(err, stage.ErrStageCleanup) {
// Retain the partial evidence without pretending that the agent stopped.
step.Status, step.Outcome, step.Target = "running", "", ""