Skip to content

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

Explain new extended planner system prompt feature in docs

mathisarends-viadee99ea9882be25
diff --git a/browser_use/agent/prompts.py b/browser_use/agent/prompts.py
index c032cfeca..9a1836321 100644
--- a/browser_use/agent/prompts.py
+++ b/browser_use/agent/prompts.py
@@ -154,7 +154,7 @@ class PlannerPrompt(SystemPrompt):
SystemMessage or HumanMessage depending on is_planner_reasoning
"""
- system_prompt = """
+ planner_prompt_text = """
You are a planning agent that helps break down tasks into smaller steps and reason about the current state.
Your role is to:
1. Analyze the current state and history
@@ -182,9 +182,9 @@ Keep your responses concise and focused on actionable insights.
"""
if extended_planner_system_prompt:
- system_prompt += f'\n{extended_planner_system_prompt}'
+ planner_prompt_text += f'\n{extended_planner_system_prompt}'
if is_planner_reasoning:
- return HumanMessage(content=system_prompt)
+ return HumanMessage(content=planner_prompt_text)
else:
- return SystemMessage(content=system_prompt)
+ return SystemMessage(content=planner_prompt_text)
diff --git a/docs/customize/system-prompt.mdx b/docs/customize/system-prompt.mdx
index ef7b5343a..ac73526ce 100644
--- a/docs/customize/system-prompt.mdx
+++ b/docs/customize/system-prompt.mdx
@@ -22,21 +22,10 @@ You can customize the system prompt in two ways:
To add additional instructions to the default system prompt:
```python
-from browser_use import Agent
-from langchain_openai import ChatOpenAI
-
-# Add your custom instructions
extend_system_message = """
REMEMBER the most important RULE:
ALWAYS open first a new tab and go first to url wikipedia.com no matter the task!!!
"""
-
-# Create agent with extended system prompt
-agent = Agent(
- task="Your task here",
- llm=ChatOpenAI(model='gpt-4'),
- extend_system_message=extend_system_message
-)
```
### Override System Prompt
@@ -64,3 +53,25 @@ agent = Agent(
override_system_message=override_system_message
)
```
+
+### Extend Planner System Prompt
+
+You can customize the behavior of the planning agent by extending its system prompt:
+
+```python
+extend_planner_system_message = """
+PRIORITIZE gathering information before taking any action.
+Always suggest exploring multiple options before making a decision.
+"""
+
+# Create agent with extended planner system prompt
+llm = ChatOpenAI(model='gpt-4o')
+planner_llm = ChatOpenAI(model='gpt-4o-mini')
+
+agent = Agent(
+ task="Your task here",
+ llm=llm,
+ planner_llm=planner_llm,
+ extend_planner_system_message=extend_planner_system_message
+)
+```