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:
@@ -81,6 +81,15 @@ func ExecutionError(data json.RawMessage) error {
|
||||
}
|
||||
safeNames := map[string]bool{"APIError": true, "ProviderAuthError": true, "ContextOverflowError": true, "MessageAbortedError": true, "OutputLengthError": true, "UnknownError": true, "ServiceUnavailableError": true}
|
||||
if !safeNames[name] {
|
||||
// An unrecognized provider error name is still reported, but only as a
|
||||
// bounded, safe identifier plus any HTTP status. No provider body,
|
||||
// message, prompt or credential is copied.
|
||||
if safe := sanitizedExecutionName(name); safe != "" {
|
||||
if failure.Data.StatusCode >= 400 && failure.Data.StatusCode <= 599 {
|
||||
return fmt.Errorf("OpenCode agent reported an execution error: %s (HTTP %d)", safe, failure.Data.StatusCode)
|
||||
}
|
||||
return fmt.Errorf("OpenCode agent reported an execution error: %s", safe)
|
||||
}
|
||||
return fmt.Errorf("OpenCode agent reported an execution error")
|
||||
}
|
||||
if failure.Data.StatusCode >= 400 && failure.Data.StatusCode <= 599 {
|
||||
@@ -88,3 +97,23 @@ func ExecutionError(data json.RawMessage) error {
|
||||
}
|
||||
return fmt.Errorf("OpenCode agent execution error: %s", name)
|
||||
}
|
||||
|
||||
// sanitizedExecutionName reduces an unknown provider error name/tag to a
|
||||
// bounded, safe identifier so the diagnostic can name the failure shape without
|
||||
// copying an arbitrary message, prompt or credential. A name containing any
|
||||
// other byte returns empty and is reported as a generic execution error.
|
||||
func sanitizedExecutionName(name string) string {
|
||||
if len(name) > 64 {
|
||||
name = name[:64]
|
||||
}
|
||||
var b strings.Builder
|
||||
for _, r := range name {
|
||||
switch {
|
||||
case r >= 'a' && r <= 'z', r >= 'A' && r <= 'Z', r >= '0' && r <= '9', r == '_', r == '.', r == '-':
|
||||
b.WriteRune(r)
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
|
||||
@@ -90,3 +90,26 @@ func TestNativeStructuredFailureIsClearAndDoesNotReplayGeneration(t *testing.T)
|
||||
t.Fatal("wait failure discarded provider response", err, string(retained))
|
||||
}
|
||||
}
|
||||
|
||||
// TestExecutionErrorReportsSanitizedNameAndStatusWithoutBody proves an
|
||||
// unrecognized provider error name is reported as a bounded, safe identifier
|
||||
// plus any HTTP status instead of a blanket summary, while no provider message,
|
||||
// prompt or credential is copied and known names keep their exact wording.
|
||||
func TestExecutionErrorReportsSanitizedNameAndStatusWithoutBody(t *testing.T) {
|
||||
err := ExecutionError(json.RawMessage(`{"name":"TotallyUnknownError","data":{"statusCode":502,"message":"secret provider body"}}`))
|
||||
if err == nil || !strings.Contains(err.Error(), "TotallyUnknownError") || !strings.Contains(err.Error(), "HTTP 502") {
|
||||
t.Fatalf("unknown error name/status not reported: %v", err)
|
||||
}
|
||||
if strings.Contains(err.Error(), "secret provider body") {
|
||||
t.Fatalf("diagnostic leaked the provider body: %v", err)
|
||||
}
|
||||
if err := ExecutionError(json.RawMessage(`{"_tag":"SomeTagError"}`)); err == nil || !strings.Contains(err.Error(), "SomeTagError") {
|
||||
t.Fatalf("unknown tag not reported: %v", err)
|
||||
}
|
||||
if err := ExecutionError(json.RawMessage(`{"name":"Injected Error: Bearer secret-token"}`)); err == nil || strings.Contains(err.Error(), "secret-token") || strings.Contains(err.Error(), "Bearer") || err.Error() != "OpenCode agent reported an execution error" {
|
||||
t.Fatalf("unsafe name was copied into the diagnostic: %v", err)
|
||||
}
|
||||
if err := ExecutionError(json.RawMessage(`{"name":"APIError","data":{"statusCode":500}}`)); err == nil || !strings.Contains(err.Error(), "APIError (HTTP 500)") {
|
||||
t.Fatalf("known safe name changed: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user