Skip to content

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

Merge branch 'main' into feature/support-reasoning-models

Anish Hiranandanif5833ad53d7b
diff --cc browser_use/agent/service.py
index abddb72ec,f4370cf84..305935538
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@@ -968,9 -1148,21 +1150,21 @@@ class Agent(Generic[Context])
if not self.settings.planner_llm:
return None
- # Create planner message history using full message history
+ # Get current state to filter actions by page
+ state = await self.browser_context.get_state()
+
+ # Get all standard actions (no filter) and page-specific actions
+ standard_actions = self.controller.registry.get_prompt_description() # No page = system prompt actions
+ page_actions = self.controller.registry.get_prompt_description(state.page) # Page-specific actions
+
+ # Combine both for the planner
+ all_actions = standard_actions
+ if page_actions:
+ all_actions += '\n' + page_actions
+
+ # Create planner message history using full message history with all available actions
planner_messages = [
- PlannerPrompt(self.controller.registry.get_prompt_description()).get_system_message(self.settings.is_planner_reasoning),
- PlannerPrompt(all_actions).get_system_message(),
++ PlannerPrompt(all_actions).get_system_message(self.settings.is_planner_reasoning),
*self._message_manager.get_messages()[1:], # Use full message history except the first
]