opencode-auto-continue
An OpenCode plugin that automatically continues responses cut off by the model's output limit.
The problem
Large-context models sometimes stop mid-answer — the response gets truncated by the output token cap (or the model enters a long reasoning loop and hits it), leaving you with half a file, a broken diff, or an unfinished explanation. You then have to type "continue" manually… over and over.
If you've experienced this, you know exactly how annoying it is:

The solution
This plugin watches your session from the outside. When the assistant's last message:
- ends with
finish: "length"/ aMessageOutputLengthError, or - crosses a soft limit of output tokens (~88% of the cap),
it automatically injects a continuation prompt telling the model to pick up exactly where it left off — no repetition.

Guardrails
| Guardrail | Default |
|---|---|
| Max auto-continues per user turn (anti infinite-loop) | 3 |
| Counter resets when you send a new message | ✓ |
| Soft limit well below the cap (catches "finished but glued to the cap") | 115k tokens |
| Silent failure (never breaks your session) | ✓ |
Install
npm install @fazaboa/opencode-auto-continue
Then register it in your opencode.json:
{
"plugin": ["@fazaboa/opencode-auto-continue"]
}
Or drop the source file directly into .opencode/plugins/auto-continue.ts in your project — it's a single self-contained file.
Configuration (optional)
{
"plugin": [
[
"opencode-auto-continue",
{
"outputSoftLimit": 115000,
"maxAutoContinues": 3,
"continueText": "[auto-continue] Continue exactly where you left off."
}
]
]
}
| Option | Type | Default | Description |
|---|---|---|---|
outputSoftLimit |
number |
115_000 |
Output-token threshold that triggers a continue |
maxAutoContinues |
number |
3 |
Max continuations per user turn |
continueText |
string |
(see source) | The prompt injected on continue |
Programmatic usage:
import { autoContinue } from "@fazaboa/opencode-auto-continue"
export const AutoContinuePlugin = autoContinue({ maxAutoContinues: 5 })
How it works
- Listens for OpenCode events.
- On
session.idle, fetches the session's messages via the SDK client. - Checks the last assistant message for truncation (
finish === "length"/MessageOutputLengthError) or output tokens ≥ soft limit. - If triggered, sends a
promptAsyncwith the continuation text and increments the per-session counter. - A new user message resets the counter.