Skip to content

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

Closed

Description

@AliDem1

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

Activity

  1. changed the title [-]Context tokens reset with every new action of ai agent[/-] [+]Context tokens resets to zero with every new action of AI agent.[/+] on Nov 6, 2025
  2. AliDem1 commented on Nov 6, 2025

    @AliDem1
    Author

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

  3. github-actions commented on Nov 6, 2025

    @github-actions
    Contributor

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

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

  4. rekram1-node commented on Nov 6, 2025

    @rekram1-node
    Contributor

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

  5. AliDem1 commented on Nov 7, 2025

    @AliDem1
    Author

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

  6. rekram1-node commented on Nov 7, 2025

    @rekram1-node
    Contributor

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions