Skip to content
This repository was archived by the owner on Sep 18, 2025. It is now read-only.

Commit 50d8fbb

Browse files
author
adamdottv
committed
fix(anthropic): increase max retries
1 parent b8383f5 commit 50d8fbb

File tree

1 file changed

+33
-25
lines changed

1 file changed

+33
-25
lines changed

internal/llm/provider/anthropic.go

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,25 @@ func (a *anthropicProvider) SendMessages(ctx context.Context, messages []message
6868
anthropicMessages := a.convertToAnthropicMessages(messages)
6969
anthropicTools := a.convertToAnthropicTools(tools)
7070

71-
response, err := a.client.Messages.New(ctx, anthropic.MessageNewParams{
72-
Model: anthropic.Model(a.model.APIModel),
73-
MaxTokens: a.maxTokens,
74-
Temperature: anthropic.Float(0),
75-
Messages: anthropicMessages,
76-
Tools: anthropicTools,
77-
System: []anthropic.TextBlockParam{
78-
{
79-
Text: a.systemMessage,
80-
CacheControl: anthropic.CacheControlEphemeralParam{
81-
Type: "ephemeral",
71+
response, err := a.client.Messages.New(
72+
ctx,
73+
anthropic.MessageNewParams{
74+
Model: anthropic.Model(a.model.APIModel),
75+
MaxTokens: a.maxTokens,
76+
Temperature: anthropic.Float(0),
77+
Messages: anthropicMessages,
78+
Tools: anthropicTools,
79+
System: []anthropic.TextBlockParam{
80+
{
81+
Text: a.systemMessage,
82+
CacheControl: anthropic.CacheControlEphemeralParam{
83+
Type: "ephemeral",
84+
},
8285
},
8386
},
8487
},
85-
})
88+
option.WithMaxRetries(8),
89+
)
8690
if err != nil {
8791
return nil, err
8892
}
@@ -121,22 +125,26 @@ func (a *anthropicProvider) StreamResponse(ctx context.Context, messages []messa
121125
temperature = anthropic.Float(1)
122126
}
123127

124-
stream := a.client.Messages.NewStreaming(ctx, anthropic.MessageNewParams{
125-
Model: anthropic.Model(a.model.APIModel),
126-
MaxTokens: a.maxTokens,
127-
Temperature: temperature,
128-
Messages: anthropicMessages,
129-
Tools: anthropicTools,
130-
Thinking: thinkingParam,
131-
System: []anthropic.TextBlockParam{
132-
{
133-
Text: a.systemMessage,
134-
CacheControl: anthropic.CacheControlEphemeralParam{
135-
Type: "ephemeral",
128+
stream := a.client.Messages.NewStreaming(
129+
ctx,
130+
anthropic.MessageNewParams{
131+
Model: anthropic.Model(a.model.APIModel),
132+
MaxTokens: a.maxTokens,
133+
Temperature: temperature,
134+
Messages: anthropicMessages,
135+
Tools: anthropicTools,
136+
Thinking: thinkingParam,
137+
System: []anthropic.TextBlockParam{
138+
{
139+
Text: a.systemMessage,
140+
CacheControl: anthropic.CacheControlEphemeralParam{
141+
Type: "ephemeral",
142+
},
136143
},
137144
},
138145
},
139-
})
146+
option.WithMaxRetries(8),
147+
)
140148

141149
eventChan := make(chan ProviderEvent)
142150

0 commit comments

Comments
 (0)