Skip to content

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

extract: don't auto-inherit output_model_schema into per-page extraction

MagMueller0a64aaa4d4fd
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index abbdcb23a..eaf2c2c6b 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -362,10 +362,12 @@ class Agent(Generic[Context, AgentStructuredOutput]):
if self.output_model_schema is not None:
self.tools.use_structured_output_action(self.output_model_schema)
- # Extraction schema: explicit param takes priority, otherwise auto-bridge from output_model_schema
+ # Per-page extract uses a schema only when the caller explicitly asks for one.
+ # It must NOT inherit output_model_schema: that describes the final task result
+ # (e.g. {summary, step_results}), which is the wrong shape for a single-page
+ # extraction and, on the browser-use gateway, routes extract into the agent
+ # action protocol and breaks it.
self.extraction_schema = extraction_schema
- if self.extraction_schema is None and self.output_model_schema is not None:
- self.extraction_schema = self.output_model_schema.model_json_schema()
# Core components - task enhancement now has access to output_model_schema from tools
self.task = self._enhance_task_with_schema(task, output_model_schema)
diff --git a/browser_use/beta/service.py b/browser_use/beta/service.py
index 4664a539d..d8f116688 100644
--- a/browser_use/beta/service.py
+++ b/browser_use/beta/service.py
@@ -4365,9 +4365,10 @@ class Agent(Generic[Context, AgentStructuredOutput]):
from browser_use.skills import SkillService
self.skill_service = SkillService(skill_ids=skill_ids)
+ # Per-page extract uses a schema only when explicitly requested; it must not
+ # inherit output_model_schema (the final-result shape), which is wrong for a
+ # single-page extraction and breaks extract on the browser-use gateway.
self.extraction_schema = extraction_schema
- if self.extraction_schema is None and output_model_schema is not None:
- self.extraction_schema = output_model_schema.model_json_schema()
self._fallback_llm = fallback_llm
self._using_fallback_llm = False
self._original_llm = llm