Skip to content

feat(plugin): add goal-loop example plugin - #46328

Open
charleneleong-ai wants to merge 4 commits into
anomalyco:devfrom
charleneleong-ai:goal-loop-plugin
Open

feat(plugin): add goal-loop example plugin#46328
charleneleong-ai wants to merge 4 commits into
anomalyco:devfrom
charleneleong-ai:goal-loop-plugin

Conversation

@charleneleong-ai

@charleneleong-ai charleneleong-ai commented Aug 31, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #27167

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Example plugin showing how to build /goal and /loop using the plugin SDK. No core changes, no SQLite, no auto-continuation. Just tools + slash commands.

Turn control

The goal tool supports optional turn limits:

/goal fix the broken tests max 20 turns
/goal write documentation one task per turn
/goal refactor auth module max 10 turns one task per turn
  • maxTurns - agent stops after N turns and reports progress
  • oneTaskPerTurn - agent does exactly one step per turn, then waits

These are enforced by the slash command prompt, not hard-coded in the plugin. The agent checks goal({ action: "status" }) after each turn and stops when limits are reached.

How it is different from other PRs

#45379 (thdxr) - core implementation with auto-continuation via event worker. Ours is a pure plugin SDK example, no core changes. Different scope.

#28610 (closed) - auto-continuation via idle events + client.prompt. Ours does not do that. User drives with slash commands.

#32743 (draft) - SQLite + core runtime changes. Ours is just file-based state in .opencode/harness/.

@bojackduy/opencode-loopd - full production plugin with subagents, TUI dashboard, scheduled goals, workspace serialization. Way more complex (1000+ lines vs our ~90). Ours is a minimal example for learning the plugin SDK. Theirs is a production goal engine.

Our plugin opencode-loopd
Lines ~90 1000+
Auto-continuation No Yes (engine-driven)
Subagents No Yes (child sessions)
TUI dashboard No Yes (modal, vim-style)
Scheduled goals No Yes
State Simple JSON Complex + artifacts
License MIT AGPL-3.0
Purpose Example plugin Production tool

Free models work because the slash command injects a prompt telling the agent to call the tool. No tool-calling needed from the model side.

How did you verify your code works?

  • Plugin loads without errors on openai/gpt-4o
  • goal set/status/clear works via tool calls
  • goal with maxTurns stores limit and shows in status
  • goal with oneTaskPerTurn stores flag and shows in status
  • loop add/list/remove works via tool calls
  • /goal slash command triggers the tool with turn control

Tests

Added packages/plugin/src/examples/goal-loop.test.ts (bun:test, 10 tests):

  • goal: set + clear round-trip, status with active goal, status when no goal, set without condition
  • goal: set with maxTurns, set with oneTaskPerTurn
  • loop: add + list round-trip, remove loop, list when no loops, add without prompt

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR
opencode_goal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Add native session goals with /goal

1 participant