The agent was halfway through a refactor. Then the session stopped with this:
Response still truncated after two output token limit continuations
The usual reaction is to raise every limit you can find and try again. Sometimes that works. Often it just moves the failure somewhere else, because the cause wasn't a low limit at all.
So before you change anything, find out where the error came from and why the response was cut. It takes five minutes, and it tells you which fix to apply.
The short version: in OpenCode 2.4.3 this error is raised by OpenCode itself, after the model hits its output limit three times in a row. The cap comes from the model's
limit.output(32,000 tokens if unset) and shrinks when the context is nearly full. Check the logs, shrink the task, set your model's real limits inopencode.jsonc, compact the session if the context is full, and file an upstream issue if a small task still fails.
Confirm where the OpenCode response truncated error came from
Truncation messages look alike across tools, so confirm the emitter first.
In OpenCode 2.4.3, the exact text "Response still truncated after two output token limit continuations" is raised in OpenCode's session runner, at line 381 of packages/core/src/session/runner/llm.ts (commit d69ee1e8). The error type is output-limit.
Here's what happens before it appears:
- The model's reply ends with the stop reason
length, meaning it ran out of output tokens. - OpenCode automatically sends a follow-up telling the model it hit the output limit, not to repeat itself, and to break the remaining work into smaller pieces.
- If the continuation is also cut off, it does that once more.
- If the last three messages are all assistant replies that ended on
length, it stops and raises the error.
Anything you type breaks that streak. So the error means the model was cut off three times running, with no input from you in between.

If your message is worded differently, it probably came from somewhere else. Hermes Agent, for example, says "Response remained truncated after 4 continuation attempts". That's a different tool with different settings, so don't copy its fixes into OpenCode.
Read the logs
Installed builds of OpenCode write logs to one file. Follow it while you reproduce the problem:
tail -f ~/.local/share/opencode/log/opencode.log
OpenCode's troubleshooting docs also suggest filtering by role or by run ID:
grep 'role=server' ~/.local/share/opencode/log/opencode.log
Note the provider, the model and the run ID around the failure. You'll need them for the fix and for any bug report.
Output truncation vs input-context overflow
These are two different problems, and people mix them up constantly.
Output truncation means the model's reply was too long for the output budget. The request was accepted, the model started writing, and it got cut off. That's the error this post covers.
Context overflow means the request itself was too big for the model's context window. OpenCode detects that from the provider's error and tries to compact the session, so you'll usually see compaction rather than this message.
Here's the part that catches people out: the two are linked.
In 2.4.3, OpenCode sets the output budget per request: it starts from the model's limit.output, or 32,000 tokens if none is set, capped at 256,000. Then it shrinks the budget to fit the room left in the context window, down to a floor of 1,024 tokens (see outputLimit() in packages/core/src/session/model-request.ts).
So a session with a nearly full context can truncate on every reply, even with a generous output limit. The fix there isn't a bigger output limit. It's more room.

| Symptom | Likely cause | Where to look |
|---|---|---|
| Truncates early in a fresh session | Output limit too low, or the task asks for one huge reply | limit.output for the model |
| Truncates late in a long session | Context almost full, so the output budget shrank | Session length; compaction |
| Fails on a local or custom model only | OpenCode's limits don't match the server's | Your provider's models entry |
| Fails on one big file write | A single tool payload larger than the budget | The task, not the config |
If a small local model keeps hitting its limits, a hosted model with a bigger output budget may be the better trade. Our guide on how to choose an LLM for your task covers that choice.
Reproduce with a small task
Start a new session with the same model and ask for something small that needs a long-ish answer. For example, a 150-line file, or one function plus its tests.
If that works, the model and limits are probably fine, and the original task was simply too big for one reply. Split it.
If even the small task truncates, the limits are wrong for this model. Move to the next section.
Check what OpenCode thinks your model's limits are
For models in OpenCode's catalog, the limits come from the catalog. For a model that isn't in the catalog, OpenCode's docs say it assumes a 200,000-token context and a 32,000-token output limit. Those are fallback assumptions, not detected values.
That matters most with local and custom servers. If your server really allows 8,192 output tokens and a 32K context, OpenCode will plan for numbers the server can't honour.
Apply only the fix the evidence supports

Pick the fix that matches what you found. Don't apply all of them.
The task is too big for one reply. Ask for the work in parts: one file at a time, or an outline first and then each section. This is what OpenCode's own continuation prompt tells the model to do.
The context is nearly full. Compact the session, or start a fresh one with a short summary. Compaction is on by default, and OpenCode's docs show how to request it yourself or keep more recent context:
{
"compaction": {
"auto": true,
"keep": { "tokens": 15000 }
}
}
The model's limits are wrong. Set the real values in the model's entry. This is the documented shape for an OpenAI-compatible local server in OpenCode 2.x:
{
"$schema": "https://opencode.ai/config.json",
"model": "local/coder",
"providers": {
"local": {
"name": "Local server",
"package": "@opencode/ai/providers/openai-compatible",
"settings": { "baseURL": "http://127.0.0.1:1234/v1" },
"models": {
"coder": {
"modelID": "model-name-on-server",
"capabilities": { "tools": true, "input": ["text"], "output": ["text"] },
"limit": { "context": 32768, "output": 8192 }
}
}
}
}
}
Use the numbers your server actually supports. OpenCode's docs are blunt about it: use the server's real model name and limits, because OpenCode can't detect whether the fallback values are accurate. If you're running the model through Ollama or LM Studio, our Ollama vs LM Studio guide covers connecting OpenCode to each.
One more note if you're migrating an old config. Version 1 used provider, options and npm. In 2.x it's providers, settings and package.
The provider ignores the output limit. Some OpenAI-compatible servers expect max_tokens rather than max_completion_tokens. OpenCode's model options include maxTokensField for that case; check the models docs for where it goes before you set it.
Retest, then file an OpenCode issue
Rerun the small task, then the original one. If the small task passes and the big one still truncates, the task needs splitting. That's not a bug.
If a small task still fails with correct limits and a fresh session, report it. OpenCode's troubleshooting docs ask for relevant log lines with their run and role fields, and ask you to strip API keys, prompts and file contents first.
A useful report includes:
- OpenCode version (
opencode --version) - Provider, model ID and the
limitvalues in your config - Whether the session was fresh or long-running
- The smallest prompt that reproduces it
- The log lines around the failure, with secrets removed
Running local models for agents rather than for coding? BetterClaw Desktop shares local Ollama, LM Studio or llama.cpp models with BetterClaw agents on a Mac with Apple silicon, and our local models docs cover the setup.
Fix the cause, not the symptom
Here's the honest takeaway.
Truncation errors invite a quick fix: raise the number and retry. But the number is often fine.
A full context, a mismatched local server or an oversized task is the real cause more often than a low limit.
Read the log, reproduce it small, and change one thing at a time. You'll fix it faster, and you'll know why it broke.
If you'd rather spend that time on the work than on agent plumbing, start free with BetterClaw.
The free plan includes 100 credits a month, and you bring your own model key, so you still pay your provider for inference (see full pricing). We handle the infrastructure. You handle the interesting part.
Frequently Asked Questions
What does "Response still truncated after two output token limit continuations" mean in OpenCode?
The model hit its output token limit three times in a row: the first reply plus two automatic continuations. OpenCode then stops the run instead of looping. In 2.4.3 it's raised by OpenCode itself, in its session runner.
How does output truncation compare to a context window overflow?
Truncation means the reply was too long for the output budget; overflow means the request was too big for the context window. OpenCode handles overflow by compacting the session. The two interact: a nearly full context shrinks the output budget, which causes truncation.
How do I increase the output token limit in OpenCode?
Set limit.output on the model in opencode.jsonc, under providers.<provider>.models.<model>. Use a value the model and server actually support. For an uncatalogued model, OpenCode assumes 32,000 if you don't set it.
Does raising the output limit cost more?
The limit itself is only a ceiling. On a paid API you pay for the tokens the model actually generates, so longer replies cost more, and a higher limit lets them get longer. Splitting a big task into smaller replies often costs about the same and fails less.
Is it safe to copy Hermes Agent's truncation settings into OpenCode?
No. Hermes uses different wording, different retry logic and a different config format. Use only the keys in OpenCode's own docs, and change one setting at a time.




