Add GatewayFailure: the provider not answering is not a tool failing
terminationFor sent every gateway error that was not Refused or Timeout to ToolFailure, because the enum had nowhere else to put it. On 2026-09-22 that was 131 of 318 production runs, and not one of them was a tool failing: 56 were retired model ids, 25 an exhausted Anthropic balance, 45 Groq's free-tier rate limit -- the only one still happening. An operator reading the termination column saw "a tool is broken" for two weeks while the actual answer was "we are not paying for capacity". GatewayFailure is the seventh termination. Rate limited, request rejected, credential refused and unreachable land there; Refused and Deadline keep their own reasons; a non-gateway error is still the tool layer's. A delegation whose subagent died at the gateway now carries that reason up to the parent instead of reading as a tool call that failed. Migration 000016 widens the CHECK that 000006 chose precisely so this would be a migration rather than an ALTER TYPE. Its down folds any GatewayFailure rows back to ToolFailure BEFORE narrowing the constraint, which is the order that works; verified up, down and up again on a scratch database. Existing rows are left as they are -- the trajectory entries still carry the gateway.* code for anyone reclassifying history. The surface wording is the one termination where "try again" is honest advice, since the dominant cause clears within a minute. Full suite run against a real database, including the tests that skip without one. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PJvibeSc1JYXjatankqM1g
This commit is contained in:
@@ -555,6 +555,12 @@ func (m *ModelExecutor) runTools(
|
||||
// a Refused run is one that must not be retried. Flattening them into a single
|
||||
// failure reason would make every one of those distinctions unanswerable from
|
||||
// the trajectory.
|
||||
//
|
||||
// Any other gateway error is GatewayFailure, not ToolFailure. The provider
|
||||
// being rate limited, rejecting the request or refusing the key is not a tool
|
||||
// failing, and calling it one sent two weeks of operators looking for a broken
|
||||
// tool that did not exist. A non-gateway error — a tool the model invented, a
|
||||
// result that could not be encoded — is still the tool layer's.
|
||||
func terminationFor(err error) Termination {
|
||||
var gwErr *gateway.Error
|
||||
if !errors.As(err, &gwErr) {
|
||||
@@ -566,7 +572,7 @@ func terminationFor(err error) Termination {
|
||||
case gateway.CodeTimeout:
|
||||
return TerminationDeadline
|
||||
default:
|
||||
return TerminationToolFailure
|
||||
return TerminationGatewayFailure
|
||||
}
|
||||
}
|
||||
|
||||
@@ -657,6 +663,8 @@ func terminationMessage(t Termination) string {
|
||||
return "the run is waiting on a confirmation"
|
||||
case TerminationToolFailure:
|
||||
return "the run failed"
|
||||
case TerminationGatewayFailure:
|
||||
return "the model provider did not answer"
|
||||
default:
|
||||
return string(t)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user