Skip to content

Commit 77c6276

Browse files
fix(opencode): unanswered stop offers Force stop
When OpenCode never answered session.abort, the adapter's 10 s abort timeout was wrapped as ProviderAdapterInterruptError, so the session was never marked unresponsive and the thread sat in "Stopping" while the interrupt was retried. The abort timeout now fails with ProviderAdapterInterruptTimeoutError and the outer mapError passes that tag through, matching the ACP and Claude adapters. Fixes #30987 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent fa055a5 commit 77c6276

1 file changed

Lines changed: 22 additions & 9 deletions

File tree

‎packages/provider-opencode/src/server/adapter.ts‎

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export const OPENCODE_PROVIDER = ProviderDriverKind.make("opencode");
8686
export const OPENCODE_DEFAULT_INSTANCE_ID = defaultInstanceIdForDriver(OPENCODE_PROVIDER);
8787
export const OPENCODE_SDK_PROTOCOL = "opencode-sdk.sse" as const;
8888
const DEFAULT_OPENCODE_SETTINGS = Schema.decodeSync(OpenCodeSettings)({});
89+
const OPENCODE_STOP_CONFIRM_TIMEOUT_MS = 10_000;
8990

9091
const makeOpenCodeMessageId = Effect.fnUntraced(function* (
9192
clock: Ref.Ref<{ readonly epochMillis: number; readonly counter: number }>,
@@ -3486,7 +3487,18 @@ export const makeOpenCodeAdapterV2 = Effect.fn("makeOpenCodeAdapterV2")(function
34863487
yield* sdkCall("session.abort", { sessionID: sessionId }, (signal) =>
34873488
client.session.abort({ sessionID: sessionId }, { signal }),
34883489
).pipe(
3489-
Effect.timeout("10 seconds"),
3490+
Effect.timeoutOrElse({
3491+
duration: OPENCODE_STOP_CONFIRM_TIMEOUT_MS,
3492+
orElse: () =>
3493+
Effect.fail(
3494+
new ProviderAdapter.ProviderAdapterInterruptTimeoutError({
3495+
driver: OPENCODE_PROVIDER,
3496+
providerThreadId: interruptInput.providerThread.id,
3497+
providerTurnId: interruptInput.providerTurnId,
3498+
timeoutMs: OPENCODE_STOP_CONFIRM_TIMEOUT_MS,
3499+
}),
3500+
),
3501+
}),
34903502
Effect.catch((cause) =>
34913503
turn.finalized
34923504
? Effect.void
@@ -3501,14 +3513,15 @@ export const makeOpenCodeAdapterV2 = Effect.fn("makeOpenCodeAdapterV2")(function
35013513
},
35023514
(effect, interruptInput) =>
35033515
effect.pipe(
3504-
Effect.mapError(
3505-
(cause) =>
3506-
new ProviderAdapter.ProviderAdapterInterruptError({
3507-
driver: OPENCODE_PROVIDER,
3508-
providerThreadId: interruptInput.providerThread.id,
3509-
providerTurnId: interruptInput.providerTurnId,
3510-
cause,
3511-
}),
3516+
Effect.mapError((cause) =>
3517+
cause._tag === "ProviderAdapterInterruptTimeoutError"
3518+
? cause
3519+
: new ProviderAdapter.ProviderAdapterInterruptError({
3520+
driver: OPENCODE_PROVIDER,
3521+
providerThreadId: interruptInput.providerThread.id,
3522+
providerTurnId: interruptInput.providerTurnId,
3523+
cause,
3524+
}),
35123525
),
35133526
),
35143527
),

0 commit comments

Comments
 (0)