From 6088e6eb52303f8254b06554bcb15831cf35551a Mon Sep 17 00:00:00 2001 From: Paul Kompfner Date: Fri, 6 Mar 2026 17:25:07 -0500 Subject: [PATCH] Make budget_tokens optional in AnthropicThinkingConfig budget_tokens is required when type is "enabled" and rejected when type is "disabled" (this is validated by the server) --- src/pipecat/services/anthropic/llm.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pipecat/services/anthropic/llm.py b/src/pipecat/services/anthropic/llm.py index 49f7f58b4..a11ec9b3e 100644 --- a/src/pipecat/services/anthropic/llm.py +++ b/src/pipecat/services/anthropic/llm.py @@ -76,16 +76,16 @@ class AnthropicThinkingConfig(BaseModel): type: Type of thinking mode (currently only "enabled" or "disabled"). budget_tokens: Maximum number of tokens for thinking. With today's models, the minimum is 1024. - Only allowed if type is "enabled". + Currently required when type is "enabled", not allowed when "disabled". """ # Why `| str` here? To not break compatibility in case Anthropic adds # more types in the future. type: Literal["enabled", "disabled"] | str - # Why not enforce minimnum of 1024 here? To not break compatibility in - # case Anthropic changes this requirement in the future. - budget_tokens: int + # No client-side validation on budget_tokens — we let the server + # enforce the rules so we stay forward-compatible if they change. + budget_tokens: Optional[int] = None @dataclass