fix(llm): normalize OpenAI strict schemas#187
Merged
Conversation
Normalize schemas before sending OpenAI strict JSON Schema or tool-call requests: seal objects, require all properties, strip unsupported validation keywords, fold trivial refs, and inline anyOf property refs that OpenAI rejects in the browser action union. Release-Impact: patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
json_schemaresponse_format or strict tool-call transport.allOfrefs, and rewritedefinitionsrefs to$defsrefs.anyOfvariants because the live OpenAI API rejects the browser action union whenfind_elementsis only a nested$defsref.Testing
cargo test -p browser-use-llm openai_json_schema_mode_makes_schema_strict -- --nocapturecargo test -p browser-use-llmcargo fmt --all -- --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspacepython3 scripts/release-version.py --checkpython3 scripts/release-version.py --self-testpython3 scripts/upstream-drift.py --self-testpython3 scripts/upstream-drift.pygit -c core.fsmonitor=false diff --checkinitialize,ping,tools/list,browser_use_statebrowser_use_agentwithgpt-4.1-mini: completed in one step with exact done text andall_errors: []prompt-onlyagent smoke: completed in one step with exact done text andall_errors: []tool-callagent smoke: completed in one step with exact done text andall_errors: []Release-Impact: patch