Bug Report: Codex App — LLM Returns Invalid JSON in Function Call Arguments
Date: 2026-06-23
App: Codex Desktop App v0.142.0-alpha.6
Module: codex_core::tools::router (Rust)
Severity: High — tool calls fail, degrading agent autonomy
========================================================================
Error Summary
-------------
The Codex app fails to parse LLM-generated function call arguments because
the "beast" model (served via vLLM) returns invalid JSON in the "arguments"
field of function_call response items.
Primary Error (from Rust serde parser):
error=failed to parse function arguments: EOF while parsing an object at line 1 column 1
Source: codex_core::tools::router -> dispatch_tool_call_with_code_mode_result
-> dispatch_tool_call_with_terminal_outcome
Cause: The LLM's streaming response emits a function_call with
arguments: "{" — a lone opening brace with no content.
The Rust serde JSON parser immediately hits EOF.
Secondary Error (from Python subprocess):
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
This error surfaces in shell commands generated by the LLM that contain
inline Python json.load() calls. When the backend returns empty or
malformed responses, Python's strict JSON parser rejects the input.
========================================================================
Evidence from Logs
------------------
Instance #1 — 2026-06-22 03:26:45 UTC (first occurrence)
Session: 019eed59-0846-7971-9821-60da96bcc3e0
File: ~/.codex/sessions/2026/06/22/rollout-2026-06-22T11-21-35-019eed59-0846-7971-9821-60da96bcc3e0.jsonl
Line 31 — the LLM response:
{
"timestamp": "2026-06-22T03:26:45.553Z",
"type": "response_item",
"payload": {
"type": "function_call",
"id": "9444b96a15eaa8c6",
"name": "exec_command",
"arguments": "{", <--- INVALID: just an opening brace
"call_id": "call_8ee1442a3618c820"
}
}
````
Line 32 — the parse error:
{
"timestamp": "2026-06-22T03:26:45.567Z",
"type": "response_item",
"payload": {
"type": "function_call_output",
"call_id": "call_8ee1442a3618c820",
"output": "failed to parse function arguments: EOF while parsing an object at line 1 column 1"
}
}
Instance #2 — 2026-06-23 03:28:43 UTC (repeated in next session)
Session: 019ef22c-046a-73f2-9805-b05d71fd87ea
File: ~/.codex/sessions/2026/06/23/rollout-2026-06-23T09-50-31-019ef22c-046a-73f2-9805-b05d71fd87ea.jsonl
Line 1083 — the LLM response:
{
"timestamp": "2026-06-23T03:28:43.950Z",
"type": "response_item",
"payload": {
"type": "function_call",
"id": "83587405fae00cc2",
"name": "exec_command",
"arguments": "{", <--- INVALID: just an opening brace
"call_id": "call_966676a1072ededd"
}
}
Line 1084 — the parse error:
{
"timestamp": "2026-06-23T03:28:43.963Z",
"type": "response_item",
"payload": {
"type": "function_call_output",
"call_id": "call_966676a1072ededd",
"output": "failed to parse function arguments: EOF while parsing an object at line 1 column 1"
}
}
Both ERROR entries are recorded in ~/.codex/logs_2.sqlite:
ts=1782098805, level=ERROR, target=codex_core::tools::router
ts=1782185323, level=ERROR, target=codex_core::tools::router
========================================================================
Root Cause Analysis
-------------------
The "beast" model (Anthropic Claude, proxied through vLLM at
http://172.16.8.107:8000/v1 with wire_api="responses") occasionally
emits incomplete JSON objects as function call arguments.
Specifically, it sends:
"arguments": "{"
instead of valid JSON like:
"arguments": "{\"cmd\": \"ls -la\"}"
This is an LLM output formatting issue. The model begins emitting a JSON
object but stops or cuts off after the opening brace.
Possible triggers:
1. The model hits a token/length limit mid-generation
2. The streaming connection is interrupted (related to frequent
"stream disconnected" WARN logs in the same session)
3. The vLLM inference server has a bug in the responses API adapter
that truncates function_call arguments
4. The "beast" model itself has insufficient instruction following
for structured JSON output in tool-calling scenarios
Supporting evidence: the same session shows repeated "stream disconnected"
warnings (codex_core::responses_retry) with reconnection attempts,
suggesting intermittent network or server-side issues with the vLLM
endpoint.
========================================================================
Environment Configuration
-------------------------
Model: beast (Anthropic Claude via vLLM)
Provider: vLLM at http://172.16.8.107:8000/v1
Wire API: responses (OpenAI Responses API compatible)
Config file: ~/.codex/config.toml
App version: 0.142.0-alpha.6
Build: 26.616.71553
CWD: /Users/swei/ai/arena
Relevant config.toml settings:
model = "beast"
model_provider = "vllm"
[model_providers.vllm]
base_url = "http://172.16.8.107:8000/v1"
wire_api = "responses"
========================================================================
Impact
------
- Tool calls fail silently (error is sent back to the LLM as
function_call_output)
- The agent loses the ability to execute commands at that turn
- The conversation may enter a loop if the LLM repeatedly generates
invalid JSON
- User sees tool execution failures or the agent gets stuck
========================================================================
Reproduction Steps
------------------
1. Configure Codex to use the "beast" model via vLLM (responses API)
2. Start a session and give the agent a complex multi-step task
3. Eventually, the LLM emits a function_call with arguments: "{"
4. The Rust JSON parser fails with:
"EOF while parsing an object at line 1 column 1"
The bug is non-deterministic — it depends on the LLM's output.
It occurred twice across two sessions in one day of usage.
========================================================================
Recommended Fixes
-----------------
For the Codex App Team (Rust side):
1. Add validation before parsing: if arguments is empty or is just
"{", treat it as a malformed response and send a structured error
back to the LLM with guidance on the expected format
2. Implement a retry mechanism: when arguments parsing fails, resubmit
the turn with a system hint like "Your last function_call had
invalid JSON arguments. Please provide a complete JSON object."
3. Log the raw arguments string in the error message for easier debugging
4. Consider a more lenient JSON parser that handles edge cases like
trailing commas, single quotes, or whitespace-only content
For the vLLM / Model Operator:
1. Check if the vLLM responses API adapter has a bug that truncates
function_call arguments at certain token boundaries
2. Verify stream integrity — the "stream disconnected" warnings
suggest the connection drops mid-response, possibly causing
incomplete function_call payloads
3. Consider adding JSON schema validation at the server level to
reject malformed function_call arguments before they reach the client
4. Review the "beast" model's tool-calling fine-tuning — it may need
additional training on proper JSON formatting for arguments
========================================================================
Related Log Entries
-------------------
WARN logs showing stream disconnections (same session):
1782102687 stream disconnected - retrying sampling request (1/5 in 214ms)
1782102036 stream disconnected - retrying sampling request (1/5 in 216ms)
1782102367 stream disconnected - retrying sampling request (1/5 in 186ms)
WARN logs showing personality fallback (beast model specific):
"Model personality requested but model_messages is missing,
falling back to base instructions. model=beast"
These warnings suggest the vLLM adapter does not fully implement the
OpenAI Responses API — particularly the "model_messages" field which
carries personality/context hints. This incomplete implementation may
contribute to the model producing malformed output.
========================================================================
Files Referenced
----------------
~/.codex/logs_2.sqlite — App log database
~/.codex/config.toml — Model/provider config
~/.codex/sessions/2026/06/22/rollout-*.jsonl — Session #1 (Jun 22)
~/.codex/sessions/2026/06/23/rollout-*.jsonl — Session #2 (Jun 23)
/Applications/Codex.app/Contents/Resources/app.asar — App source bundle
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗