Repository navigation
Description
Browser Use Version
d2fcda5 (0.13.8)
Bug Description
SchemaOptimizer.create_optimized_json_schema inlines every $ref and drops $defs. It does that by walking the schema and dispatching on JSON Schema keyword names, but it walks into properties maps too, and the keys in there are the user's field names, not keywords.
So a model field named description lands in the elif key == 'description': branch (browser_use/llm/schema.py:57), which copies the value through verbatim and never recurses. If that field is a nested model, its {"$ref": "#/$defs/..."} is never inlined, and $defs has already been stripped, so the schema we hand the provider points at nothing.
This is the same bug #2324 fixed for a field named title by adding the in_properties flag. description was missed.
Reproduce with no API key:
from pydantic import BaseModel
from browser_use.llm.schema import SchemaOptimizer
class Details(BaseModel):
summary: str
class Article(BaseModel):
headline: str
description: Details
print(SchemaOptimizer.create_optimized_json_schema(Article))On d2fcda5:
{'properties': {'headline': {'type': 'string'},
'description': {'$ref': '#/$defs/Details'}},
'required': ['headline', 'description'],
'type': 'object',
'additionalProperties': False}
#/$defs/Details is not in the document, and jsonschema 4.26.0 refuses it:
_WrappedReferencingError: PointerToNowhere: '/$defs/Details' does not exist within
{'properties': {'headline': {'type': 'string'}, 'description': {'$ref': '#/$defs/Details'}}, ...}
Same thing through the agent path with Agent(output_model_schema=Article) / Tools(output_model=Article):
DANGLING /properties/action/items/anyOf[0]/properties/done/properties/data/properties/description/$ref -> #/$defs/Details
That dict goes straight into response_format with strict: True in ChatOpenAI (browser_use/llm/openai/chat.py:224-232), into input_schema on the Anthropic ToolParam, and into the Bedrock/Gemini/Groq tool specs.
A field named properties is affected more mildly: in_properties=True leaks into the field's own schema, so it keeps its metadata title.
I checked every other JSON Schema keyword that has a branch in that loop. Fields named title, type, required, items, anyOf, default, pattern, minimum, maximum and minItems all come out correct today. It is only description and properties.
Failing Python Code
from pydantic import BaseModel
from browser_use import Agent
from browser_use.llm import ChatOpenAI
class Details(BaseModel):
summary: str
bullets: list[str]
class Article(BaseModel):
headline: str
description: Details
agent = Agent(
task='open example.com and summarise it',
llm=ChatOpenAI(model='gpt-4.1-mini'),
output_model_schema=Article,
)
# the done-action schema sent to the model contains "$ref": "#/$defs/Details" with no $defsLLM Model
any provider that uses structured output
Operating System & Browser Versions
macOS 15 (the bug is in a pure function, no browser involved)
Activity
aniketwaghh commentedon Aug 30, 2026
Correcting two things in this report after a fuller sweep on d2fcda5.
I said it was
descriptionandproperties.propertiesis fine - I claimed it holds on to a metadatatitleand it does not.I also missed two that are worse.
additionalPropertiesand$defsare inskip_fields, so a field with either name is skipped and vanishes from the schema entirely, rather than being left with a dangling pointer. Every keyword as a field name:The dropped ones fail silently, which is the worse half of this - nothing raises, the field is simply never offered to the model.
#5605 fixes all three, because the
in_propertiescheck sits ahead ofskip_fields.fix(llm): preserve schema-keyword field names (#5605)