Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6c580a1
test(server): reproduce #32829, OpenCode 2 background shells not tracked
juliusmarminge Nov 8, 2026
7db4f03
fix(opencode): count running background shells as pending work
juliusmarminge Nov 8, 2026
760f1bc
fix(opencode): Stop starts no work from a removed shell's report
juliusmarminge Nov 8, 2026
d5f8c8b
fix(opencode): count background shells as their events arrive
juliusmarminge Nov 8, 2026
4b2a6e8
test(server): read the reconnect case's events through one consumer
juliusmarminge Nov 8, 2026
d0acbf5
Merge remote-tracking branch 'origin/main' into fix/issue-32829
juliusmarminge Nov 8, 2026
94e070a
fix(opencode): count a held subagent's shells and remove shells launc…
juliusmarminge Nov 8, 2026
1a7c445
fix(opencode): a failed shell check keeps the shell, not the reconnect
juliusmarminge Nov 8, 2026
5cd4fc1
fix(opencode): check tracked shells concurrently on reconnect
juliusmarminge Nov 8, 2026
c9bdd13
Merge remote-tracking branch 'origin/main' into pr-32851
juliusmarminge Nov 10, 2026
c88510a
fix(opencode): Stop ends work launched while it runs
juliusmarminge Nov 10, 2026
975c081
fix(opencode): Stop waits for every interrupted session before its la…
juliusmarminge Nov 10, 2026
17291d3
Merge remote-tracking branch 'origin/main' into pr-32851
juliusmarminge Nov 10, 2026
4b55798
fix(opencode): shells in held wakes survive neither Stop nor a reconnect
juliusmarminge Nov 10, 2026
460272b
Merge remote-tracking branch 'origin/main' into pr-32851
juliusmarminge Nov 10, 2026
8f0c659
fix(opencode): Stop keeps discarded subagents' shells tracked and sto…
juliusmarminge Nov 10, 2026
dca900e
fix(opencode): Stop does not wait on a session that went idle while i…
juliusmarminge Nov 10, 2026
153c326
fix(opencode): background shell Details show the command
juliusmarminge Nov 10, 2026
c9406df
Merge remote-tracking branch 'origin/main' into pr-32851
juliusmarminge Nov 10, 2026
d63cbb9
Merge origin/main into fix/issue-32829
juliusmarminge Nov 22, 2026
07b3523
fix(opencode): Stop ends shells launched while it runs and shells hel…
juliusmarminge Nov 22, 2026
c792deb
fix(opencode): a held shell Stop cannot remove stays tracked
juliusmarminge Nov 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 103 additions & 9 deletions apps/server/src/orchestration-v2/Adapters/OpenCode2AdapterV2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,58 @@ it.layer(McpProviderSessions.layer)("OpenCode2 adapter", (it) => {
);
return { attached: Deferred.await(attached), terminal: Fiber.join(terminal) };
});
it.effect("Stop removes a shell the turn launches while its interrupt lands", () =>
Effect.gen(function* () {
const shellID = "sh_late";
const tool = { sessionID: SESSION, assistantMessageID: "msg_assistant", id: "call-late" };
const output = [
out("shell.output", "<any>"),
reply("shell.output", {
location: { directory: WORK },
data: { output: "", cursor: 0, size: 0, truncated: false },
}),
];
const { runtime, thread } = yield* resumed([
out("session.prompt", { sessionID: SESSION, text: "<any>" }),
promptAccepted,
event("session.execution.started", { sessionID: SESSION }),
event("session.tool.input.started", { ...tool, name: "shell" }),
event("session.tool.called", {
...tool,
name: "shell",
input: { command: "sleep 500", background: true },
executed: false,
}),
out("session.interrupt", { sessionID: SESSION }),
reply("session.interrupt", { interrupted: true }),
// OpenCode accepted the interrupt, but the running tool still launches before the run ends.
event(
"session.tool.success",
{
...tool,
content: [{ type: "text", text: "Launched" }],
metadata: { shellID },
executed: false,
},
undefined,
2,
),
...output,
event("session.execution.interrupted", { sessionID: SESSION }),
...output,
out("shell.remove", { id: shellID, "location[directory]": WORK }),
reply("shell.remove", null),
]);
yield* runtime.startTurn(withLineage(thread));
yield* runtime.interruptTurn({
providerThread: thread,
providerTurnId: yield* providerTurnId,
requestRuntimeRestart: true,
});
assert.isFalse(yield* runtime.hasPendingBackgroundWorkForThread!(thread));
}),
);

it.effect.each([false, true, "thread", "failed", "burst", "poll"] as const)(
"tracks native background shells through launch, retained output, stop=%s",
(stop) =>
Expand Down Expand Up @@ -2342,7 +2394,15 @@ it.layer(McpProviderSessions.layer)("OpenCode2 adapter", (it) => {
}),
);

it.effect.each(["running", "exited", "timeout", "held", "sync"] as const)(
it.effect.each([
"running",
"exited",
"timeout",
"held",
"sync",
"stopped",
"unremovable",
] as const)(
"marks a shell OpenCode started on its own before T3 runs the wake, shell %s",
(shell) =>
Effect.gen(function* () {
Expand Down Expand Up @@ -2419,13 +2479,29 @@ it.layer(McpProviderSessions.layer)("OpenCode2 adapter", (it) => {
sessionID: SESSION,
model: { providerID: "opencode", id: "big-pickle", variant: "thinking" },
}),
...Array.from({ length: shell === "held" ? 2 : shell === "sync" ? 0 : 1 }, () => [
out("shell.output", "<any>"),
reply("shell.output", {
location: { directory: WORK },
data: { output: "", cursor: 0, size: 0, truncated: false },
}),
]).flat(),
...(shell === "stopped" || shell === "unremovable"
? [
out("shell.remove", { id: shellID, "location[directory]": WORK }),
reply("shell.remove", shell === "stopped" ? null : { status: 500, body: {} }),
]
: []),
...Array.from(
{
length:
shell === "held"
? 2
: shell === "sync" || shell === "stopped" || shell === "unremovable"
? 0
: 1,
},
() => [
out("shell.output", "<any>"),
reply("shell.output", {
location: { directory: WORK },
data: { output: "", cursor: 0, size: 0, truncated: false },
}),
],
).flat(),
]).pipe(
Effect.provideService(ProviderContinuationRequests.ProviderContinuationRequests, {
offer: (request) =>
Expand Down Expand Up @@ -2470,9 +2546,27 @@ it.layer(McpProviderSessions.layer)("OpenCode2 adapter", (it) => {
taskIds: [shellID],
awaited: true,
}),
{ matched: shell === "running" ? [shellID] : [] },
{
matched:
shell === "running" || shell === "stopped" || shell === "unremovable"
? [shellID]
: [],
},
);
if (shell === "sync") return;
if (shell === "stopped" || shell === "unremovable") {
// Stop discards the held wake, so the launch it holds must be removed before it goes.
yield* runtime.interruptTurn({
providerThread: thread,
providerTurnId: yield* providerTurnId,
requestRuntimeRestart: true,
});
// A shell that would not stop outlives its wake and stays pending.
return assert.equal(
yield* runtime.hasPendingBackgroundWorkForThread!(thread),
shell === "unremovable",
);
}
yield* runtime.startTurn(continuationTurn(thread, offers[0]!));
if (shell === "running") return assert.isTrue(yield* Deferred.await(marked));
// A shell that ended before the wake ran never holds the thread.
Expand Down
Loading
Loading