Context tokens resets to zero with every new action of AI agent. #2628

Closed
opened 2026-02-16 17:36:31 -05:00 by yindo · 5 comments
Owner

Originally created by @AliDem1 on GitHub (Nov 6, 2025).

Description

Stated Context tokens constantly reset to zero with every new action by the agent. running llm locally on Mac.

Image

OpenCode version

No response

Steps to reproduce

Run llm locally
Start opencode
Give AI agent a multi turn task
Watch context window constantly reset to zero

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Originally created by @AliDem1 on GitHub (Nov 6, 2025). ### Description Stated Context tokens constantly reset to zero with every new action by the agent. running llm locally on Mac. <img width="167" height="77" alt="Image" src="https://github.com/user-attachments/assets/ecead2a5-4d91-4bce-b7b1-6d1225f941f0" /> ### OpenCode version _No response_ ### Steps to reproduce Run llm locally Start opencode Give AI agent a multi turn task Watch context window constantly reset to zero ### Screenshot and/or share link _No response_ ### Operating System _No response_ ### Terminal _No response_
yindo added the bug label 2026-02-16 17:36:31 -05:00
yindo closed this issue 2026-02-16 17:36:31 -05:00
Author
Owner

@AliDem1 commented on GitHub (Nov 6, 2025):

*Running opencode version 1.0.35, but this issue has been around for a very long time now.

@AliDem1 commented on GitHub (Nov 6, 2025): *Running opencode version 1.0.35, but this issue has been around for a very long time now.
Author
Owner

@github-actions[bot] commented on GitHub (Nov 6, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #423: Context usage count is always 0 for some local openai-compatible providers - specifically reports token counts showing as 0 when using local LLM servers like LM Studio and Ollama
  • #1937: Inconsistent Session Token Count - reports similar behavior where token counts reset or regress for no apparent reason across multiple providers and models

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Nov 6, 2025): This issue might be a duplicate of existing issues. Please check: - #423: Context usage count is always 0 for some local openai-compatible providers - specifically reports token counts showing as 0 when using local LLM servers like LM Studio and Ollama - #1937: Inconsistent Session Token Count - reports similar behavior where token counts reset or regress for no apparent reason across multiple providers and models Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Nov 6, 2025):

can u show me your opencode.json that defines this model?

@rekram1-node commented on GitHub (Nov 6, 2025): can u show me your opencode.json that defines this model?
Author
Owner

@AliDem1 commented on GitHub (Nov 7, 2025):

Hiya,

can u show me your opencode.json that defines this model?

{ "$schema": "https://opencode.ai/config.json", "provider": { "mlx": { "npm": "@ai-sdk/openai-compatible", "name": "Local MLX Server", "options": { "baseURL": "http://127.0.0.1:8080/v1" }, "models": { "glm-4.6-mlx-8bit-gs32": { "name": "GLM 4.6 (MLX gs32)" }, "glm-4.5-air-mlx": { "name": "GLM 4.5 Air (MLX)" } } } }, "plugin": ["opencode-openai-codex-auth"], "mcp": { "weather": { "type": "local", "command": ["bun", "x", "@h1deya/mcp-server-weather"] }, "context7": { "type": "remote", "url": "https://mcp.context7.com/mcp", "headers": { "CONTEXT7_API_KEY": "{env:CONTEXT7_API_KEY}" } } } }

{
"$schema": "https://opencode.ai/config.json",
"provider": {
"mlx": {
"npm": "@ai-sdk/openai-compatible",
"name": "Local MLX Server",
"options": {
"baseURL": "http://127.0.0.1:8080/v1"
},
"models": {
"glm-4.6-mlx-8bit-gs32": { "name": "GLM 4.6 (MLX gs32)" },
"glm-4.5-air-mlx": { "name": "GLM 4.5 Air (MLX)" }
}
}
},
"plugin": ["opencode-openai-codex-auth"],
"mcp": {
"weather": { "type": "local", "command": ["bun", "x", "@h1deya/mcp-server-weather"] },
"context7": {
"type": "remote",
"url": "https://mcp.context7.com/mcp",
"headers": { "CONTEXT7_API_KEY": "{env:CONTEXT7_API_KEY}" }
}
}
}

@AliDem1 commented on GitHub (Nov 7, 2025): Hiya, > can u show me your opencode.json that defines this model? ` { "$schema": "https://opencode.ai/config.json", "provider": { "mlx": { "npm": "@ai-sdk/openai-compatible", "name": "Local MLX Server", "options": { "baseURL": "http://127.0.0.1:8080/v1" }, "models": { "glm-4.6-mlx-8bit-gs32": { "name": "GLM 4.6 (MLX gs32)" }, "glm-4.5-air-mlx": { "name": "GLM 4.5 Air (MLX)" } } } }, "plugin": ["opencode-openai-codex-auth"], "mcp": { "weather": { "type": "local", "command": ["bun", "x", "@h1deya/mcp-server-weather"] }, "context7": { "type": "remote", "url": "https://mcp.context7.com/mcp", "headers": { "CONTEXT7_API_KEY": "{env:CONTEXT7_API_KEY}" } } } } ` { "$schema": "https://opencode.ai/config.json", "provider": { "mlx": { "npm": "@ai-sdk/openai-compatible", "name": "Local MLX Server", "options": { "baseURL": "http://127.0.0.1:8080/v1" }, "models": { "glm-4.6-mlx-8bit-gs32": { "name": "GLM 4.6 (MLX gs32)" }, "glm-4.5-air-mlx": { "name": "GLM 4.5 Air (MLX)" } } } }, "plugin": ["opencode-openai-codex-auth"], "mcp": { "weather": { "type": "local", "command": ["bun", "x", "@h1deya/mcp-server-weather"] }, "context7": { "type": "remote", "url": "https://mcp.context7.com/mcp", "headers": { "CONTEXT7_API_KEY": "{env:CONTEXT7_API_KEY}" } } } }
Author
Owner

@rekram1-node commented on GitHub (Nov 7, 2025):

@AliDem1 are you sure your server reports tokens correctly? If they reset on every request i tend to think it reports incorrect numbers

@rekram1-node commented on GitHub (Nov 7, 2025): @AliDem1 are you sure your server reports tokens correctly? If they reset on every request i tend to think it reports incorrect numbers
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2628