Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

fix temperature for reasoning models

Magnus Müllerd695a5692396
diff --git a/browser_use/llm/openai/chat.py b/browser_use/llm/openai/chat.py
index edfb75d7a..4883478b1 100644
--- a/browser_use/llm/openai/chat.py
+++ b/browser_use/llm/openai/chat.py
@@ -20,16 +20,6 @@ from browser_use.llm.views import ChatInvokeCompletion, ChatInvokeUsage
T = TypeVar('T', bound=BaseModel)
ReasoningModels: list[ChatModel | str] = ['o4-mini', 'o3', 'o3-mini', 'o1', 'o1-pro', 'o3-pro']
-UnsupportedReasoningParams: list[str] = [
- 'temperature',
- 'frequency_penalty',
- 'top_p',
- 'presence_penalty',
- 'logprobs',
- 'top_logprobs',
- 'logit_bias',
- 'max_tokens',
-]
@dataclass
@@ -172,8 +162,8 @@ class ChatOpenAI(BaseChatModel):
if self.model in ReasoningModels:
model_params['reasoning_effort'] = self.reasoning_effort
- for param in UnsupportedReasoningParams:
- model_params.pop(param, None)
+ model_params['temperature'] = 1
+ model_params['frequency_penalty'] = 0
if output_format is None:
# Return string response
diff --git a/examples/simple.py b/examples/simple.py
index f9bfe8132..3204f280e 100644
--- a/examples/simple.py
+++ b/examples/simple.py
@@ -10,21 +10,39 @@ from dotenv import load_dotenv
load_dotenv()
+try:
+ from lmnr import Instruments, Laminar
+
+ Laminar.initialize(project_api_key=os.getenv('LMNR_PROJECT_API_KEY'), disabled_instruments={Instruments.BROWSER_USE})
+except Exception:
+ print('Error initializing Laminar')
+ pass
from browser_use import Agent
# Initialize the model
llm = ChatOpenAI(
- model='gpt-4.1-mini',
+ model='o4-mini',
+ temperature=0.2,
)
+# Optimized task with more specific instructions
+task = """
+Navigate to the Qatar Airways homepage and search for flights from Doha to Paris departing in the upcoming week; then list the available fare classes and prices.
+Only use https://www.qatarairways.com/ to achieve the task. Don't go to any other site. The task is achievable with just navigation from this site."""
-task = 'Find the founders of browser-use'
-agent = Agent(task=task, llm=llm)
+task = ' call done directly and repeat the word "New" 100 times'
+# Performance optimizations
+agent = Agent(
+ task=task,
+ llm=llm,
+)
async def main():
- await agent.run()
+ history = await agent.run(max_steps=10)
+ # token usage
+ print(history.usage)
if __name__ == '__main__':