Skip to content

[BUG] GLM-5 via NVIDIA NIM emits malformed MCP tool JSON (Expected '}') in OpenCode v1.2.6 #13900

Closed as not planned

Description

Description

When using z-ai/glm5 via the NVIDIA NIM provider in OpenCode 1.2.6, tool calls intermittently emit malformed JSON arguments.

This causes repeated tool failures and retry loops with errors like:

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 '}'

Similar malformed payloads occurred for multiple web tools in the same session (tavily_tavily_search, brave-search_brave_web_search, webfetch).

Environment

  • OpenCode version: 1.2.6
  • Model: z-ai/glm5
  • Provider: NVIDIA NIM
  • OS: macOS Sequoia 15.7.4

Steps to reproduce

  1. Configure OpenCode to use z-ai/glm5 through NVIDIA NIM.
  2. Ask for a web-research task that triggers multiple MCP/web tool calls.
  3. Observe some tool calls being emitted with malformed JSON (missing closing braces / truncated payloads).
  4. Session may enter repeated invalid-call retries.

Expected behavior

Tool arguments should always be valid JSON before execution (or be rejected/recovered with a structured retry).

Actual behavior

Some tool calls are emitted as malformed JSON and fail parser validation, often repeatedly in the same session.

Additional context

Potentially related issues (similar parsing symptoms across models/providers):

I’m unsure whether root cause is parser-side, stream chunk handling, provider behavior, or interaction between them; sharing this report in case the 1.2.x + GLM-5 + NIM combination has a distinct failure mode.

Activity

  1. github-actions commented on Feb 16, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of or closely related to existing issues. Please check:

    While this report is specific to GLM-5 via NVIDIA NIM, the underlying JSON parsing failure pattern appears consistent with these existing issues.

  2. chindris-mihai-alexandru commented on Feb 16, 2026

    @chindris-mihai-alexandru
    Author

    Update: also reported upstream on NVIDIA Developer Forums with the same repro and error signature:
    https://forums.developer.nvidia.com/t/nim-glm-5-malformed-tool-call-json-missing-via-openai-compatible-endpoint-opencode/360809

    This should help confirm whether root cause is model output, serving/stream chunking, or client-side parser recovery in this stack combination.

  3. chindris-mihai-alexandru commented on Feb 16, 2026

    @chindris-mihai-alexandru
    Author

    Added minimal reproducible prompt + exact malformed payloads gist: https://gist.github.com/chindris-mihai-alexandru/f3c114915f18618406030e6a2d8fa59b

  4. rekram1-node commented on Feb 17, 2026

    @rekram1-node
    Contributor

    yeah the nvidia provider has been giving me some weirdness, it says openai compat but maybe there is something we arent properly sending them...

  5. YukariMindGap commented on Feb 17, 2026

    @YukariMindGap

    I have the same problem as you, however i'm using NanoGPT as my endpoint and i still get the issue. I also get this problem from Qwen 3.5 and Kimi 2.5.

  6. aryulianto commented on Feb 18, 2026

    @aryulianto

    I also encountered this issue with self-hosted GLM‑5 FP8 in OpenCode v1.2.5 and v1.2.6, both the CLI and desktop versions.

  7. CodingRookie98 commented on Feb 18, 2026

    @CodingRookie98

    I also encountered this issue with nvidia provider.

  8. allanchan339 commented on Feb 24, 2026

    @allanchan339

    Per https://build.nvidia.com/z-ai/glm5/modelcard, glm5 in NIM use SGLang as inference engine, so i think SGLang should have same report ? @chindris-mihai-alexandru

  9. chindris-mihai-alexandru commented on Feb 25, 2026

    @chindris-mihai-alexandru
    Author

    I thin you're right. Opened upstream tracking issue in SGLang too: sgl-project/sglang#19345

  10. openzeka-birol-kuyumcu commented on Mar 3, 2026

    @openzeka-birol-kuyumcu

    same problem with vllm serving over Dgx-B300

  11. chindris-mihai-alexandru commented on Mar 5, 2026

    @chindris-mihai-alexandru
    Author

    Reproduced the GLM-5 failure again a few minutes ago and captured clean artifacts. Highlights:

    • macOS 26.3, OpenCode CLI 1.2.15.
    • Command: opencode run --model nvidia/z-ai/glm5 "Quick smoke test".
    • OpenCode log line 115 shows the agent handing off to providerID=nvidia modelID=z-ai/glm5, after which no tokens ever arrive and the CLI eventually times out.
    • A direct OpenAI-compatible call to https://integrate.api.nvidia.com/v1/chat/completions with the same API key immediately returns HTTP/2 500 with nvcf-reqid: 83cc2550-a234-445d-b5b4-7da6b35e4497 and body {"error":{"message":"EngineCore encountered an issue..."}}, so the crash is upstream of OpenCode.

    Direct curl repro

    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}'
    

    The captured headers/body show the same HTTP/2 500 with the request ID above; happy to upload the raw files if anyone needs them.

    OpenCode log (2026-03-05T22:40:23Z run)

    That log records the CLI handing off to the NVIDIA provider, receiving no tokens, and timing out. I can attach the file if it would be useful; omitted here to avoid referencing local paths that others cannot access.

  12. chindris-mihai-alexandru commented on Mar 5, 2026

    @chindris-mihai-alexandru
    Author

    Quick reproduction data from macOS 26.3 running OpenCode CLI 1.2.15 with providerID=nvidia / modelID=z-ai/glm5 (opencode run --model nvidia/z-ai/glm5 "Quick smoke test"):

    (Earlier retries with provider=openai / model=gpt-5.3-codex showed the same AI_APICallError loop; keeping that snippet here until I capture a glm5-specific log.)

    opencode-debug-snippets.txt

    2026-02-27T174331.log:155 | 2026-02-27T19:16:23 | ERROR | provider=openai | model=gpt-5.3-codex | session=ses_35f782c21ffettEeu5b3nwNqpz | agent=build | error=AI_APICallError
    2026-02-27T174331.log:160 | 2026-02-27T19:16:26 | ERROR | provider=openai | model=gpt-5.3-codex | session=ses_35f782c21ffettEeu5b3nwNqpz | agent=build | error=AI_APICallError
    2026-02-27T174331.log:165 | 2026-02-27T19:16:31 | ERROR | provider=openai | model=gpt-5.3-codex | session=ses_35f782c21ffettEeu5b3nwNqpz | agent=build | error=AI_APICallError
    2026-02-27T174331.log:170 | 2026-02-27T19:16:40 | ERROR | provider=openai | model=gpt-5.3-codex | session=ses_35f782c21ffettEeu5b3nwNqpz | agent=build | error=AI_APICallError
    2026-02-27T174331.log:179 | 2026-02-27T19:16:56 | ERROR | provider=openai | model=gpt-5.3-codex | session=ses_35f782c21ffettEeu5b3nwNqpz | agent=build | error=AI_APICallError
    2026-02-27T174331.log:184 | 2026-02-27T19:17:29 | ERROR | provider=openai | model=gpt-5.3-codex | session=ses_35f782c21ffettEeu5b3nwNqpz | agent=build | error=AI_APICallError
    

    opencode-error-snippets.txt

    session_id: ses_3414e160bffeM7NlG2Ae41uXUQ
    session_updated_unix_ms: 1772736548377
    captured_payload: {"type":"error","sequence_number":2,"error":{"type":"server_error","code":"serve... (click to expand) [retrying in 2s attempt #2]
    captured_payload: {"type":"error","sequence_number":2,"error":{"type":"server_error","code":"server_error","message":"An error occurred while processing your request... [retrying in 2s attempt #2]
    

    Full structured session log (already redacted) is in this gist: https://gist.github.com/chindris-mihai-alexandru/cfa84780015dc417b550170c52d98db6

  13. MoshiLL commented on Mar 12, 2026

    @MoshiLL

    I also encountered this issue with self-hosted GLM‑5 FP8 in claude code

  14. github-actions commented on May 12, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions