Bug: schema cleanup removes fields named default, minItems, or min_items

Author: dafyy321-pixelCreated Sep 17, 2026Updated Sep 17, 2026
Labelsbug

Browser Use Version

main d8110c5ff87ccba887aaa726cdb780f2f84bef8d (also present in browser-use 0.13.10)

Bug Description, Steps to Reproduce, Screenshots

Problem

When structured output compatibility flags remove JSON Schema metadata, the cleanup pass also removes user properties whose names match those metadata keys. The resulting schema still lists the removed names in required, while additionalProperties is false, so the schema cannot be satisfied.

Steps to reproduce

  1. Use a Pydantic output model containing fields named default, minItems, or min_items.
  2. Generate its schema with remove_defaults=True and/or remove_min_items=True.
  3. Inspect the generated properties and required entries.

Expected

The compatibility flags remove only Schema metadata (a field default or minItems annotation). User property names with those strings remain present and valid.

Actual

The final recursive cleanup in browser_use/llm/schema.py pops these keys from every dictionary, including properties maps. The names remain in required after strict compatibility is applied, producing an unsatisfiable schema.

This is a follow-up to #5605: its first traversal protects property names, but the later cleanup traversal does not.

Failing Python Code

from pydantic import BaseModel
from browser_use.llm.schema import SchemaOptimizer

class Output(BaseModel):
    default: bool
    minItems: str
    min_items: str
    optional_value: str = 'fallback'

schema = SchemaOptimizer.create_optimized_json_schema(
    Output,
    remove_defaults=True,
    remove_min_items=True,
)

print(schema['properties'].keys())
print(schema['required'])
# Expected: all four fields are in properties.
# Actual on main/0.13.10: default, minItems, and min_items are removed
# while they remain required.

LLM Model

No LLM call; schema generation is local

Operating System & Browser Versions

Python 3.14.6, Pydantic 2.13.4

Full DEBUG Log Output

Not applicable: the failure occurs while building the local JSON schema, before any provider request.