-
-
Notifications
You must be signed in to change notification settings - Fork 305
Open
Labels
bugSomething isn't workingSomething isn't workinghelp wantedExtra attention is neededExtra attention is neededtriaged
Description
Basic checks
- I searched existing issues - this hasn't been reported
- I can reproduce this consistently
- This is a RubyLLM bug, not my application code
What's broken?
Hey, folks,
I think I've discovered a bug, unless, of course, I'm not missing something. I think RubyLLM won't retry POST requets, because it doesn't set the methods option on faraday-retry and also doesn't provide a way to set it.
- The faraday-retry middleware accepts a methods option and falls back to
%i[delete get head options put], if no methods are given. - RubyLLM doesn't set the
methodsoption, hence only idempotent methods are retried,postrequests are never retried.
I'm hitting this on Anthropic's POST v1/messages endpoint. Tagging @tpaulshippy here as well, as I know he uses Anthropic heavily as well.
How to reproduce
-
RubyLLM has a default config for automatic retries, so need for additional configuration regarding retries. Set Anthropic as provider or make sure that the
askmethod will issue a POST request. -
Stub an error response and see, that requests are not retried. Something like:
context "when Anthropic API returns an error" do
before do
# Stub the Anthropic Messages API endpoint with proper error format
stub_request(:post, "https://api.anthropic.com/v1/messages")
.to_return(
status: 500,
body: {
type: "error",
error: {
type: "api_error",
message: "An unexpected error has occurred internal to Anthropic's systems."
},
request_id: "req_018EeWyXxfu5pfWkrYcMdjWG"
}.to_json,
headers: {
"Content-Type" => "application/json",
"request-id" => "req_018EeWyXxfu5pfWkrYcMdjWG"
}
)
end
it "retries the request" do
RubyLLM.ask "Something"
expect(WebMock).to have_requested(:post, "https://api.anthropic.com/v1/messages").times(4) # 1 call + 3 (default) retries, this should fail
end
endFailure/Error: expect(WebMock).to have_requested(:post, "https://api.anthropic.com/v1/messages").times(4)
The request POST https://api.anthropic.com/v1/messages was expected to execute 4 times but it executed 1 timeExpected behavior
POST requests should be retried.
What actually happened
POST requests are not retried.
Environment
- RubyLLM 1.6
Leteyski
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinghelp wantedExtra attention is neededExtra attention is neededtriaged