fix(agent): classify upstream prompt failures without replay#1782
Open
fix(agent): classify upstream prompt failures without replay#1782
Conversation
Prompt To Fix All With AIThis is a comment left during a code review.
Path: packages/agent/src/adapters/claude/conversion/sdk-to-acp.ts
Line: 637-644
Comment:
**Exported but unused function**
`isTransientAgentError` is exported here but is not imported or called anywhere in the codebase. The prompt-level retry logic that presumably consumed it was removed in this PR, leaving this as dead code — violating the "no superfluous parts" simplicity rule.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: packages/agent/src/server/question-relay.test.ts
Line: 544-630
Comment:
**Regex patterns in `classifyAgentError` are untested**
Both new tests exercise the structured `data.classification` path — the error fixtures have `error.data.classification` pre-set, so `extractErrorClassification` returns early and `classifyAgentError`'s regex matching is never exercised. The two regexes (`API Error:\s*terminated\b` and `API Error:\s*Connection error\b`) therefore have no coverage. Given the team's preference for parameterised tests, a small `it.each` table directly on `classifyAgentError` (e.g. `"API Error: terminated"` → `upstream_stream_terminated`, `"API Error: Connection error"` → `upstream_connection_error`, arbitrary string → `agent_error`) would close this gap.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(agent): classify upstream prompt fai..." | Re-trigger Greptile |
joshsny
approved these changes
Apr 21, 2026
| if (!result) return "agent_error"; | ||
| const text = result.trim(); | ||
| // Anthropic SDK surfaces an undici fetch abort as "API Error: terminated". | ||
| if (/API Error:\s*terminated\b/i.test(text)) { |
Contributor
There was a problem hiding this comment.
you love a little bit of regex error message matching
|
|
||
| // Prefer the structured `data` carried on RequestError if present. | ||
| const data = (error as { data?: unknown } | undefined)?.data; | ||
| if ( |
Contributor
There was a problem hiding this comment.
this looks like zod would simplify it
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
When the upstream Claude prompt stream terminated unexpectedly, the server surfaced a generic failure that did not preserve the underlying reason. Prompt-level replay also risked rerunning work after execution had already started, which is unsafe for non-idempotent ops
Changes