Repository navigation
Z.ai coding model connection issue #4349
Copy link
Copy link
Closed
Description
Question
OS Ubuntu 22.04.5 LTS
opencode ver. 1.0.65
Hello! I have an issue in Z.ai model using in opencode. I have an Z.ai API-key. It is added to opencode by *auth login * command. Access to model works okey when I make request by curl:
curl -X POST "https://api.z.ai/api/coding/paas/v4/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer my api-key" \
-d '{
"model": "glm-4.6",
"messages": [{"role": "user", "content": "Write a short story about a robot"}],
"stream": true
}'
request and answer log:
curl -X POST "https://api.z.ai/api/coding/paas/v4/chat/completions" \ST "https://api.z.ai/api/coding/paas/v4/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer 6ebc214feae84a9899e35a5726930070.eeVimJD98DJYlxm2" \
-d '{
"model": "glm-4.6",
"messages": [{"role": "user", "content": "say Hello!"}],
"stream": true
}'
data: {"id":"2025111517384495eaf2ee418443b1","created":1763199524,"model":"glm-4.6","choices":[{"index":0,"delta":{"role":"assistant","content":"","reasoning_content":"\n"}}]}
data: {"id":"2025111517384495eaf2ee418443b1","created":1763199524,"model":"glm-4.6","choices":[{"index":0,"delta":{"role":"assistant","reasoning_content":"1"}}]}
data: {"id":"2025111517384495eaf2ee418443b1","created":1763199524,"model":"glm-4.6","choices":[{"index":0,"delta":{"role":"assistant","reasoning_content":"."}}]}
data: {"id":"2025111517384495eaf2ee418443b1","created":1763199524,"model":"glm-4.6","choices":[{"index":0,"delta":{"role":"assistant","content":"","reasoning_content":" "}}]}
data: {"id":"2025111517384495eaf2ee418443b1","created":1763199524,"model":"glm-4.6","choices":[{"index":0,"delta":{"role":"assistant","reasoning_content":" **"}}]}
data: {"id":"2025111517384495eaf2ee418443b1","created":1763199524,"model":"glm-4.6","choices":[{"index":0,"delta":{"role":"assistant","reasoning_content":"An"}}]}
data: {"id":"2025111517384495eaf2ee418443b1","created":1763199524,"model":"glm-4.6","choices":[{"index":0,"delta":{"role":"assistant","reasoning_content":"alyze"}}]}
data: {"id":"2025111517384495eaf2ee418443b1","created":1763199524,"model":"glm-4.6","choices":[{"index":0,"delta":{"role":"assistant","reasoning_content":" the"}}]}
But when I try to send request from opencode it finishes by timeout after long waiting.
debug log print looks like:
INFO 2025-11-15T09:07:55 +169ms service=config path=/home/igor/.config/opencode/config.json loading
INFO 2025-11-15T09:07:55 +1ms service=config path=/home/igor/.config/opencode/opencode.json loading
INFO 2025-11-15T09:07:55 +35ms service=config path=/home/igor/.config/opencode/opencode.jsonc loading
INFO 2025-11-15T09:07:55 +51ms service=server method=GET path=/config/providers request
INFO 2025-11-15T09:07:55 +0ms service=server status=started method=GET path=/config/providers request
INFO 2025-11-15T09:07:55 +1ms service=default directory=/home/igor/Plastov/lightconsole_soft/lightconsole_test_eobj creating instance
INFO 2025-11-15T09:07:55 +1ms service=project directory=/home/igor/Plastov/lightconsole_soft/lightconsole_test_eobj fromDirectory
INFO 2025-11-15T09:07:55 +0ms service=server method=GET path=/agent request
INFO 2025-11-15T09:07:55 +0ms service=server status=started method=GET path=/agent request
INFO 2025-11-15T09:07:55 +1ms service=server method=GET path=/config request
INFO 2025-11-15T09:07:55 +0ms service=server status=started method=GET path=/config request
INFO 2025-11-15T09:07:55 +0ms service=project status=started git.rev-parse
INFO 2025-11-15T09:07:55 +2ms service=project status=completed duration=2 git.rev-parse
INFO 2025-11-15T09:07:55 +3ms service=server method=GET path=/event request
INFO 2025-11-15T09:07:55 +0ms service=server status=started method=GET path=/event request
INFO 2025-11-15T09:07:55 +4ms service=default directory=/home/igor/Plastov/lightconsole_soft/lightconsole_test_eobj bootstrapping
INFO 2025-11-15T09:07:55 +5ms service=bun cmd=["/home/igor/.opencode/bin/opencode","add","@opencode-ai/plugin@1.0.65","--exact"] cwd=/home/igor/.config/opencode running
INFO 2025-11-15T09:07:55 +7ms service=bun code=0 stdout=bun add v1.3.2 (b131639c)
installed @opencode-ai/plugin@1.0.65
[3.00ms] done
stderr=Saved lockfile
done
INFO 2025-11-15T09:07:55 +6ms service=plugin path=opencode-copilot-auth@0.0.5 loading plugin
INFO 2025-11-15T09:07:55 +2ms service=plugin path=opencode-anthropic-auth@0.0.2 loading plugin
INFO 2025-11-15T09:07:55 +30ms service=bus type=* subscribing
INFO 2025-11-15T09:07:55 +0ms service=bus type=session.updated subscribing
INFO 2025-11-15T09:07:55 +0ms service=bus type=message.updated subscribing
INFO 2025-11-15T09:07:55 +0ms service=bus type=message.part.updated subscribing
INFO 2025-11-15T09:07:55 +1ms service=format init
INFO 2025-11-15T09:07:55 +0ms service=bus type=file.edited subscribing
INFO 2025-11-15T09:07:55 +0ms service=lsp serverIds=deno, typescript, vue, eslint, gopls, ruby-lsp, pyright, elixir-ls, zls, csharp, sourcekit-lsp, rust, clangd, svelte, astro, jdtls, lua-ls enabled LSP servers
INFO 2025-11-15T09:07:55 +2ms service=bus type=command.executed subscribing
INFO 2025-11-15T09:07:55 +2ms service=server status=started providers
INFO 2025-11-15T09:07:55 +3ms service=provider status=started state
INFO 2025-11-15T09:07:55 +1ms service=server event connected
INFO 2025-11-15T09:07:55 +3ms service=bus type=* subscribing
INFO 2025-11-15T09:07:55 +3ms service=models.dev file={} refreshing
INFO 2025-11-15T09:07:55 +3ms service=server status=completed duration=72 method=GET path=/event request
INFO 2025-11-15T09:07:55 +0ms service=server status=completed duration=77 method=GET path=/config request
INFO 2025-11-15T09:07:55 +1ms service=server status=completed duration=79 method=GET path=/agent request
INFO 2025-11-15T09:07:55 +8ms service=provider init
INFO 2025-11-15T09:07:55 +16ms service=provider providerID=zai-coding-plan found
INFO 2025-11-15T09:07:55 +0ms service=provider providerID=opencode found
INFO 2025-11-15T09:07:55 +0ms service=provider status=completed duration=35 state
INFO 2025-11-15T09:07:55 +2ms service=server status=completed duration=40 providers
INFO 2025-11-15T09:07:55 +0ms service=server status=completed duration=107 method=GET path=/config/providers request
INFO 2025-11-15T09:07:55 +16ms service=server method=GET path=/session request
INFO 2025-11-15T09:07:55 +0ms service=server status=started method=GET path=/session request
INFO 2025-11-15T09:07:55 +1ms service=server method=GET path=/command request
INFO 2025-11-15T09:07:55 +0ms service=server status=started method=GET path=/command request
INFO 2025-11-15T09:07:55 +1ms service=server status=completed duration=1 method=GET path=/command request
INFO 2025-11-15T09:07:55 +1ms service=server method=GET path=/lsp request
INFO 2025-11-15T09:07:55 +0ms service=server status=started method=GET path=/lsp request
INFO 2025-11-15T09:07:55 +0ms service=server status=completed duration=0 method=GET path=/lsp request
INFO 2025-11-15T09:07:55 +1ms service=server method=GET path=/mcp request
INFO 2025-11-15T09:07:55 +1ms service=server status=started method=GET path=/mcp request
INFO 2025-11-15T09:07:55 +0ms service=server status=completed duration=1 method=GET path=/mcp request
INFO 2025-11-15T09:07:55 +0ms service=server method=GET path=/formatter request
INFO 2025-11-15T09:07:55 +0ms service=server status=started method=GET path=/formatter request
INFO 2025-11-15T09:07:55 +8ms service=server status=completed duration=13 method=GET path=/session request
INFO 2025-11-15T09:07:55 +1ms service=server status=completed duration=9 method=GET path=/formatter request
ERROR 2025-11-15T09:08:05 +9942ms service=default e=The operation timed out. rejection
INFO 2025-11-15T09:08:09 +3551ms service=server method=POST path=/session request
INFO 2025-11-15T09:08:09 +0ms service=server status=started method=POST path=/session request
INFO 2025-11-15T09:08:09 +4ms service=session id=ses_5793a61e1ffeJII1qOvBi9wTIy version=1.0.65 projectID=c98cea3e79beb9bb24002455891052cf3c497e43 directory=/home/igor/Plastov/lightconsole_soft/lightconsole_test_eobj title=New session - 2025-11-15T09:08:09.374Z time={"created":1763197689374,"updated":1763197689374} created
INFO 2025-11-15T09:08:09 +1ms service=bus type=session.created publishing
INFO 2025-11-15T09:08:09 +1ms service=bus type=session.updated publishing
INFO 2025-11-15T09:08:09 +2ms service=server status=completed duration=8 method=POST path=/session request
INFO 2025-11-15T09:08:09 +4ms service=server method=POST path=/session/ses_5793a61e1ffeJII1qOvBi9wTIy/message request
INFO 2025-11-15T09:08:09 +0ms service=server status=started method=POST path=/session/ses_5793a61e1ffeJII1qOvBi9wTIy/message request
INFO 2025-11-15T09:08:09 +12ms service=session.prompt session=ses_5793a61e1ffeJII1qOvBi9wTIy prompt
INFO 2025-11-15T09:08:09 +0ms service=server status=completed duration=12 method=POST path=/session/ses_5793a61e1ffeJII1qOvBi9wTIy/message request
INFO 2025-11-15T09:08:09 +8ms service=bus type=message.updated publishing
INFO 2025-11-15T09:08:09 +6ms service=bus type=message.part.updated publishing
INFO 2025-11-15T09:08:09 +2ms service=bus type=session.updated publishing
INFO 2025-11-15T09:08:09 +1ms service=provider providerID=zai-coding-plan modelID=glm-4.6 getModel
INFO 2025-11-15T09:08:09 +1ms service=provider status=started providerID=zai-coding-plan getSDK
INFO 2025-11-15T09:08:09 +127ms service=provider status=completed duration=127 providerID=zai-coding-plan getSDK
INFO 2025-11-15T09:08:09 +3ms service=provider providerID=zai-coding-plan modelID=glm-4.6 found
INFO 2025-11-15T09:08:09 +1ms service=session.lock sessionID=ses_5793a61e1ffeJII1qOvBi9wTIy locked
INFO 2025-11-15T09:08:09 +0ms service=session.prompt session=ses_5793a61e1ffeJII1qOvBi9wTIy sessionID=ses_5793a61e1ffeJII1qOvBi9wTIy locking
INFO 2025-11-15T09:08:09 +65ms service=bus type=message.updated publishing
INFO 2025-11-15T09:08:09 +14ms service=session.prompt session=ses_5793a61e1ffeJII1qOvBi9wTIy process
INFO 2025-11-15T09:08:09 +21ms service=bus type=message.updated publishing
INFO 2025-11-15T09:08:09 +1ms service=bus type=session.updated publishing
INFO 2025-11-15T09:08:09 +0ms service=bus type=session.diff publishing
INFO 2025-11-15T09:08:11 +1830ms service=bus type=session.updated publishing
ERROR 2025-11-15T09:12:55 +284229ms service=session.prompt session=ses_5793a61e1ffeJII1qOvBi9wTIy error={"error":{}} stream error
ERROR 2025-11-15T09:12:55 +3ms service=session.prompt session=ses_5793a61e1ffeJII1qOvBi9wTIy error=The operation timed out. process
INFO 2025-11-15T09:12:55 +0ms service=bus type=session.error publishing
INFO 2025-11-15T09:12:55 +4ms service=bus type=message.updated publishing
INFO 2025-11-15T09:12:55 +1ms service=bus type=message.updated publishing
INFO 2025-11-15T09:12:55 +2ms service=session.compaction pruning
INFO 2025-11-15T09:12:55 +1ms service=session.lock sessionID=ses_5793a61e1ffeJII1qOvBi9wTIy unlocked
INFO 2025-11-15T09:12:55 +0ms service=session.prompt session=ses_5793a61e1ffeJII1qOvBi9wTIy sessionID=ses_5793a61e1ffeJII1qOvBi9wTIy unlocking
INFO 2025-11-15T09:12:55 +2ms service=bus type=session.idle publishing
INFO 2025-11-15T09:12:55 +2ms service=bus type=* unsubscribing
INFO 2025-11-15T09:12:55 +0ms service=server event disconnected
INFO 2025-11-15T09:12:55 +1ms service=session.compaction pruned=0 total=0 found
INFO 2025-11-15T09:12:58 +2987ms service=server method=GET path=/event request
INFO 2025-11-15T09:12:58 +1ms service=server status=started method=GET path=/event request
INFO 2025-11-15T09:12:58 +0ms service=server event connected
INFO 2025-11-15T09:12:58 +0ms service=bus type=* subscribing
INFO 2025-11-15T09:12:58 +1ms service=server status=completed duration=1 method=GET path=/event request
INFO 2025-11-15T09:17:55 +296993ms service=bus type=* unsubscribing
INFO 2025-11-15T09:17:55 +0ms service=server event disconnected
INFO 2025-11-15T09:18:01 +6003ms service=server method=GET path=/event request
INFO 2025-11-15T09:18:01 +1ms service=server status=started method=GET path=/event request
INFO 2025-11-15T09:18:01 +0ms service=server event connected
INFO 2025-11-15T09:18:01 +1ms service=bus type=* subscribing
INFO 2025-11-15T09:18:01 +0ms service=server status=completed duration=1 method=GET path=/event request
INFO 2025-11-15T09:21:28 +207261ms service=bus type=* unsubscribing
INFO 2025-11-15T09:21:28 +0ms service=server event disconnected
INFO 2025-11-15T09:21:28 +1ms service=default worker shutting down
INFO 2025-11-15T09:21:28 +0ms service=default disposing all instances
INFO 2025-11-15T09:21:28 +1ms service=default directory=/home/igor/Plastov/lightconsole_soft/lightconsole_test_eobj disposing instance
INFO 2025-11-15T09:21:28 +1ms service=state key=/home/igor/Plastov/lightconsole_soft/lightconsole_test_eobj waiting for state disposal to complete
INFO 2025-11-15T09:21:28 +1ms service=state key=/home/igor/Plastov/lightconsole_soft/lightconsole_test_eobj state disposal completed
How to fix this issue?
Best regards,
Igor
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
github-actions commentedon Nov 15, 2025
This issue might be a duplicate of existing issues. Please check:
The core issue appears to be related to improper handling of empty
tool_calls: []arrays that some providers (including Z.ai) include in responses, causing OpenCode to hang indefinitely.Feel free to ignore if none of these address your specific case.
chetverovod commentedon Nov 15, 2025
Addition to opencode.json "tools" fieild:
Fixes connection. But maybe cuts functionality.
dumheter commentedon Nov 15, 2025
Try using the z.ai coding plan instead, it has its own auth method in opencode.
rekram1-node commentedon Nov 15, 2025
@chetverovod add this to your opencode.json:
This will override default timeout for the provider and set it to 10 minutes (timeout is in milliseconds)
rekram1-node commentedon Nov 15, 2025
The fetch automatically times out if there is no data being sent from the server at all, as long as data is being sent the connection won't timeout
mossbergmaverick commentedon Nov 15, 2025
The z.ai coding plan doesn't work with OpenCode in VS Code extension, although it works in the terminal.
rekram1-node commentedon Nov 15, 2025
@mossbergmaverick hm that doesn't make sense, is it the oauth flow not going through properly? The vscode extension just launches the tui
mossbergmaverick commentedon Nov 15, 2025
I'll describe in more detail what I mean:
I opened VSCode and launched it through the extension (I have Sonnet 4.5 as the main agent and GLM 4.6 as a sub-agent, to which tasks are delegated). I asked the agent to pass a task to the sub-agent to create a test text file in the project root. Nothing happened - the model looks like it froze. However, if I connect GLM directly and interact with it, it responds.
I just rechecked, and the problem is that GLM should request permission for write and edit operations, but the confirmation dialog doesn't appear on my end. I thought the model had simply frozen. But as I understand it now, this is related to my issue - meaning not only does ESC not work, but the confirmation dialog for executing actions is also missing.
If you need me to take any specific steps to clarify the situation, I'm ready to help.
chetverovod commentedon Nov 15, 2025
Hello, now for opencode.json:
I had got timeout after 10 minutes:
rekram1-node commentedon Nov 15, 2025
@chetverovod you can continue bumping the timeout to higher values, we can consider changing the default too I suppose
rekram1-node commentedon Nov 15, 2025
oh u can disable the timeout too using
timeout: false
rekram1-node commentedon Nov 15, 2025
@mossbergmaverick ill check it out
chetverovod commentedon Nov 15, 2025
timeout: falsedoes not change result.rekram1-node commentedon Nov 15, 2025
if you set timeout to false and restart opencode (because settings arent hot reloaded rn) it disables the fetch timeout entirely is that not happening for u?
chetverovod commentedon Nov 16, 2025
Fetch timeout is entirely disabled if used
timeout: false.rekram1-node commentedon Nov 16, 2025
yes
chetverovod commentedon Nov 16, 2025
I see this, opencode now does not generate timeouts. But dialog with Z.ai does not work.