From 7c8f3e253f87d64bded0c42cd4185af68a3833dc Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 13 Sep 2026 18:16:19 +1000 Subject: [PATCH 1/2] fix(server): report missing interrupt-and-restart capability for forced restarts When a restart is explicitly requested (forceRestart) and the provider cannot satisfy interrupt-and-restart steering, the typed CommandPolicyCapabilityUnsupportedError claimed the active_steering capability was missing whenever the provider also lacked interrupt support, and always carried the generic steering detail. That misreports the actual gap: the request was a restart, and the missing capability is interrupt_restart_steering. Report interrupt_restart_steering with an explicit-restart detail for every unsatisfiable forced restart, and leave ordinary steering decisions and its fallback error policy untouched. Adapted from the stalled proposal in pingdotgg/t3code#11151 by kiiwee; extended to a 16-case capability matrix that also pins the typed error fields for both steering modes. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../orchestration-v2/CommandPolicy.test.ts | 205 ++++++++++++++++++ .../src/orchestration-v2/CommandPolicy.ts | 8 +- 2 files changed, 211 insertions(+), 2 deletions(-) diff --git a/apps/server/src/orchestration-v2/CommandPolicy.test.ts b/apps/server/src/orchestration-v2/CommandPolicy.test.ts index 8fda729ffecd..f7a90216ff7e 100644 --- a/apps/server/src/orchestration-v2/CommandPolicy.test.ts +++ b/apps/server/src/orchestration-v2/CommandPolicy.test.ts @@ -15,10 +15,12 @@ import { CodexProviderCapabilitiesV2 } from "./Adapters/CodexAdapterV2.ts"; import { CursorProviderCapabilitiesV2 } from "./Adapters/CursorAdapterV2.ts"; import { GrokProviderCapabilitiesV2 } from "./Adapters/GrokAdapterV2.ts"; import { + type CommandPolicyCapability, CommandPolicyCapabilityUnsupportedError, CommandPolicyV2, layer as commandPolicyLayer, resolveMessageDispatchIntent, + type SteeringExecutionPolicyV2, } from "./CommandPolicy.ts"; const commandId = CommandId.make("command-policy-test"); @@ -191,6 +193,209 @@ layer("CommandPolicyV2", (it) => { }), ); + it.effect("reports the actually missing capability across the steering matrix", () => + Effect.gen(function* () { + const policy = yield* CommandPolicyV2; + const providerInstanceId = ProviderInstanceId.make("codex"); + const fallbackDetail = + "providerInstanceId cannot steer active turns directly or by interrupt-and-restart"; + const forcedRestartDetail = + "providerInstanceId cannot satisfy an explicit interrupt-and-restart request"; + + const cases: ReadonlyArray<{ + readonly forceRestart: boolean; + readonly supportsActiveSteering: boolean; + readonly supportsInterrupt: boolean; + readonly supportsSteeringByInterruptRestart: boolean; + readonly expected: + | { readonly type: "policy"; readonly value: SteeringExecutionPolicyV2 } + | { + readonly type: "error"; + readonly capability: CommandPolicyCapability; + readonly detail: string; + }; + }> = [ + // Ordinary steering prefers direct active steering whenever available. + { + forceRestart: false, + supportsActiveSteering: true, + supportsInterrupt: false, + supportsSteeringByInterruptRestart: false, + expected: { type: "policy", value: "active_steering" }, + }, + { + forceRestart: false, + supportsActiveSteering: true, + supportsInterrupt: false, + supportsSteeringByInterruptRestart: true, + expected: { type: "policy", value: "active_steering" }, + }, + { + forceRestart: false, + supportsActiveSteering: true, + supportsInterrupt: true, + supportsSteeringByInterruptRestart: false, + expected: { type: "policy", value: "active_steering" }, + }, + { + forceRestart: false, + supportsActiveSteering: true, + supportsInterrupt: true, + supportsSteeringByInterruptRestart: true, + expected: { type: "policy", value: "active_steering" }, + }, + // Ordinary steering falls back to interrupt-and-restart, then to a + // typed error naming the capability that is actually missing. + { + forceRestart: false, + supportsActiveSteering: false, + supportsInterrupt: true, + supportsSteeringByInterruptRestart: true, + expected: { type: "policy", value: "interrupt_restart" }, + }, + { + forceRestart: false, + supportsActiveSteering: false, + supportsInterrupt: true, + supportsSteeringByInterruptRestart: false, + expected: { + type: "error", + capability: "interrupt_restart_steering", + detail: fallbackDetail, + }, + }, + { + forceRestart: false, + supportsActiveSteering: false, + supportsInterrupt: false, + supportsSteeringByInterruptRestart: true, + expected: { type: "error", capability: "active_steering", detail: fallbackDetail }, + }, + { + forceRestart: false, + supportsActiveSteering: false, + supportsInterrupt: false, + supportsSteeringByInterruptRestart: false, + expected: { type: "error", capability: "active_steering", detail: fallbackDetail }, + }, + // An explicit restart skips direct steering and only succeeds via + // interrupt-and-restart; every other combination must report that + // capability instead of claiming live steering is unsupported. + { + forceRestart: true, + supportsActiveSteering: true, + supportsInterrupt: true, + supportsSteeringByInterruptRestart: true, + expected: { type: "policy", value: "interrupt_restart" }, + }, + { + forceRestart: true, + supportsActiveSteering: false, + supportsInterrupt: true, + supportsSteeringByInterruptRestart: true, + expected: { type: "policy", value: "interrupt_restart" }, + }, + { + forceRestart: true, + supportsActiveSteering: true, + supportsInterrupt: true, + supportsSteeringByInterruptRestart: false, + expected: { + type: "error", + capability: "interrupt_restart_steering", + detail: forcedRestartDetail, + }, + }, + { + forceRestart: true, + supportsActiveSteering: false, + supportsInterrupt: true, + supportsSteeringByInterruptRestart: false, + expected: { + type: "error", + capability: "interrupt_restart_steering", + detail: forcedRestartDetail, + }, + }, + { + forceRestart: true, + supportsActiveSteering: true, + supportsInterrupt: false, + supportsSteeringByInterruptRestart: true, + expected: { + type: "error", + capability: "interrupt_restart_steering", + detail: forcedRestartDetail, + }, + }, + { + forceRestart: true, + supportsActiveSteering: false, + supportsInterrupt: false, + supportsSteeringByInterruptRestart: true, + expected: { + type: "error", + capability: "interrupt_restart_steering", + detail: forcedRestartDetail, + }, + }, + { + forceRestart: true, + supportsActiveSteering: true, + supportsInterrupt: false, + supportsSteeringByInterruptRestart: false, + expected: { + type: "error", + capability: "interrupt_restart_steering", + detail: forcedRestartDetail, + }, + }, + { + forceRestart: true, + supportsActiveSteering: false, + supportsInterrupt: false, + supportsSteeringByInterruptRestart: false, + expected: { + type: "error", + capability: "interrupt_restart_steering", + detail: forcedRestartDetail, + }, + }, + ]; + + for (const entry of cases) { + const decision = policy.decideSteeringExecution({ + commandId, + threadId, + providerInstanceId, + forceRestart: entry.forceRestart, + capabilities: capabilities((current) => ({ + ...current, + turns: { + ...current.turns, + supportsActiveSteering: entry.supportsActiveSteering, + supportsInterrupt: entry.supportsInterrupt, + supportsSteeringByInterruptRestart: entry.supportsSteeringByInterruptRestart, + }, + })), + }); + + if (entry.expected.type === "policy") { + assert.equal(yield* decision, entry.expected.value); + continue; + } + + const error = yield* decision.pipe(Effect.flip); + assert.instanceOf(error, CommandPolicyCapabilityUnsupportedError); + assert.equal(error.commandId, commandId); + assert.equal(error.threadId, threadId); + assert.equal(error.providerInstanceId, providerInstanceId); + assert.equal(error.capability, entry.expected.capability); + assert.equal(error.detail, entry.expected.detail); + } + }), + ); + it.effect("returns typed capability errors for unsupported active steering", () => Effect.gen(function* () { const policy = yield* CommandPolicyV2; diff --git a/apps/server/src/orchestration-v2/CommandPolicy.ts b/apps/server/src/orchestration-v2/CommandPolicy.ts index 090958250ca9..f16e85cb1572 100644 --- a/apps/server/src/orchestration-v2/CommandPolicy.ts +++ b/apps/server/src/orchestration-v2/CommandPolicy.ts @@ -254,8 +254,12 @@ const decideSteeringExecution: CommandPolicyV2Shape["decideSteeringExecution"] = return Effect.fail( unsupported( input, - input.capabilities.turns.supportsInterrupt ? "interrupt_restart_steering" : "active_steering", - "providerInstanceId cannot steer active turns directly or by interrupt-and-restart", + input.forceRestart || input.capabilities.turns.supportsInterrupt + ? "interrupt_restart_steering" + : "active_steering", + input.forceRestart + ? "providerInstanceId cannot satisfy an explicit interrupt-and-restart request" + : "providerInstanceId cannot steer active turns directly or by interrupt-and-restart", ), ); }; From c1eb1101403f60994a90f81203cef1b5c226a315 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 14 Sep 2026 02:42:31 +1000 Subject: [PATCH 2/2] fix(server): describe forced-restart requirement, not its origin forceRestart reaches decideSteeringExecution both for an explicit restart and for a selection change that requires one, so "explicit interrupt-and-restart request" overstated the intent on the selection-change path. Say the provider cannot satisfy a required interrupt-and-restart instead. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- apps/server/src/orchestration-v2/CommandPolicy.test.ts | 4 ++-- apps/server/src/orchestration-v2/CommandPolicy.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/server/src/orchestration-v2/CommandPolicy.test.ts b/apps/server/src/orchestration-v2/CommandPolicy.test.ts index f7a90216ff7e..c487bdd10823 100644 --- a/apps/server/src/orchestration-v2/CommandPolicy.test.ts +++ b/apps/server/src/orchestration-v2/CommandPolicy.test.ts @@ -200,7 +200,7 @@ layer("CommandPolicyV2", (it) => { const fallbackDetail = "providerInstanceId cannot steer active turns directly or by interrupt-and-restart"; const forcedRestartDetail = - "providerInstanceId cannot satisfy an explicit interrupt-and-restart request"; + "providerInstanceId cannot satisfy a required interrupt-and-restart"; const cases: ReadonlyArray<{ readonly forceRestart: boolean; @@ -278,7 +278,7 @@ layer("CommandPolicyV2", (it) => { supportsSteeringByInterruptRestart: false, expected: { type: "error", capability: "active_steering", detail: fallbackDetail }, }, - // An explicit restart skips direct steering and only succeeds via + // A forced restart skips direct steering and only succeeds via // interrupt-and-restart; every other combination must report that // capability instead of claiming live steering is unsupported. { diff --git a/apps/server/src/orchestration-v2/CommandPolicy.ts b/apps/server/src/orchestration-v2/CommandPolicy.ts index f16e85cb1572..bdd1845e3ba5 100644 --- a/apps/server/src/orchestration-v2/CommandPolicy.ts +++ b/apps/server/src/orchestration-v2/CommandPolicy.ts @@ -258,7 +258,7 @@ const decideSteeringExecution: CommandPolicyV2Shape["decideSteeringExecution"] = ? "interrupt_restart_steering" : "active_steering", input.forceRestart - ? "providerInstanceId cannot satisfy an explicit interrupt-and-restart request" + ? "providerInstanceId cannot satisfy a required interrupt-and-restart" : "providerInstanceId cannot steer active turns directly or by interrupt-and-restart", ), );