mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-14 12:16:54 +00:00
fix(providers): capture claude-cli stream errors and surface real message (#884)
claude-cli emits API errors (rate limits, usage limits) via stream-json stdout result events, not stderr. Previous code only checked ev.Subtype == "error" and used an empty stderr buffer in the final wrap, so users saw a generic "something went wrong" instead of the real cause. - Add IsError and Error fields to cliStreamEvent to parse both signals - Capture stream error message when FinishReason flips to "error" - Substitute captured message when stderr is empty in cmd.Wait path - Extend gateway rate-limit classifier to recognize "usage limit"
This commit is contained in:
1 parent
96cc940f2b
commit
91d79ce120
2 files changed
+3
-1
No files matched your search
@@ -32,7 +32,7 @@ func formatAgentError(err error) string {
|
||||
}
|
||||
|
||||
// 4. Rate limit
|
||||
if containsAny(lower, "rate limit", "rate_limit", "too many requests", "429", "quota exceeded", "resource_exhausted") {
|
||||
if containsAny(lower, "rate limit", "rate_limit", "too many requests", "429", "quota exceeded", "resource_exhausted", "usage limit") {
|
||||
return "⚠️ API rate limit reached. Please try again later."
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@ type cliStreamEvent struct {
|
||||
Model string `json:"model,omitempty"`
|
||||
CostUSD float64 `json:"cost_usd,omitempty"`
|
||||
Usage *cliUsage `json:"usage,omitempty"`
|
||||
IsError bool `json:"is_error,omitempty"` // true when subtype="error"
|
||||
Error string `json:"error,omitempty"` // error message (may be set when result is empty)
|
||||
}
|
||||
|
||||
// cliStreamMsg wraps content blocks inside an assistant message event.
|
||||
|
||||
Reference in new issue
Block a user