fix(agent): handle upstream provider failures#2221
Merged
Conversation
fbed6dd to
268bb9d
Compare
Contributor
Prompt To Fix All With AIFix the following 3 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 3
packages/agent/src/server/question-relay.test.ts:98-105
**Missing `429` test case despite explicit regex support**
The PR description highlights handling `API Error: 429` as a key scenario, and `UPSTREAM_PROVIDER_ERROR_STATUS_PATTERN` explicitly includes `429` in the alternation — but the parameterised test never exercises it. If the regex alternation for `429` were accidentally dropped, this suite would not catch the regression.
### Issue 2 of 3
packages/agent/src/adapters/codex/codex-agent.test.ts:309-340
**Non-parameterised test; `agent_error` pass-through path not covered**
Per the project's simplicity rules, parameterised tests are always preferred. This test only exercises the 529 classification path through `classifyPromptError`. The `agent_error` branch (where the original error is returned unchanged) goes untested, and additional status codes like 429 or 503 are not covered. Converting to `it.each` would cover all meaningful inputs, including the pass-through branch, with no extra boilerplate.
### Issue 3 of 3
packages/agent/src/server/question-relay.test.ts:39-40
`UPSTREAM_PROVIDER_FAILURE_MESSAGE` is defined identically in `agent-server.ts` (line 72) and re-declared here, violating OnceAndOnlyOnce. Exporting it from `agent-server.ts` (or moving it to `error-classification.ts`) and importing it in the test keeps the two in sync automatically.
```suggestion
import { UPSTREAM_PROVIDER_FAILURE_MESSAGE } from "../server/agent-server";
```
Reviews (1): Last reviewed commit: "fix(agent): handle upstream provider fai..." | Re-trigger Greptile |
skoob13
approved these changes
May 19, 2026
268bb9d to
18e1e15
Compare
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.
Problem
Cloud task failures can surface raw upstream provider error payloads when the agent receives retryable provider failures. That makes task run errors harder to read and can leak noisy JSON into downstream notifications.
Changes
Classify retryable upstream provider HTTP failures from the SDK result messages when they include
API Error: 429orAPI Error: 5xx