Skip to content

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

feat: add thinking parameter to control agent system prompt

Magnus Müller5905ad949cf6
diff --git a/.github/workflows/eval.yaml b/.github/workflows/eval.yaml
index e9a1cfafe..f1b673334 100644
--- a/.github/workflows/eval.yaml
+++ b/.github/workflows/eval.yaml
@@ -116,6 +116,7 @@ jobs:
DEFAULT_END_INDEX="100"
DEFAULT_EVAL_GROUP="PRTests"
DEFAULT_HEADLESS="true"
+ DEFAULT_THINKING="true"
DEFAULT_MEMORY_INTERVAL="10"
DEFAULT_MAX_ACTIONS_PER_STEP="10"
@@ -147,7 +148,8 @@ jobs:
HEADLESS="${{ github.event.client_payload.script_args.headless }}"
HEADLESS="${HEADLESS:-$DEFAULT_HEADLESS}"
-
+ THINKING="${{ github.event.client_payload.script_args.thinking }}"
+ THINKING="${THINKING:-$DEFAULT_THINKING}"
MEMORY_INTERVAL="${{ github.event.client_payload.script_args.memory_interval }}"
MEMORY_INTERVAL="${MEMORY_INTERVAL:-$DEFAULT_MEMORY_INTERVAL}"
@@ -199,6 +201,7 @@ jobs:
[[ "${{ github.event.client_payload.script_args.include_result }}" == "true" ]] && CMD_ARGS+=("--include-result")
[[ "${{ github.event.client_payload.script_args.highlight_elements }}" == "false" ]] && CMD_ARGS+=("--no-highlight-elements")
[[ "${{ github.event.client_payload.script_args.use_mind2web_judge }}" == "true" ]] && CMD_ARGS+=("--use-mind2web-judge")
+ [[ "$THINKING" == "false" ]] && CMD_ARGS+=("--no-thinking")
# Add optional string parameters
[[ -n "$USER_MESSAGE" ]] && CMD_ARGS+=("--user-message" "$USER_MESSAGE")
diff --git a/eval/service.py b/eval/service.py
index a5057cc28..04f83dba9 100644
--- a/eval/service.py
+++ b/eval/service.py
@@ -1362,6 +1362,7 @@ async def run_agent_with_browser(
validate_output: bool = False,
planner_llm: BaseChatModel | None = None,
planner_interval: int = 1,
+ use_thinking: bool = True,
) -> tuple[AgentHistoryList, str]:
"""Run agent with the browser session"""
# Create controller, optionally with SERP search and structured output
@@ -1385,6 +1386,7 @@ async def run_agent_with_browser(
validate_output=validate_output,
planner_llm=planner_llm,
planner_interval=planner_interval,
+ use_thinking=use_thinking,
source='eval_platform',
calculate_cost=True,
)
@@ -1578,6 +1580,7 @@ async def run_task_with_semaphore(
include_result: bool = False,
highlight_elements: bool = True,
use_mind2web_judge: bool = False,
+ use_thinking: bool = True,
) -> dict:
"""Clean pipeline approach for running tasks"""
task_start_time = time.time()
@@ -1680,6 +1683,7 @@ async def run_task_with_semaphore(
validate_output,
planner_llm,
planner_interval,
+ use_thinking,
),
timeout=1000,
)
@@ -1908,6 +1912,7 @@ async def run_multiple_tasks(
include_result: bool = False,
highlight_elements: bool = True,
use_mind2web_judge: bool = False,
+ use_thinking: bool = True,
) -> dict:
"""
Run multiple tasks in parallel and evaluate results.
@@ -1985,6 +1990,7 @@ async def run_multiple_tasks(
include_result=include_result,
highlight_elements=highlight_elements,
use_mind2web_judge=use_mind2web_judge,
+ use_thinking=use_thinking,
)
for task in tasks_to_run
),
@@ -2253,6 +2259,7 @@ async def run_evaluation_pipeline(
laminar_eval_id: str | None = None,
highlight_elements: bool = True,
use_mind2web_judge: bool = False,
+ use_thinking: bool = True,
) -> dict:
"""
Complete evaluation pipeline that handles Laminar setup and task execution in the same event loop
@@ -2303,6 +2310,7 @@ async def run_evaluation_pipeline(
include_result=include_result,
highlight_elements=highlight_elements,
use_mind2web_judge=use_mind2web_judge,
+ use_thinking=use_thinking,
)
@@ -2366,6 +2374,7 @@ if __name__ == '__main__':
help='Existing Laminar evaluation ID to use (if not provided, a new evaluation will be created)',
)
parser.add_argument('--use-mind2web-judge', action='store_true', help='Use original judge')
+ parser.add_argument('--no-thinking', action='store_true', help='Disable thinking in agent system prompt')
# Single task mode arguments
parser.add_argument('--task-text', type=str, default=None, help='Task description for single task mode')
@@ -2610,6 +2619,7 @@ if __name__ == '__main__':
laminar_eval_id=args.laminar_eval_id,
highlight_elements=args.highlight_elements,
use_mind2web_judge=args.use_mind2web_judge,
+ use_thinking=not args.no_thinking,
)
)
diff --git a/examples/simple.py b/examples/simple.py
index 7c53263e7..cbde69fd8 100644
--- a/examples/simple.py
+++ b/examples/simple.py
@@ -19,12 +19,14 @@ llm = ChatOpenAI(
)
-task = 'Go to google.com/travel/flights and find the cheapest one-way flight from Zurich to San Francisco in 3 weeks.'
+task = 'Open 3 tabs with random wikipedia pages'
agent = Agent(task=task, llm=llm)
async def main():
- await agent.run()
+ history = await agent.run()
+ # token usage
+ print(history.usage)
if __name__ == '__main__':