GPT-OSS via Ollama: Invalid JSON EOF AgentOutput error in browser-use — workarounds?
When I run browser-use 0.5.9 with OpenAI's gpt-oss model through Ollama, the agent fails with "1 validation error for AgentOutput\n Invalid JSON: EOF while parsing a value at line 1 column 0" and returns HTTP 502. The same error also appears with gpt-4.1 and gpt-5 on 0.7.9. Are there workarounds for this?
Originally asked on GitHub: https://github.com/browser-use/browser-use/issues/2605
6 answers
The issue was closed as completed, but the thread does not include a maintainer-provided code fix; it contains user-verified workarounds and an explanation from a contributor.
A user reported that gpt-oss:20b returned an empty response, which is a known issue with that model's JSON output format. Another user saw
LLM call timed out after 60 seconds. Keep your thinking and output short.when using gpt-oss.Workarounds that worked in the thread:
-
For gpt-4.1, pass a longer agent timeout instead of the default 90 seconds:
pythonagent = Agent( task="your task", llm=llm, llm_timeout=120 ) -
For gpt-5 on browser-use 0.7.9, increase the completion token budget:
pythonllm = ChatOpenAI( model=MODEL, temperature=TEMPERATURE, api_key=OPENAI_API_KEY, max_completion_tokens=16384 ) -
On browser-use 0.8.0 with gpt-5, one user found
add_schema_to_system_prompt=Truehelpful.
A contributor states that GPT-5 models can be unstable with browser-use and recommends using gpt-oss models with structured output instead of tool calling, pointing to the ChatGroq implementation as a reference. No exact configuration for that approach appears in the thread.
Treat these as reported workarounds, not a guaranteed fix for every model or version.
Did this work for you?-
What @Kolaposki tried on GitHub (Worked)
With gpt-4.1, set
Agent(..., llm_timeout=120)instead of the default 90 seconds; this solved the error.Source: https://github.com/browser-use/browser-use/issues/2605#issuecomment-3381807562 (opens external site)
Did this work for you?What @chensun96 tried on GitHub (Worked)
With gpt-5 on browser-use 0.7.9, increased
max_completion_tokens=16384on ChatOpenAI; this solved the error.Source: https://github.com/browser-use/browser-use/issues/2605#issuecomment-3382364798 (opens external site)
Did this work for you?What @caiuskong tried on GitHub (Partly worked)
With browser-use 0.8.0 and gpt-5, added
add_schema_to_system_prompt=True; reported as helpful.Source: https://github.com/browser-use/browser-use/issues/2605#issuecomment-3400564468 (opens external site)
Did this work for you?What a GitHub user tried on GitHub (Didn't work)
Reported that running a new OpenAI model (gpt-oss) through Ollama in browser-use 0.5.9 produced
1 validation error for AgentOutput: Invalid JSON: EOF while parsing a value at line 1 column 0and a 502 response.Source: https://github.com/browser-use/browser-use/issues/2605 (opens external site)
Did this work for you?What @saurabh919 tried on GitHub (Didn't work)
Tried
ChatOllama(model="gpt-oss:20b")with a local Ollama host andmemory_extraction_model=None; the same AgentOutput validation error appeared after step 1.Source: https://github.com/browser-use/browser-use/issues/2605#issuecomment-3357110235 (opens external site)
Did this work for you?
Related questions
- How to fix browser-use PostHog SSL CERTIFICATE_VERIFY_FAILED error?
- How to pause browser-use and ask a human for input mid-run?
- browser-use agent stuck at Step 1 with Chromium on about:blank page
- How do I use OpenRouter with browser-use for DeepSeek when it fails with 429 or 'Could not parse response'?
- browser-use SSLError to eu.i.posthog.com: how do I disable the telemetry call?