[NIM] [GLM-5] Malformed tool-call JSON (missing '}') via OpenAI-compatible endpoint (OpenCode)

Hello,

I’m seeing intermittent malformed tool-call arguments when using z-ai/glm5 via NIM (https://integrate.api.nvidia.com/v1) from an OpenAI-compatible coding client called OpenCode.

Symptom
Tool calls occasionally contain truncated/malformed JSON args, e.g. missing closing }:

Invalid input for tool tavily_tavily_search: JSON parsing failed: Text: {“query”:“Geoffrey Huntley LinkedIn Ralph Wiggum most viral reposts”.
Error message: JSON Parse error: Expected ‘}’

In the same session, multiple tools can fail similarly (tavily_tavily_search, brave-search_brave_web_search, webfetch), and the client may enter retry loops.

Environment

Reproduction

  1. Configure OpenAI-compatible client to use NIM endpoint + z-ai/glm5.
  2. Run a prompt that triggers several tool/function calls in one turn.
  3. Observe intermittent malformed tool JSON payloads.

Expected
Tool/function call arguments are always strict valid JSON.

Actual
Occasional malformed JSON in tool arguments causes parser errors and failed tool execution.

Related reports

If there is a recommended parser/config/flag set for robust GLM-5 tool-calling via NIM, please share.

Thanks!

Update: minimal repro + exact malformed tool-call payloads here:

Me too.I found that GLM-5 cannot correctly output JSON in json_object mode.

GLM-5 via OpenCode (NIM OpenAI endpoint) still returning EngineCore encountered an issue

Environment:

  • macOS 26.3
  • OpenCode CLI 1.2.15
  • Model: z-ai/glm5 via https://integrate.api.nvidia.com/v1
  • Request ID (from direct API call): 83cc2550-a234-445d-b5b4-7da6b35e4497

Steps:

  1. Run opencode run --model nvidia/z-ai/glm5 "Quick smoke test".

  2. OpenCode log line 115 shows llm providerID=nvidia modelID=z-ai/glm5, but the CLI never receives any tokens before timing out.

  3. To isolate OpenCode from the provider:

    curl -s -D nim-glm5-headers.txt -o nim-glm5-body.json \
      -H "Authorization: Bearer $NVIDIA_API_KEY" \
      -H "Content-Type: application/json" \
      -X POST https://integrate.api.nvidia.com/v1/chat/completions \
      -d '{"model":"z-ai/glm5","messages":[{"role":"user","content":"ping"}],"max_tokens":64}'
    
  4. The API immediately returns HTTP/2 500 and the body {“error”:{“message”:“EngineCore encountered an issue. See stack trace (above) for the root cause.”,“type”:“InternalServerError”…}}.

Artifacts: opencode-log-2026-03-05T224023.log, nim-glm5-headers.txt, nim-glm5-body.json.

glm5-nim-error.zip (5.2 KB)