-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Closed
Description
Bug Description
HTTP timeouts from LLM providers (e.g. z.ai) are incorrectly classified as context window errors. This causes:
- Useless history compression triggered on network timeouts
- Misleading message to users: "Context window exceeded. Compressing history and retrying..."
- No actual retry of the failed request
Steps to Reproduce
- Configure picoclaw with z.ai (or any provider with slow/unstable network)
- Send a message that triggers an LLM call
- Wait for HTTP timeout (2 minutes)
- Observe the error in logs:
error=failed to send request: context deadline exceeded (Client.Timeout exceeded while awaiting headers)
Expected Behavior
- Timeout errors should be recognized as network timeouts
- The request should be retried with backoff
- No false "Context window exceeded" message
Actual Behavior
context deadline exceededmatches the broad"context"substring check in the retry loopClient.Timeoutmatches the broad"token"substring check- Error is classified as a context window error
- History compression runs (pointless for a network issue)
- User sees "Context window exceeded" (misleading)
- After compression + retry fails, the error is not retried further
Root Cause
In pkg/agent/loop.go, the context window error detection uses overly broad substring matching:
isContextError := strings.Contains(errMsg, "token") ||
strings.Contains(errMsg, "context") ||
strings.Contains(errMsg, "invalidparameter") ||
strings.Contains(errMsg, "length")"context"matches bothcontext_length_exceededandcontext deadline exceeded"token"matches both token limit errors andClient.Timeout
Fix
PR #681
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels