Skip to content

fix(llm): preserve schema-keyword field names - #5605

Merged
MagMueller merged 2 commits into
mainfrom
agency/fix-schema-keyword-fields
Aug 30, 2026
Merged

MagMueller merged 2 commits into
mainfrom
agency/fix-schema-keyword-fields

Conversation

@MagMueller

@MagMueller MagMueller commented Aug 30, 2026 •

Copy link
Copy Markdown
Collaborator

What

Treat keys inside a schema properties map as user field names before applying schema-keyword rules. This keeps fields named description or properties from retaining dangling $ref values.

Fixes #5603

Test

  • uv run pytest -q tests/ci/models/test_llm_schema_optimizer.py
  • uv run pre-commit run --files browser_use/llm/schema.py tests/ci/models/test_llm_schema_optimizer.py

Summary by cubic

Fixes schema optimization so user fields named description or properties no longer keep dangling $ref values.

  • Treats keys inside a properties map as field names before applying schema-keyword rules.
  • Simplifies title skipping, which now only applies outside properties.
  • Adds coverage for nested and aliased fields named after schema keywords.

Written for commit b250709. Summary will update on new commits.

Review in cubic

@github-actions

github-actions Bot commented Aug 30, 2026 •

Copy link
Copy Markdown

Agent Task Evaluation Results: 2/2 (100%)

View detailed results
Task Result Reason
amazon_laptop ✅ Pass Skipped - API key not available (fork PR or missing secret)
browser_use_pip ✅ Pass Skipped - API key not available (fork PR or missing secret)

Check the evaluate-tasks job for detailed task execution logs.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

@aniketwaghh

Copy link
Copy Markdown
Contributor

This is cleaner than what I had in #5604 - dropping and not in_properties from the title branch is the right call once the short-circuit is above it.

One thing worth flagging, because I got two details wrong in #5603 and only caught them re-checking against d2fcda5.

properties is not actually affected. I said it keeps a metadata title and it doesn't.

But there are two names I never mentioned that are worse than the one I did. additionalProperties and $defs are both in skip_fields, so as user field names they hit that continue and the field disappears from the schema altogether. Sweeping all 22 keywords as a field name on d2fcda5:

additionalProperties   DROPPED
$defs                  DROPPED
description            dangling $ref
properties             ok
title                  ok
(+ type, items, anyOf, required, default, pattern, minimum,
   maximum, minItems, enum, format, allOf, oneOf, const,
   examples, nullable - all ok)

The dropped ones are quieter than the dangling ref: no error anywhere, the model just never sees the field and can't fill it.

Your patch fixes both, since the in_properties check runs ahead of skip_fields. I applied it locally and all 22 come out intact, so there is nothing to change here. Might be worth a case so it can't regress:

class Details(BaseModel):
	summary: str

class M(BaseModel):
	headline: str
	additionalProperties: Details

# d2fcda5: 'additionalProperties' is absent from the optimized schema entirely

@MagMueller
MagMueller force-pushed the agency/fix-schema-keyword-fields branch from 4a5c0a8 to c48b1c9 Compare August 30, 2026 21:49

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: SchemaOptimizer leaves a dangling $ref when a model field is named "description"

2 participants