Skip to content

fix(agent): handle upstream provider failures#2221

Merged
tatoalo merged 1 commit into
mainfrom
chore/slack-upstream-provider-errors
May 19, 2026
Merged

fix(agent): handle upstream provider failures#2221
tatoalo merged 1 commit into
mainfrom
chore/slack-upstream-provider-errors

Conversation

@tatoalo
Copy link
Copy Markdown
Contributor

@tatoalo tatoalo commented May 19, 2026

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: 429 or API Error: 5xx

@tatoalo tatoalo self-assigned this May 19, 2026
@tatoalo tatoalo force-pushed the chore/slack-upstream-provider-errors branch from fbed6dd to 268bb9d Compare May 19, 2026 15:09
@tatoalo tatoalo marked this pull request as ready for review May 19, 2026 15:11
@tatoalo tatoalo requested a review from skoob13 May 19, 2026 15:12
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 19, 2026

Prompt To Fix All With AI
Fix 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

Comment thread packages/agent/src/server/question-relay.test.ts
Comment thread packages/agent/src/adapters/codex/codex-agent.test.ts Outdated
Comment thread packages/agent/src/server/question-relay.test.ts Outdated
@tatoalo tatoalo force-pushed the chore/slack-upstream-provider-errors branch from 268bb9d to 18e1e15 Compare May 19, 2026 15:17
@tatoalo tatoalo enabled auto-merge (squash) May 19, 2026 15:19
@tatoalo tatoalo merged commit 50cf45d into main May 19, 2026
15 checks passed
@tatoalo tatoalo deleted the chore/slack-upstream-provider-errors branch May 19, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants