-
Notifications
You must be signed in to change notification settings - Fork 3.3k
fix(anthropic): token limits for streaming with tool calls #3084
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile OverviewGreptile SummaryThis PR fixes token limit handling for Anthropic provider tool calls to prevent SDK timeout errors. Key Changes:
Context: Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant AnthropicProvider
participant AnthropicSDK
participant Tools
Note over Client,AnthropicProvider: Request with stream=true, tools present
Client->>AnthropicProvider: execute(request)
alt shouldStreamToolCalls = false
Note over AnthropicProvider: Non-streaming tool execution path
AnthropicProvider->>AnthropicProvider: Create nonStreamingMaxTokens<br/>(uses default: 8192 instead of max: 64000)
AnthropicProvider->>AnthropicProvider: Create intermediatePayload with<br/>non-streaming token limit
loop Tool execution iterations
AnthropicProvider->>AnthropicSDK: messages.create(intermediatePayload)
Note over AnthropicSDK: Non-streaming call avoids<br/>SDK timeout (>10 min limit)
AnthropicSDK-->>AnthropicProvider: response with tool_use
AnthropicProvider->>Tools: Execute tool calls
Tools-->>AnthropicProvider: Tool results
AnthropicProvider->>AnthropicProvider: Update messages with results
end
AnthropicProvider-->>Client: Stream final response to client
else shouldStreamToolCalls = true
Note over AnthropicProvider: Regular streaming path
AnthropicProvider->>AnthropicSDK: messages.stream()
AnthropicSDK-->>Client: Stream response
end
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, no comments
|
@cursor review |
|
@cursor review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Summary
Type of Change
Testing
Tested manually
Checklist