on main help sign in
chore: fix max tokens limit
9a2d0c2Kujtim Hoxha
internal/llm/provider/anthropic.go+2−1
@@ -438,7 +438,8 @@ func (a *anthropicClient) shouldRetry(attempts int, err error) (bool, int64, err
438func (a *anthropicClient) handleContextLimitError(apiErr *anthropic.Error) (int, bool) {
438func (a *anthropicClient) handleContextLimitError(apiErr *anthropic.Error) (int, bool) {
439 // Parse error message like: "input length and max_tokens exceed context limit: 154978 + 50000 > 200000"
439 // Parse error message like: "input length and max_tokens exceed context limit: 154978 + 50000 > 200000"
440 errorMsg := apiErr.Error()
440 errorMsg := apiErr.Error()
441+
441− re := regexp.MustCompile(`input length and max_tokens exceed context limit: (\d+) \+ (\d+) > (\d+)`)
442+ re := regexp.MustCompile("input length and `max_tokens` exceed context limit: (\\d+) \\+ (\\d+) > (\\d+)")
442 matches := re.FindStringSubmatch(errorMsg)
443 matches := re.FindStringSubmatch(errorMsg)
443
444
444 if len(matches) != 4 {
445 if len(matches) != 4 {