diff --git a/internal/llm/provider/anthropic.go b/internal/llm/provider/anthropic.go index 380d0e3083786b628d726a3310c01fd817f237fe..8e8e3237f55d58fa995d15baf60400a485ec95a2 100644 --- a/internal/llm/provider/anthropic.go +++ b/internal/llm/provider/anthropic.go @@ -438,7 +438,8 @@ func (a *anthropicClient) shouldRetry(attempts int, err error) (bool, int64, err func (a *anthropicClient) handleContextLimitError(apiErr *anthropic.Error) (int, bool) { // Parse error message like: "input length and max_tokens exceed context limit: 154978 + 50000 > 200000" errorMsg := apiErr.Error() - re := regexp.MustCompile(`input length and max_tokens exceed context limit: (\d+) \+ (\d+) > (\d+)`) + + re := regexp.MustCompile("input length and `max_tokens` exceed context limit: (\\d+) \\+ (\\d+) > (\\d+)") matches := re.FindStringSubmatch(errorMsg) if len(matches) != 4 {