Build Agent stops working randomly and asks for continuation #1750

Closed
opened 2026-02-16 17:32:27 -05:00 by yindo · 26 comments
Owner

Originally created by @fraenky8 on GitHub (Sep 17, 2025).

Originally assigned to: @thdxr on GitHub.

  1. In BUILD AGENT mode
  2. Go programming language repository
  3. Github Copilot with Claude Sonnet 4
  4. I give it a precise prompt to fix some unit tests, even with an example, pointing to the test and file itself.
  5. It starts planning, reads the file.
  6. Stops and asks if it should continue.
  • What am I doing wrong or do I miss something?
  • Why is it not just continuing what it got asked for?

See screenshot:

Image

My config:

{
    "$schema": "https://opencode.ai/config.json",
    "theme": "opencode",
    "share": "disabled"
}
Originally created by @fraenky8 on GitHub (Sep 17, 2025). Originally assigned to: @thdxr on GitHub. 1. In BUILD AGENT mode 2. Go programming language repository 3. Github Copilot with Claude Sonnet 4 4. I give it a precise prompt to fix some unit tests, even with an example, pointing to the test and file itself. 5. It starts planning, reads the file. 6. Stops and asks if it should continue. ❌ - What am I doing wrong or do I miss something? - Why is it not just continuing what it got asked for? See screenshot: <img width="1492" height="852" alt="Image" src="https://github.com/user-attachments/assets/09413b95-50c1-4532-9dce-16ee189758e8" /> My config: ``` { "$schema": "https://opencode.ai/config.json", "theme": "opencode", "share": "disabled" } ```
yindo closed this issue 2026-02-16 17:32:27 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Sep 17, 2025):

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

  • #2438: Similar behavior where agent freezes on "working..." with no changes and becomes unresponsive
  • #2512: Agent gets stuck in "generating" state and becomes unresponsive to interrupts

Both issues describe similar symptoms of agents stopping unexpectedly and not continuing as expected, which aligns with your experience of the Build Agent stopping and asking for continuation.

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

@github-actions[bot] commented on GitHub (Sep 17, 2025): This issue might be a duplicate of existing issues. Please check: - #2438: Similar behavior where agent freezes on "working..." with no changes and becomes unresponsive - #2512: Agent gets stuck in "generating" state and becomes unresponsive to interrupts Both issues describe similar symptoms of agents stopping unexpectedly and not continuing as expected, which aligns with your experience of the Build Agent stopping and asking for continuation. Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Sep 17, 2025):

How often have you seen this? I dont think I really encounter this with sonnet much, now I will say given what I see in the screenshot that huge burst of context could be confusing the llm

Can you maybe share your original prompt? or ask it “repeat our conversation so far”

Ik you disabled share so you probably arent up for that but that could help me see if maybe there is a bug but I tend to think this is just the model misbehaving which happens every so oftej

@rekram1-node commented on GitHub (Sep 17, 2025): How often have you seen this? I dont think I really encounter this with sonnet much, now I will say given what I see in the screenshot that huge burst of context could be confusing the llm Can you maybe share your original prompt? or ask it “repeat our conversation so far” Ik you disabled share so you probably arent up for that but that could help me see if maybe there is a bug but I tend to think this is just the model misbehaving which happens every so oftej
Author
Owner

@fraenky8 commented on GitHub (Sep 17, 2025):

How often have you seen this? I dont think I really encounter this with sonnet much, now I will say given what I see in the screenshot that huge burst of context could be confusing the llm
...
but I tend to think this is just the model misbehaving which happens every so oftej

Since yesterday, couple of times.

It works usually fine tho, I noticed couple of weeks back it was running smooth and even at 200k++ tokens (before auto-compaction and pruning and what not) it was giving the expected output. Having these 30k tokens only after reading the file doesn't bother me much. But I'm also not an expert here, only a user.

Can you maybe share your original prompt?

Something like this:

Fix the failing unit tests of `TestConfig_load` in @config/config_test.go . Setup the ProviderEnv: use the same values as A provider test case but  prefix every value with `env-`. Check the SENTRY_DSN setup. 

Ik you disabled share so you probably arent up for that but that could help me see if maybe there is a bug

Yeah sry about that, but I rather try to be cautious here and not oversharing something the company doesn't want to be shared.

@fraenky8 commented on GitHub (Sep 17, 2025): > How often have you seen this? I dont think I really encounter this with sonnet much, now I will say given what I see in the screenshot that huge burst of context could be confusing the llm > ... > but I tend to think this is just the model misbehaving which happens every so oftej Since yesterday, couple of times. It works usually fine tho, I noticed couple of weeks back it was running smooth and even at 200k++ tokens (before auto-compaction and pruning and what not) it was giving the expected output. Having these 30k tokens only after reading the file doesn't bother me much. But I'm also not an expert here, only a user. > Can you maybe share your original prompt? Something like this: ``` Fix the failing unit tests of `TestConfig_load` in @config/config_test.go . Setup the ProviderEnv: use the same values as A provider test case but prefix every value with `env-`. Check the SENTRY_DSN setup. ``` > Ik you disabled share so you probably arent up for that but that could help me see if maybe there is a bug Yeah sry about that, but I rather try to be cautious here and not oversharing something the company doesn't want to be shared.
Author
Owner

@rekram1-node commented on GitHub (Sep 17, 2025):

makes sense, thanks for info

@rekram1-node commented on GitHub (Sep 17, 2025): makes sense, thanks for info
Author
Owner

@zelenkovsky commented on GitHub (Sep 18, 2025):

It's reaching 99% of the context window with Sonnet 4 (via GitHub), starting to auto-compact the conversation after the first question is asked, and then interrupting the execution. 100% reproducible. It worked before. Something got definitely broken, it reaches the context window too fast.

Image
@zelenkovsky commented on GitHub (Sep 18, 2025): It's reaching 99% of the context window with Sonnet 4 (via GitHub), starting to auto-compact the conversation after the first question is asked, and then interrupting the execution. 100% reproducible. It worked before. Something got definitely broken, it reaches the context window too fast. <img width="1827" height="928" alt="Image" src="https://github.com/user-attachments/assets/539bc6af-e19f-4bbf-a22c-fbe47c38d538" />
Author
Owner

@fraenky8 commented on GitHub (Sep 18, 2025):

Running with OPENCODE_DISABLE_AUTOCOMPACT=true opencode seems to work better, no random interruptions or stopping. It ran smooth up to 279k/210% and finished what I asked for 😬

@fraenky8 commented on GitHub (Sep 18, 2025): Running with `OPENCODE_DISABLE_AUTOCOMPACT=true opencode` seems to work better, no random interruptions or stopping. It ran smooth up to 279k/210% and finished what I asked for 😬
Author
Owner

@fraenky8 commented on GitHub (Sep 18, 2025):

Not sure if that helps as well, but I ran into

AI_APICallError: prompt token count of 132296 exceeds the limit of 128000

Whereas the counter top right says 371K/289%.

@fraenky8 commented on GitHub (Sep 18, 2025): Not sure if that helps as well, but I ran into ``` AI_APICallError: prompt token count of 132296 exceeds the limit of 128000 ``` Whereas the counter top right says `371K/289%`.
Author
Owner

@shantur commented on GitHub (Sep 18, 2025):

I keep seeing this too

AI_APICallError: input length and `max_tokens` exceed context limit: 173718 + 32000 > 200000, decrease input length or `max_tokens` and try again
@shantur commented on GitHub (Sep 18, 2025): I keep seeing this too ``` AI_APICallError: input length and `max_tokens` exceed context limit: 173718 + 32000 > 200000, decrease input length or `max_tokens` and try again ```
Author
Owner

@zelenkovsky commented on GitHub (Sep 19, 2025):

I found the problem!!! opencode takes the model parameters from models.dev website, this website holds outdated information regarding the Sonnet 4 from Anthropic. According to the following article, 1M tokens are supported: https://www.anthropic.com/news/1m-context while models.dev reports 200k or even 128 for github-copilot version.

I've added the following configuration file to set 1M token output and automatic /summary stopped happening. Previously it was happening after the first question.

{
    "$schema": "https://opencode.ai/config.json",
    "provider": {
        "github-copilot": {
            "models": {
                "claude-sonnet-4": {
                    "limit": {
                        "context": 1000000,
                        "output": 64000
                    }
                }
            }
        },
        "anthropic": {
            "models": {
                "claude-sonnet-4-20250514": {
                    "limit": {
                        "context": 1000000,
                        "output": 64000
                    }
                }
            }
        }
    }
}
@zelenkovsky commented on GitHub (Sep 19, 2025): I found the problem!!! `opencode` takes the model parameters from models.dev website, this website holds outdated information regarding the Sonnet 4 from Anthropic. According to the following article, 1M tokens are supported: https://www.anthropic.com/news/1m-context while models.dev reports 200k or even 128 for github-copilot version. I've added the following configuration file to set 1M token output and automatic /summary stopped happening. Previously it was happening after the first question. ``` { "$schema": "https://opencode.ai/config.json", "provider": { "github-copilot": { "models": { "claude-sonnet-4": { "limit": { "context": 1000000, "output": 64000 } } } }, "anthropic": { "models": { "claude-sonnet-4-20250514": { "limit": { "context": 1000000, "output": 64000 } } } } } } ```
Author
Owner

@rekram1-node commented on GitHub (Sep 19, 2025):

@zelenkovsky github copilot has actual limits that differ from what anthropic has, I will check and see if they bumped the context window size but last I checked it was still 128k

Also for the claude w/ anthropic that isn't wrong either you can only get 1,000,000 context through the api w/ api key you cannot use your max plan and use the 1,000,000 context length

@rekram1-node commented on GitHub (Sep 19, 2025): @zelenkovsky github copilot has actual limits that differ from what anthropic has, I will check and see if they bumped the context window size but last I checked it was still 128k Also for the claude w/ anthropic that isn't wrong either you can only get 1,000,000 context through the api w/ api key you cannot use your max plan and use the 1,000,000 context length
Author
Owner

@rekram1-node commented on GitHub (Sep 19, 2025):

Yeah just verified using copilot api the cap is 128k:

{
  "max_context_window_tokens": 128000,
  "max_output_tokens": 16000,
  "max_prompt_tokens": 128000,
  "vision": {
    "max_prompt_image_size": 3145728,
    "max_prompt_images": 5,
    "supported_media_types": [
      "image/jpeg",
      "image/png",
      "image/webp"
    ]
  }
}

@zelenkovsky the limits on models.dev are correct

@rekram1-node commented on GitHub (Sep 19, 2025): Yeah just verified using copilot api the cap is 128k: ``` { "max_context_window_tokens": 128000, "max_output_tokens": 16000, "max_prompt_tokens": 128000, "vision": { "max_prompt_image_size": 3145728, "max_prompt_images": 5, "supported_media_types": [ "image/jpeg", "image/png", "image/webp" ] } } ``` @zelenkovsky the limits on models.dev are correct
Author
Owner

@zelenkovsky commented on GitHub (Sep 19, 2025):

I guess you are right. However, with correct limits, opencode is unusable. Every question leads to compacting, and it loses the context. I've got the impression that it did not happen before. What could be the reason? Too many MCP servers enabled or too long instruction file? I did not really change much in the environment.

@zelenkovsky commented on GitHub (Sep 19, 2025): I guess you are right. However, with correct limits, opencode is unusable. Every question leads to compacting, and it loses the context. I've got the impression that it did not happen before. What could be the reason? Too many MCP servers enabled or too long instruction file? I did not really change much in the environment.
Author
Owner

@rekram1-node commented on GitHub (Sep 19, 2025):

how long are these sessions you are doing? is this specifically with github copilot?

It’s weird I have heard this a few times but I rarely experience compacts

@rekram1-node commented on GitHub (Sep 19, 2025): how long are these sessions you are doing? is this specifically with github copilot? It’s weird I have heard this a few times but I rarely experience compacts
Author
Owner

@zelenkovsky commented on GitHub (Sep 20, 2025):

Here is an example: it uses two tools and starts compacting:
https://opencode.ai/s/oDC24Svi

@zelenkovsky commented on GitHub (Sep 20, 2025): Here is an example: it uses two tools and starts compacting: https://opencode.ai/s/oDC24Svi
Author
Owner

@rekram1-node commented on GitHub (Sep 20, 2025):

@zelenkovsky did you unshare? link seems invalid

maybe you can /unshare and then do /share again

@rekram1-node commented on GitHub (Sep 20, 2025): @zelenkovsky did you unshare? link seems invalid maybe you can /unshare and then do /share again
Author
Owner

@zelenkovsky commented on GitHub (Sep 20, 2025):

Sorry, I didn't know that deleting the session locally would also remove the shared one.
Here is a new one: https://opencode.ai/s/ugoe6wBw

@zelenkovsky commented on GitHub (Sep 20, 2025): Sorry, I didn't know that deleting the session locally would also remove the shared one. Here is a new one: https://opencode.ai/s/ugoe6wBw
Author
Owner

@zelenkovsky commented on GitHub (Sep 20, 2025):

Search for "Conversation Summary", this is when compacting happened.

@zelenkovsky commented on GitHub (Sep 20, 2025): Search for "Conversation Summary", this is when compacting happened.
Author
Owner

@rekram1-node commented on GitHub (Sep 20, 2025):

It looks like this is happening due to your massive polygon_list_ticker_news mcp tool?

That absolutely obliterates context so with a github copilot model limited to 128k im not surprised it is having issues tbh

not to say we cant be better but this is definitely less than idea situation to begin with

@rekram1-node commented on GitHub (Sep 20, 2025): It looks like this is happening due to your massive polygon_list_ticker_news mcp tool? That absolutely obliterates context so with a github copilot model limited to 128k im not surprised it is having issues tbh not to say we cant be better but this is definitely less than idea situation to begin with
Author
Owner

@zelenkovsky commented on GitHub (Sep 20, 2025):

Well, I suddenly realized that disabling other MCP servers gave me enough room to finish the research. This means that MCP server prompts also consume a significant number of tokens. Can we enable MCP per Agent? That would make so much sense. Otherwise, my Trading Agent suddenly knows how to search in Trello and review MRs in GitLab. I would turn off all unnecessary MCP servers for this agent.

@zelenkovsky commented on GitHub (Sep 20, 2025): Well, I suddenly realized that disabling other MCP servers gave me enough room to finish the research. This means that MCP server prompts also consume a significant number of tokens. Can we enable MCP per Agent? That would make so much sense. Otherwise, my Trading Agent suddenly knows how to search in Trello and review MRs in GitLab. I would turn off all unnecessary MCP servers for this agent.
Author
Owner

@rekram1-node commented on GitHub (Sep 20, 2025):

@zelenkovsky yes you can disable mcps per agent using "tools" in your config, ex:

in global one disable: "polygon_" and then for the one agent explicitly enable using "polygon_": true

ex:
"tools": {
"mymcp_*": false,
"write": false,
"edit": false
}

read more here: https://opencode.ai/docs/agents/#tools

@rekram1-node commented on GitHub (Sep 20, 2025): @zelenkovsky yes you can disable mcps per agent using "tools" in your config, ex: in global one disable: "polygon_*" and then for the one agent explicitly enable using "polygon_*": true ex: "tools": { "mymcp_*": false, "write": false, "edit": false } read more here: https://opencode.ai/docs/agents/#tools
Author
Owner

@trystan2k commented on GitHub (Sep 20, 2025):

I am also facing this issue, which wasn't happening in previous versions of opencode. My project configuration didn't changed by from 0.9.x versions it started to compact with just one prompt too. I disabled some MCPs and it got better, but still compacting at second or third iteration, when using sonnet 4 with github copilot.

Yesterday I ran opencode with auto compact disabled and could run a complete session without problem. The counting was showing 250% and it was working without problem.

Maybe copilot changed the limit but didn't update docs? Or it would still work but can start to malfunction with such a big context?

@trystan2k commented on GitHub (Sep 20, 2025): I am also facing this issue, which wasn't happening in previous versions of opencode. My project configuration didn't changed by from 0.9.x versions it started to compact with just one prompt too. I disabled some MCPs and it got better, but still compacting at second or third iteration, when using sonnet 4 with github copilot. Yesterday I ran opencode with auto compact disabled and could run a complete session without problem. The counting was showing 250% and it was working without problem. Maybe copilot changed the limit but didn't update docs? Or it would still work but can start to malfunction with such a big context?
Author
Owner

@zelenkovsky commented on GitHub (Sep 20, 2025):

I've disabled tools in the config for build and plan agents, then enabled them for each custom agent. That saved me.

However, I really miss an option to disable all servers or enable all, plus I want the MCP tools not mentioned explicitly to be disabled. I now need to write for each agent about each MCP server I have, specifying whether I want to disable it.

@zelenkovsky commented on GitHub (Sep 20, 2025): I've disabled tools in the config for build and plan agents, then enabled them for each custom agent. That saved me. However, I really miss an option to disable all servers or enable all, plus I want the MCP tools not mentioned explicitly to be disabled. I now need to write for each agent about each MCP server I have, specifying whether I want to disable it.
Author
Owner

@rekram1-node commented on GitHub (Sep 20, 2025):

@zelenkovsky you can enable and disable all at the top level in your config, you dont have to do it for every agent.

plus I want the MCP tools not mentioned explicitly to be disabled

What do you mean by that? Not mentioned where?

I now need to write for each agent about each MCP server I have, specifying whether I want to disable it.

No, the mcp is enabled by default right so you can explicitly disable for one or more agents. OR you could at the top level in your opencode.json specify (at the "top level" not in an agent definition):

{
  "tools": {
    "mymcp_*": false
  }
}

So that the mcp server would be disabled by default and then you could explicitly enable for one or more agents

@rekram1-node commented on GitHub (Sep 20, 2025): @zelenkovsky you can enable and disable all at the top level in your config, you dont have to do it for every agent. > plus I want the MCP tools not mentioned explicitly to be disabled What do you mean by that? Not mentioned where? > I now need to write for each agent about each MCP server I have, specifying whether I want to disable it. No, the mcp is enabled by default right so you can explicitly disable for one or more agents. OR you could at the top level in your opencode.json specify (at the "top level" not in an agent definition): ``` { "tools": { "mymcp_*": false } } ``` So that the mcp server would be disabled by default and then you could explicitly enable for one or more agents
Author
Owner

@zelenkovsky commented on GitHub (Sep 22, 2025):

@rekram1-node, I've disabled MCP servers globally, and re-enabled per agent. That helped to save context. Thanks.

@zelenkovsky commented on GitHub (Sep 22, 2025): @rekram1-node, I've disabled MCP servers globally, and re-enabled per agent. That helped to save context. Thanks.
Author
Owner

@zelenkovsky commented on GitHub (Sep 22, 2025):

In general, this issue is understood:

  • compacting hits suddenly if the context is polluted (occupied)
  • by extra MCP tool prompts or by MCP tool responses.
  • With models like GitHub/Sonnet 4 (where context is limited to 128k), that happens almost instantly.
  • At the same time, experience shows that model providers are not rejecting queries with context slightly larger than advertised.
  • Some users report 125% or higher without getting rejections (can some explain that?)

So, @rekram1-node, what should we do with this issue? Should we close this issue?

NOTE: Currently, compacting interrupts the flow. Can we somehow indicate explicitly in the chat history compacting event? And continue without the user needing to type "retry" or "continue".

@zelenkovsky commented on GitHub (Sep 22, 2025): In general, this issue is understood: * compacting hits suddenly if the context is polluted (occupied) * by extra MCP tool prompts or by MCP tool responses. * With models like GitHub/Sonnet 4 (where context is limited to 128k), that happens almost instantly. * At the same time, experience shows that model providers are not rejecting queries with context slightly larger than advertised. * Some users report 125% or higher without getting rejections (can some explain that?) So, @rekram1-node, what should we do with this issue? Should we close this issue? NOTE: Currently, compacting interrupts the flow. Can we somehow indicate explicitly in the chat history compacting event? And continue without the user needing to type "retry" or "continue".
Author
Owner

@rekram1-node commented on GitHub (Sep 22, 2025):

The original issue here was that I think compacts were being hidden and that should be fixed on latest. If this continues happening lmk

Some users report 125% or higher without getting rejections (can some explain that?)

I can't explain without seeing specific example :) If you can send a session I can probably explain why

NOTE: Currently, compacting interrupts the flow. Can we somehow indicate explicitly in the chat history compacting event? And continue without the user needing to type "retry" or "continue".

this could probably be done need to play with compacts more to see how they behave there are a few different cases to think about

@rekram1-node commented on GitHub (Sep 22, 2025): The original issue here was that I think compacts were being hidden and that should be fixed on latest. If this continues happening lmk > Some users report 125% or higher without getting rejections (can some explain that?) I can't explain without seeing specific example :) If you can send a session I can probably explain why > NOTE: Currently, compacting interrupts the flow. Can we somehow indicate explicitly in the chat history compacting event? And continue without the user needing to type "retry" or "continue". this could probably be done need to play with compacts more to see how they behave there are a few different cases to think about
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1750