Overview
opencode-goal-plugin is a persistent /goal command for OpenCode 2. It allows users to set a standing goal, and the agent continues working on it across turns until the goal is achieved, judged unachievable, stalled, or out of turns. The plugin targets OpenCode 2.0.18 and the V2 plugin API (@opencode/plugin ^2.0.18) and does not work on OpenCode 1.x. It is implemented as a V2 server plugin because custom commands cannot react to turn completion, call a model outside the conversation, or feed a prompt back into a session.
The plugin works by storing the goal against the current session and submitting the first turn. When the turn settles, a judge model reads the goal and the agent's last reply and returns strict JSON with a verdict of done, blocked, or continue. If the verdict is continue, a continuation prompt is posted back into the same session, and the loop repeats. The judge is called through ctx.generate.text, which creates no session and adds nothing to the transcript. By default it runs on the same model as the session, but a smaller fast model can be configured to reduce cost.
Features include standing goals that survive across turns and OpenCode restarts, completion contracts with verify, constraints, scope, and stop when lines, five independent stop conditions (three deterministic), per-session state, user messages always winning, and status control via /goal status, pause, resume, and clear. The plugin can be installed globally, as a configured package plugin, or per project. Options such as maxTurns, stallLimit, pollLimit, judgeModel, quiet, and verifyTimeoutMs can be configured via the plugins array in opencode.json.
Pricing
Free
Detailed plans have not been confirmed in our catalog. Check the official website for current limits and billing terms.
Visit WebsitePrices and limits may change. Confirm the currency, billing period, seat minimum and usage caps on the official website.
Use Cases
- Developers use the plugin to set a standing goal that the agent works on across multiple turns without needing to re-prompt.
- Teams use completion contracts to define what "done" means for a goal, including verification commands and constraints.
- Users can run multiple unrelated goals simultaneously across different projects because goals are keyed by session ID.
- Operators use the five independent stop conditions to prevent runaway loops from burning budgets unattended.
- Users can pause, resume, or clear goals using subcommands to control the loop's behavior.
- Teams can configure a smaller, faster judge model to reduce the cost of each turn's verdict.
Features
Set persistent goals in OpenCode
Keep working toward a standing goal
Stop when the goal is complete
Recognize blocked goal progress
Recognize stalled goal progress
Stop when turns run out
Reviews
No reviews yet. Be the first to share your experience!
FAQ
What does the /goal command do?
It sets a standing goal for OpenCode 2 so work can continue until the goal is done, blocked, stalled, or out of turns.
Is this intended for one-step questions?
Its persistent-goal design is especially relevant when a task takes multiple turns or steps.
Does the description guarantee recovery after restarting a session?
No. The supplied description does not explain storage or restart behavior; consult the repository for those details.