Skip to content

LM Studio + concurrent agents + unified KV cache = opencode runs past context limits, API errors, and gets stuck in a retry loop #50347

Description

@machineonamission

Description

this is a very weird combination of settings.

i'm running opencode with an LLM via LM Studio on my somewhat modest RTX 5070 Ti

So: llama.cpp/lm studio has experimental concurrent agent settings.

opencode already makes full use of this, and autodiscovers lm studio and the agent is able to use concurrent and subagents amazinglky.

BUT: the unified kv cache causes an issue.

unified kv cache means the context window memory is shared among concurrently executing agents. this is useful because it makes it possible at all to have concurrent execution within memory limitations.

opencode isn't aware of this yet, and treats each subagent as if it has its own copy of the full context window.

so it runs the agents in parallel until the unified kv cache fills, but opencode has no idea that it has until lm studio sends back an API error, which opencode just entirely aborts and retries the subagent, but this doesn't actually fix the issue most of the time.

would it be possible for opencode to be aware of unified kv cache and manage subagents with that in mind?

Plugins

none i dont think

OpenCode version

2.0.12 desktop

Steps to reproduce

Launch 5 or more concurrent general subagents simultaneously, each requesting substantial context (file reads, glob searches, grep operations, git history — anything that produces long LLM responses). Use the same model for all agents

- M2

Screenshot and/or share link

Image

Operating System

windows 11 x64

Terminal

opencode desktop app lol

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions