Merge pull request #17534 from colinlin-stripe/colinlin/opus-budget-thinking

[fix] parse <budget:thinking> blocks for opus 4.5
This commit is contained in:
Sameer Kankute 2025-12-05 22:21:05 +05:30 committed by GitHub
commit b6867184a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View file

@ -1071,7 +1071,7 @@ def _parse_content_for_reasoning(
return None, message_text
reasoning_match = re.match(
r"<(?:think|thinking)>(.*?)</(?:think|thinking)>(.*)", message_text, re.DOTALL
r"<(?:think|thinking|budget:thinking)>(.*?)</(?:think|thinking|budget:thinking)>(.*)", message_text, re.DOTALL
)
if reasoning_match:

View file

@ -1043,6 +1043,11 @@ def test_convert_model_response_object():
"I am thinking here",
"The sky is a canvas of blue",
),
(
"<budget:thinking>I am thinking here</budget:thinking>The sky is a canvas of blue",
"I am thinking here",
"The sky is a canvas of blue",
),
("I am a regular response", None, "I am a regular response"),
],
)