Skip to content

Opencode with GLM 4.5 String issue #1880

Closed

Description

@Abdiazizahmedali

opencode stops working in the middle and gives this error ; AI_InvalidResponseDataError: Expected 'id' to be a string.

Activity

  1. legout commented on Aug 13, 2025

    @legout

    Same error here

  2. beyondpixeldesign commented on Aug 13, 2025

    @beyondpixeldesign

    I receive the same error message when using the Chutes provider with the GLM 4.5 Air Model. Using the Qwen3 Model via Chutes does work, so it seems to be tied to the GLM models

  3. Abdiazizahmedali commented on Aug 13, 2025

    @Abdiazizahmedali
    Author

    Yes exactly i also receive that error via chutes api . Its the GLM models response format i guess. @thdxr Kindly assist to accommodate GLM models better .

  4. Yesseuki commented on Aug 14, 2025

    @Yesseuki

    Seeing the same with openrouter and standard GLM 4.5 model.

  5. theoriginalaiexplorer commented on Aug 15, 2025

    @theoriginalaiexplorer
    Image

    From My experience if you try to jailbreak it asking something it has been asked to not to do. I see this issue.

  6. cgycorey commented on Aug 17, 2025

    @cgycorey

    I can reproduce this error on v0.5.5 version of Opencode. What I found is that if you use Chutes AI as a provider and choose GLM 4.5 FP8 model, every time when the model create the todo list by calling this tool it shows the above error. Occasionally, when this model called the read file tool it also showed the above. I tried the same model with same provider on Kilo code to check if it is provider's issue but seems it worked fine on that.

  7. stickyburn commented on Aug 27, 2025

    @stickyburn

    Facing the same for days now. I think it might be on the model?

  8. aaronnewsome commented on Sep 2, 2025

    @aaronnewsome

    I'll subscribe to this issue too, as running unsloth's GLM-4.5-Air-UD-Q4_K_XL, served by llama.cpp, using opencode has been a challenge and I'm out of ideas. My opencode.json contains:

    "models": {
            "GLM-4.5-Air-UD-Q4_K_XL": {
                "name": "GLM Air 4.5 Q4",
                "tool_call": true,
                "reasoning": true,            
                "options": { "num_ctx": 131072 }
            }
    }
    

    I've done some experimentation with removing some of the options or mixing which options to use, but I haven't yet found a magic combination. The read tools seem to be working but trying to use any tools that write files just fails with errors.

    The same model served from the same server works 100% in Cline/VSCode, but I'm really looking for a good terminal based coder that works with GLM 4.5, since it's the best model I can run on my local setup. I did try gpt-oss:20b/ollama and it worked with opencode. I assume 120b would also work. I do have qwen3-coder:30b-a3b, which also works nicely with Cline, it's just not as strong as GLM 4.5 air.

    Hopefully someone can point me to a working config for opencode, or recommend another capable terminal coder that will work with GLM-4.5, I'm not particularly tied to opencoder since I've never been able to get it to work correctly.

    Thank you all, in advance, for your help.

  9. xypur commented on Sep 11, 2025

    @xypur

    This issue still exists

  10. aaronnewsome commented on Sep 11, 2025

    @aaronnewsome

    I was able to get opencode talking to my GLM-4.5-AIR, served by llama.cpp with this chat template

    https://huggingface.co/unsloth/GLM-4.5-Air-GGUF/discussions/1

    I was even get it to call some tools, write some files but it's about is flaky as they come. Still looking for some guidance from anyone has this setup working. I'm tied to opencode, but I'd be willing to give any competent terminal coder a try. For now, I'll just be happy that Cline seems to work pretty well.

  11. jdiaz5513 commented on Sep 17, 2025

    @jdiaz5513
    Contributor

    This happens when the model hallucinates the tool name and the chat template (on the inference server, like at z.ai) fails to parse it.

    See: #2557 (comment)

    I wonder if there can be a special case to handle this error message and treat it like a failed tool call (it was going to fail anyway), prompting the LLM to try again.

  12. jdiaz5513 commented on Sep 19, 2025

    @jdiaz5513
    Contributor

    @aaronnewsome you probably want to watch this thread; I've run this branch of llama.cpp locally and tool calling is much better (flawless?) there.

    Any inference providers using llama.cpp in production will also benefit from this patch; hard to say if that's going to affect z.ai as well. They may be using vLLM.

  13. aaronnewsome commented on Sep 19, 2025

    @aaronnewsome

    Thanks for the tip @jdiaz5513 , I pulled the latest b6517, applied the pr 15904 and built it. I'm running llama.cpp with the chat template in the PR and opencode is working much, much better. It was working somewhat with the chat template in comments on the GLM-4.5-Air huggingface page, tool calls would succeed but then the chat would just stop instead of continuing to the next step. Super annoying to keep typing "proceed" or "continue" after each and every tool call. Talk about a productivity killer. I'm not seeing the issue any longer with PR 15904. Hopefully the PR gets merged soon, so it's in the main. Again, thank you for the tip.

  14. rversteegen commented on Nov 1, 2025

    @rversteegen

    I just had this AI_InvalidResponseDataError: Expected 'id' to be a string error repeatedly from Big Pickle (GLM 4.6) when it tried to edit, and finally I realised I had it in Plan mode...

  15. vinicius507 commented on Nov 12, 2025

    @vinicius507
  16. Ununnilium commented on Jan 5, 2026

    @Ununnilium

    I have the error with GLM-4.7 and vLLM. Gemini CLI says that this is a bug in the inference engine (in my case vLLM). According to the OpenAI API specification, an id in the first chunk of a tool call is mandatory. AI SDK is very strict and enforces this: https://github.com/vercel/ai/blob/c041f749c58cd6669a0abadccc7530e8949bf532/packages/openai-compatible/src/chat/openai-compatible-chat-language-model.ts#L464

  17. stromseng commented on Jan 16, 2026

    @stromseng

    See my short writeup at BerriAI/litellm#13124 (comment) , using GLM 4.7 hosted via litellm and encountering a similar issue.

  18. Ununnilium commented on Jan 18, 2026

    @Ununnilium

    For me, it just works now with GLM-4.7 after updating to the latest vLLM nightly. I think there was a bug in vLLM which was fixed. It also works through LiteLLM.

    For other people having the same problem, you can use mitmproxy to see the exact tool calls in the HTTP responses . First, start mitmweb (part of mitmproxy). Then, before starting opencode, set the following variables:

    export no_proxy=localhost,127.0.0.1
    export https_proxy=http://127.0.0.1:8080
    export http_proxy=http://127.0.0.1:8080
    export https_proxy=http://127.0.0.1:8080
    export HTTPS_PROXY=http://127.0.0.1:8080
    export NODE_TLS_REJECT_UNAUTHORIZED=0

    Now, try one time the problematic API of the LLM and one time a proper working version (e.g. GLM-4.7 OpenCode Zen) with a simple prompt. You can then compare the HTTP response to the same prompt e.g. with Gemini. With this information, you can the easier report the problem e.g. to the inference engine or the API provider.

  19. github-actions commented on Mar 27, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 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

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions