Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -4035,6 +4035,26 @@ it.layer(McpProviderSessions.layer)("OpenCode2 adapter", (it) => {
}),
);

// A cancel without a message aborts the asking session's step, so the child would never report.
it.effect.each(["cancel", "decline"] as const)(
"lets a background child carry on when its question is dismissed with %s",
(decision) =>
Effect.gen(function* () {
const form = { ...colorForm, sessionID: CHILD };
const { runtime, thread } = yield* resumed([
...launchedAndRunning,
event("form.created", { form }),
event("session.execution.succeeded", { sessionID: SESSION }),
out("session.form.cancel", { sessionID: CHILD, formID: form.id, message: "<string>" }),
reply("session.form.cancel", null),
]);
const requested = yield* requestOf(runtime).pipe(Effect.forkScoped);
yield* runtime.startTurn(withLineage(thread));
const request = yield* Fiber.join(requested);
yield* runtime.respondToRuntimeRequest({ requestId: request!.id, decision });
}),
);

it.effect("keeps a background child's requests when its parent stops during reconciliation", () =>
Effect.gen(function* () {
const reading = yield* Deferred.make<void>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export type OpenCodeOrchestratorReplayHarnessError =

function replayValueMatches(expected: unknown, actual: unknown): boolean {
if (expected === "<any>" || expected === "<workspace>") return true;
if (expected === "<string>") return typeof actual === "string" && actual.length > 0;
if (Array.isArray(expected)) {
return (
Array.isArray(actual) &&
Expand Down
3 changes: 3 additions & 0 deletions packages/provider-opencode/src/server/v2/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ const sameRules = (left: ReadonlyArray<Rule> | undefined, right: ReadonlyArray<R

// Rejection without a message stops the whole execution, meaning Cancel.
const DECLINED = "The user declined this request.";
const DISMISSED = "The user dismissed this question. Continue without an answer.";

// Steer before decline; otherwise the model sees only Unable to execute command and retries.
const declinedNote = (action: string, resources: ReadonlyArray<string>) =>
Expand Down Expand Up @@ -5192,6 +5193,8 @@ export const make = Effect.fn("OpenCode2Adapter.make")(function* (instanceId: Pr
? client.session.form.cancel({
sessionID: entry.sessionId,
formID: Form.ID.make(native.id),
// Without a message OpenCode aborts the step, and a background subagent never reports.
...(asker.subagent === undefined ? {} : { message: DISMISSED }),
})
: client.session.form.reply({
sessionID: entry.sessionId,
Expand Down
Loading