Skip to content

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

Open
wannT-1/browser-use
#2

Description

@dafyy321-pixel

Browser Use Version

main d8110c5 (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.

Activity

  1. added
    bug
    on Sep 17, 2026
  2. Lucky-Lodhi2004 commented on Sep 17, 2026

    @Lucky-Lodhi2004

    hi! I made a PR for this issue, but it isn't tagged here for some reason. What's wrong here? Am i missing something?

    Here is my PR #5830

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions