Skip to content

Commit d0b9bd4

Browse files
cveilleuxclaude
andcommitted
OpenCode: a turn that ends is reported idle, from session.execution.succeeded
OpenCode 2 declares session.idle and session.status but never sends them (anomalyco/opencode#55358); a finished turn arrives only as session.execution.*. The plugin reported idle on failed and interrupted but not on succeeded, so an OpenCode agent stayed working after its first turn. It now reports idle on succeeded, and on session.status idle for the day OpenCode sends it. Tracked in #44, to be removed once OpenCode is fixed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent f0722cc commit d0b9bd4

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

‎internal/harness/harness_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func TestOpenCodePluginReportsEgzosStates(t *testing.T) {
225225
o := options(t)
226226
plan, _ := openCode{}.Plan(o, nil)
227227
plugin := string(plan.Files[filepath.Join(o.Home, ".config", "opencode", "plugins", "egzo.js")].Content)
228-
for _, want := range []string{`state("idle"`, `"session.idle"`, `state("working"`, `hook("prompt"`, `state("blocked"`, `"permission.asked"`, `"form.created"`, "/v1/state"} {
228+
for _, want := range []string{`state("idle"`, `"session.idle"`, `"session.execution.succeeded"`, `"session.status"`, `state("working"`, `hook("prompt"`, `state("blocked"`, `"permission.asked"`, `"form.created"`, "/v1/state"} {
229229
if !strings.Contains(plugin, want) {
230230
t.Errorf("the plugin lacks %s", want)
231231
}

‎internal/harness/opencode.go‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,17 @@ export default {
6060
try {
6161
for await (const event of ctx.event.subscribe({ signal: stop.signal })) {
6262
switch (event.type) {
63-
case "session.idle":
63+
// A turn that ends is session.execution.*: OpenCode 2 declares session.idle and session.status but does not send them
64+
// (anomalyco/opencode#55358); they are handled for the day it does.
65+
case "session.execution.succeeded":
6466
case "session.execution.failed":
6567
case "session.execution.interrupted":
68+
case "session.idle":
6669
await state("idle", { reason: event.type })
6770
break
71+
case "session.status":
72+
if ((event.properties?.status?.type ?? event.properties?.status) === "idle") await state("idle", { reason: event.type })
73+
break
6874
case "permission.asked":
6975
await state("blocked", { reason: "permission" })
7076
break

‎specs/harness/test_harness_integrations.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ def test_opencode_is_configured_to_allow_every_tool_report_through_a_plugin_and_
233233
assert server["codemode"] is False
234234
assert "codemode" not in config["mcp"]["servers"]["playwright"]
235235
plugin = in_instance(engine, p, default, "cat $HOME/.config/opencode/plugins/egzo.js").stdout
236-
assert "session.idle" in plugin
236+
# a turn that finishes is session.execution.succeeded in OpenCode 2, which declares session.idle but never sends it
237+
assert "session.execution.succeeded" in plugin
237238
assert "/v1/state" in plugin and "blocked" in plugin and "working" in plugin and "idle" in plugin
238239

239240
configured = read_json(engine, p, model, "$HOME/.config/opencode/opencode.json")

0 commit comments

Comments
 (0)