Skip to content

fix(openai): report empty structured output#4833

Open
Lubrsy706 wants to merge 1 commit into
browser-use:mainfrom
Lubrsy706:fix/empty-llm-response-diagnostics
Open

fix(openai): report empty structured output#4833
Lubrsy706 wants to merge 1 commit into
browser-use:mainfrom
Lubrsy706:fix/empty-llm-response-diagnostics

Conversation

@Lubrsy706

@Lubrsy706 Lubrsy706 commented May 15, 2026

Copy link
Copy Markdown

Summary

  • detect empty or whitespace-only OpenAI structured-output content before Pydantic JSON parsing
  • raise a ModelProviderError with response diagnostics such as response_id and finish_reason
  • add regression coverage for None, empty string, and whitespace-only content

Why

When OpenAI chat completions return an empty structured-output message, browser-use currently surfaces a low-level Pydantic EOF error. That makes agent failures much harder to diagnose after long runs. This keeps the error at the provider boundary and preserves useful completion metadata.

Fixes #4786.

Tests

  • uv run pytest tests/ci/models/test_llm_openai_structured_output.py
  • uv run ruff format --check browser_use/llm/openai/chat.py tests/ci/models/test_llm_openai_structured_output.py
  • uv run ruff check browser_use/llm/openai/chat.py tests/ci/models/test_llm_openai_structured_output.py
  • git diff --check

Summary by cubic

Detects and reports empty OpenAI structured-output before JSON parsing, returning a clear provider error with diagnostics instead of a pydantic EOF. Adds tests for None, empty, and whitespace-only messages.

  • Bug Fixes
    • Detects None/empty/whitespace message.content and raises ModelProviderError (502) with response_id, finish_reason, and base_url when available.
    • Prevents low-level pydantic EOF errors from leaking past the provider boundary.
    • Adds regression tests covering all empty-content cases.

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

@CLAassistant

CLAassistant commented May 15, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@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

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: Unable to complete task using browser use(GPT5.1/5.2/5.3/5.4)

2 participants