You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE]: /goal: let plugins declare background work in SessionIdle.background #60860
I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Problem
/goal's idle judge (packages/core/src/plugin/goal.ts, v2.2.5) only sees background work the host itself tracks in SessionIdle.background: subagent, image and shell. It skips judging while the Session's own subagent or image job runs (lines 150–153). It offers wait only while one of the Session's own shells runs (lines 126–127).
A plugin can run work in other sessions and wake this one when that work finishes, but it has no way to say so. opencode-courier, for example, spawns child sessions that report back to their parent with a session.synthetic message. So a root with an active goal that spawns children and ends its turn to wait for their reports looks finished or stalled to the judge. The judge answers continue, the root is prompted on instead of waiting, and after MAX_STALLS rounds the goal pauses with "Not making progress".
Reproduced on 2.2.4 with a scripted reviewer: three continuations within a second of the spawn, then the goal paused, 25 s before the child reported. The same happened with children created with parentID set to the root.
Proposal
Let a plugin add entries to SessionIdle.background for a session, for example:
{kind: "plugin", sessionID,description: string}
/goal would treat these the way it treats a subagent: the plugin's own wake (a synthetic message) runs the hook again, so the judge can simply return. It could also offer wait for them. Its WAIT_LIMIT watchdog would still pause a goal whose plugin work never reports.
Another option: let /goal hold back while any plugin reports pending work for the session, through a hook or a field on the idle event.
A plugin's own experimental.idle hook can't work around this: built-in hooks run before package plugins (plugin/supervisor.ts), so /goal's continuation is already admitted when ours runs.
Thanks for the detailed write-up and the repro, @ivopogace!
To restate the request: plugins should be able to declare pending background work for a session, for example a { kind: "plugin", sessionID, description } entry in SessionIdle.background. /goal could then skip judging, or offer wait, while that work runs, the same way it handles the session's own subagents and shells.
I checked v2.2.5. SessionIdleBackground only covers work the host tracks itself, and built-in idle hooks run before package plugins. So a plugin can't add this on its own today; it needs a change to the plugin API. Maintainers will consider it.
Following this as the author of opencode-dev-framework — my completion gate currently re-prompts through experimental.idle → session.synthetic with its own bound, while /goal judges the same turn, so the two continuations step on each other and I have no way to tell the judge my gate work is still pending. Being able to declare that background work would make them deterministic (no race).
Your benchmarking case is the same shape as the courier one in the issue (work the host can't see, wake arrives from outside), which is useful: two independent cases makes it a general API gap, not a one-plugin quirk.
I've been through this area for my own gate work, so to save you some digging:
the host entries get built in packages/core/src/session/background.ts from Job recovery records, the public type is SessionIdleBackground in the plugin session types, and the judge lives in packages/core/src/plugin/goal.ts (idle() skips on own subagent/image work, offers wait only for shells).
The consumer half is small — treat a plugin entry like a subagent for the skip, and only offer wait if the plugin guarantees a wake, otherwise WAIT_LIMIT pauses it, which is the right backstop anyway.
The real design question is the producer side: where a plugin declares "I'm waiting on X" and how that gets cleaned up. That's the piece worth sketching first, even roughly, before writing code.
One practical tip: keep the PR to type + registry + goal handling + tests, modeled on session-background.test.ts and subagent-idle-e2e.test.ts. Small ones move fastest here — review bandwidth is thin.
And if it helps, I'm happy to test against opencode-dev-framework. My completion gate hits the exact same race (my re-prompt vs /goal's continuation, no way to declare pending work), so you'd have a second consumer from day one.
The goal state is not reachable from a plugin. The built-in goal exposes get plus a changed event, so a plugin can read a goal but cannot re-limit
or drive it - every alternative has to reimplement the judge and the stall
logic. That is exactly what we ended up doing (we ported MiniMax Code's agent-modules/goal, which has no external judge: the agent proposes the
terminal state and the host settles it).
Background work cannot be declared from a plugin. Our continuation often
waits on work started outside the session (a quota wake-up, an external
worker), and there is no way to tell the idle judge that the session is
waiting rather than finished.
We are not asking for a specific API. What would help is either:
Activity
opencodejr commentedon Oct 31, 2026
Thanks for the detailed write-up and the repro, @ivopogace!
To restate the request: plugins should be able to declare pending background work for a session, for example a
{ kind: "plugin", sessionID, description }entry inSessionIdle.background./goalcould then skip judging, or offerwait, while that work runs, the same way it handles the session's own subagents and shells.I checked v2.2.5.
SessionIdleBackgroundonly covers work the host tracks itself, and built-in idle hooks run before package plugins. So a plugin can't add this on its own today; it needs a change to the plugin API. Maintainers will consider it.Related:
experimental.stoppinghook that could veto completion/goalon top of the session idle hookjwitmann commentedon Nov 5, 2026
Following this as the author of opencode-dev-framework — my completion gate currently re-prompts through
experimental.idle→session.syntheticwith its own bound, while/goaljudges the same turn, so the two continuations step on each other and I have no way to tell the judge my gate work is still pending. Being able to declare that background work would make them deterministic (no race).chenpao7 commentedon Nov 24, 2026
I'm experiencing a similar issue with callback-driven remote GPU benchmarking.
I'd be interested in trying to work on this. I'm still getting familiar with the OpenCode codebase, but I'll do my best to explore a solution.
Any suggestions or guidance would be greatly appreciated. Thank you!
jwitmann commentedon Nov 25, 2026
Your benchmarking case is the same shape as the courier one in the issue (work the host can't see, wake arrives from outside), which is useful: two independent cases makes it a general API gap, not a one-plugin quirk.
I've been through this area for my own gate work, so to save you some digging:
packages/core/src/session/background.tsfrom Job recovery records, the public type isSessionIdleBackgroundin the plugin session types, and the judge lives inpackages/core/src/plugin/goal.ts(idle()skips on own subagent/image work, offerswaitonly for shells).waitif the plugin guarantees a wake, otherwiseWAIT_LIMITpauses it, which is the right backstop anyway.One practical tip: keep the PR to type + registry + goal handling + tests, modeled on
session-background.test.tsandsubagent-idle-e2e.test.ts. Small ones move fastest here — review bandwidth is thin.And if it helps, I'm happy to test against opencode-dev-framework. My completion gate hits the exact same race (my re-prompt vs /goal's continuation, no way to declare pending work), so you'd have a second consumer from day one.
iniaki662 commentedon Nov 29, 2026
We run the goal loop from a plugin rather than the built-in
opencode.goal, sowe hit the limitation described here from the other side.
Our plugin (
thread-goal, https://github.com/iniaki662/opencode-thread-goal)keeps its own state in plugin storage and drives continuation from the idle hook.
Two consequences of the built-in design that a plugin-owned goal has to work
around:
getplus achangedevent, so a plugin can read a goal but cannot re-limitor drive it - every alternative has to reimplement the judge and the stall
logic. That is exactly what we ended up doing (we ported MiniMax Code's
agent-modules/goal, which has no external judge: the agent proposes theterminal state and the host settles it).
waits on work started outside the session (a quota wake-up, an external
worker), and there is no way to tell the idle judge that the session is
waiting rather than finished.
We are not asking for a specific API. What would help is either:
first-class goal (the RPC surface already suggests this direction - refactor(core): serve the goal over a plugin RPC instead of session metadata #59850),
Either way the goal semantics stay pluggable instead of being fixed in the
built-in plugin. Happy to share the plugin as a reference implementation.