Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
fix: remove double-counting of reasoning_tokens in OpenAI usage
Chase Xu993a4c1f5b36
diff --git a/browser_use/llm/openai/chat.py b/browser_use/llm/openai/chat.pyindex 8b75eb54c..390df689f 100644--- a/browser_use/llm/openai/chat.py+++ b/browser_use/llm/openai/chat.py@@ -122,13 +122,9 @@ class ChatOpenAI(BaseChatModel):def _get_usage(self, response: ChatCompletion) -> ChatInvokeUsage | None:if response.usage is not None:- completion_tokens = response.usage.completion_tokens- completion_token_details = response.usage.completion_tokens_details- if completion_token_details is not None:- reasoning_tokens = completion_token_details.reasoning_tokens- if reasoning_tokens is not None:- completion_tokens += reasoning_tokens-+ # Note: completion_tokens already includes reasoning_tokens per OpenAI API docs.+ # Unlike Google Gemini where thinking_tokens are reported separately,+ # OpenAI's reasoning_tokens are a subset of completion_tokens.usage = ChatInvokeUsage(prompt_tokens=response.usage.prompt_tokens,prompt_cached_tokens=response.usage.prompt_tokens_details.cached_tokens@@ -137,7 +133,7 @@ class ChatOpenAI(BaseChatModel):prompt_cache_creation_tokens=None,prompt_image_tokens=None,# Completion- completion_tokens=completion_tokens,+ completion_tokens=response.usage.completion_tokens,total_tokens=response.usage.total_tokens,)else: