From 9a2d0c2db6106055baa00efae3f2e1f10bc24ccf Mon Sep 17 00:00:00 2001 From: Kujtim Hoxha Date: Sat, 5 Jul 2025 19:09:34 +0200 Subject: [PATCH] chore: fix max tokens limit --- internal/llm/provider/anthropic.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 {