diff --git a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts index 4c41dad10a..73627e7f84 100644 --- a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts +++ b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts @@ -720,7 +720,6 @@ describe("ClaudeAdapterV2 attachments", () => { }), setModel: () => Effect.void, interrupt: Effect.void, - stopTask: () => Effect.void, close: Effect.void, }), forkSession: () => Effect.die("unused forkSession"), @@ -843,7 +842,6 @@ describe("ClaudeAdapterV2 attachments", () => { offer: () => Effect.void, setModel: () => Effect.void, interrupt: Effect.void, - stopTask: () => Effect.void, close: Effect.void, }; }), @@ -935,7 +933,6 @@ describe("ClaudeAdapterV2 native fork", () => { offer: () => Effect.void, setModel: () => Effect.void, interrupt: Effect.void, - stopTask: () => Effect.void, close: Effect.void, }; }), @@ -1105,7 +1102,6 @@ describe("ClaudeAdapterV2 native session identity", () => { offer: () => Effect.void, setModel: () => Effect.void, interrupt: Effect.void, - stopTask: () => Effect.void, close: Effect.void, }; }), @@ -1298,7 +1294,6 @@ describe("ClaudeAdapterV2 background wake turns", () => { const makeWakeHarnessWithOptions = (options?: { readonly close?: (sdkMessages: Queue.Queue) => Effect.Effect; readonly interrupt?: Effect.Effect; - readonly stopTask?: (taskId: string) => Effect.Effect; }) => Effect.gen(function* () { const fileSystem = yield* FileSystem.FileSystem; @@ -1333,7 +1328,6 @@ describe("ClaudeAdapterV2 background wake turns", () => { }), setModel: () => Effect.void, interrupt: options?.interrupt ?? Effect.void, - stopTask: options?.stopTask ?? (() => Effect.void), close: options?.close?.(sdkMessages) ?? Effect.void, }), forkSession: () => Effect.die("unused forkSession"), @@ -1384,36 +1378,6 @@ describe("ClaudeAdapterV2 background wake turns", () => { }); const makeWakeHarness = makeWakeHarnessWithOptions(); - it.effect("treats a stop after query release as already complete", () => - Effect.scoped( - Effect.gen(function* () { - const stoppedTaskIds = yield* Ref.make>([]); - const harness = yield* makeWakeHarnessWithOptions({ - stopTask: (taskId) => Ref.update(stoppedTaskIds, (current) => [...current, taskId]), - }); - if (harness.runtime.stopTask === undefined) { - return yield* Effect.die("Claude adapter runtime must expose stopTask."); - } - const now = yield* DateTime.now; - yield* harness.runtime.startTurn( - makeClaudeTestTurnInput({ - threadId: harness.threadId, - providerThread: harness.providerThread, - now, - attemptId: RunAttemptId.make("attempt-claude-stop-after-release"), - text: "Start a query that will be released.", - attachments: [], - }), - ); - yield* Queue.shutdown(harness.sdkMessages); - yield* awaitUntil(() => harness.terminalEvents().length === 1, "released query terminal"); - - yield* harness.runtime.stopTask({ nativeTaskId: WAKE_TASK_ID }); - assert.deepEqual(yield* Ref.get(stoppedTaskIds), []); - }).pipe(Effect.provide(Layer.merge(idAllocatorLayer, NodeServices.layer))), - ), - ); - it.effect("projects API retries and resolves the same item after recovery", () => Effect.scoped( Effect.gen(function* () { @@ -1726,7 +1690,6 @@ describe("ClaudeAdapterV2 background wake turns", () => { offer: () => Effect.void, setModel: () => Effect.void, interrupt: Effect.void, - stopTask: () => Effect.void, // End the message stream so interruptTurn's closed wait resolves // via stream exit finalize (interrupted status clears roster). close: Queue.shutdown(sdkMessages), @@ -1852,7 +1815,6 @@ describe("ClaudeAdapterV2 background wake turns", () => { offer: () => Effect.void, setModel: () => Effect.void, interrupt: Effect.void, - stopTask: () => Effect.void, close: Queue.shutdown(queue), }; }), @@ -3847,7 +3809,6 @@ describe("ClaudeAdapterV2 background wake turns", () => { offer: () => Effect.void, setModel: () => Effect.void, interrupt: Effect.void, - stopTask: () => Effect.void, // End this process stream so openQuery can replace it. close: Queue.shutdown(sdkMessages), }; @@ -4114,7 +4075,6 @@ describe("ClaudeAdapterV2 background wake turns", () => { offer: () => Effect.void, setModel: () => Effect.void, interrupt: Effect.void, - stopTask: () => Effect.void, close: Queue.shutdown(sdkMessages), }; }), @@ -4347,7 +4307,6 @@ describe("ClaudeAdapterV2 background wake turns", () => { offer: () => Effect.void, setModel: () => Effect.void, interrupt: Effect.void, - stopTask: () => Effect.void, close: Queue.shutdown(sdkMessages), }; }), @@ -4544,7 +4503,6 @@ describe("ClaudeAdapterV2 background wake turns", () => { offer: () => Effect.void, setModel: () => Effect.void, interrupt: Effect.void, - stopTask: () => Effect.void, close: Queue.shutdown(sdkMessages), }; }); @@ -4681,7 +4639,6 @@ describe("ClaudeAdapterV2 background wake turns", () => { offer: () => Effect.void, setModel: () => Effect.void, interrupt: Effect.void, - stopTask: () => Effect.void, close: Queue.shutdown(sdkMessages), }; }); diff --git a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.testkit.ts b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.testkit.ts index 63f3579a00..eec8ede1e3 100644 --- a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.testkit.ts +++ b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.testkit.ts @@ -733,10 +733,6 @@ export function makeReplayQueryRunner( interrupt: replayEffect(() => { assertNextOutboundFrame({ type: "query.interrupt" }); }), - stopTask: (taskId) => - replayEffect(() => { - assertNextOutboundFrame({ type: "task.stop", taskId }); - }), close: Effect.void, }; }, diff --git a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts index 256c018bab..9c840d4311 100644 --- a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts +++ b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts @@ -278,7 +278,6 @@ export interface ClaudeAgentSdkQuerySession { readonly offer: (message: SDKUserMessage) => Effect.Effect; readonly setModel: (model: string) => Effect.Effect; readonly interrupt: Effect.Effect; - readonly stopTask: (taskId: string) => Effect.Effect; readonly close: Effect.Effect; } @@ -601,37 +600,6 @@ export const claudeAgentSdkQueryRunnerLiveLayer: Layer.Layer< }), ), ), - stopTask: (taskId) => - Effect.suspend(() => { - // stopTask is deliberate wire surface (the CLI's own - // /workflows view stops through it) but absent from the - // published SDK types — this cast is the single place the - // undocumented method is read. - const stop = (queryRuntime as { stopTask?: (taskId: string) => Promise }) - .stopTask; - return stop === undefined - ? Effect.fail( - new ClaudeAgentSdkQueryRunnerError({ - method: "stopTask", - cause: "The Claude SDK runtime for this session does not expose stopTask.", - }), - ) - : Effect.tryPromise({ - try: () => stop.call(queryRuntime, taskId), - catch: (cause) => queryRunnerError(cause, "stopTask"), - }); - }).pipe( - Effect.tap(() => - logProtocolEvent({ - direction: "outgoing", - stage: "decoded", - payload: { - type: "task.stop", - taskId, - }, - }), - ), - ), close: Queue.shutdown(promptQueue).pipe( Effect.andThen(closeClaudeQuery(queryRuntime)), Effect.tap(() => @@ -5259,28 +5227,6 @@ export function makeClaudeAdapterV2( startTurn, steerTurn, interruptTurn, - stopTask: Effect.fn("ClaudeAdapterV2.stopTask")(function* (stopInput: { - readonly nativeTaskId: string; - }) { - const existing = yield* Ref.get(queryContext); - if (existing === null) { - yield* Effect.logWarning("orchestration-v2.claude-stop-task-without-live-query", { - providerSessionId: input.providerSessionId, - nativeTaskId: stopInput.nativeTaskId, - }); - return; - } - yield* existing.query.stopTask(stopInput.nativeTaskId).pipe( - Effect.mapError( - (cause) => - new ProviderAdapterProtocolError({ - driver: CLAUDE_PROVIDER, - detail: `Stopping Claude task ${stopInput.nativeTaskId} failed.`, - payload: cause, - }), - ), - ); - }), respondToRuntimeRequest: Effect.fn("ClaudeAdapterV2.respondToRuntimeRequest")( function* (requestInput) { const pending = (yield* Ref.get(pendingRuntimeRequests)).get( diff --git a/apps/server/src/orchestration-v2/EffectOutbox.ts b/apps/server/src/orchestration-v2/EffectOutbox.ts index cd9a49e4cf..85180279fc 100644 --- a/apps/server/src/orchestration-v2/EffectOutbox.ts +++ b/apps/server/src/orchestration-v2/EffectOutbox.ts @@ -72,12 +72,6 @@ export const OrchestrationEffectRequestV2 = Schema.Union([ decision: Schema.optional(ProviderApprovalDecision), answers: Schema.optional(ProviderUserInputAnswers), }), - Schema.Struct({ - type: Schema.Literal("subagent.stop"), - providerSessionId: ProviderSessionId, - /** The provider's own task id — what the runtime's stop call accepts. */ - nativeTaskId: Schema.String, - }), Schema.Struct({ type: Schema.Literal("provider-thread.rollback"), providerThreadId: ProviderThreadId, @@ -121,7 +115,6 @@ export const PROCESS_BOUND_EFFECT_TYPES = [ "provider-turn.steer", "provider-turn.restart", "runtime-request.respond", - "subagent.stop", ] as const satisfies ReadonlyArray; export const OrchestrationEffectStatusV2 = Schema.Literals([ diff --git a/apps/server/src/orchestration-v2/EffectWorker.test.ts b/apps/server/src/orchestration-v2/EffectWorker.test.ts index c091444ff4..b39105f36f 100644 --- a/apps/server/src/orchestration-v2/EffectWorker.test.ts +++ b/apps/server/src/orchestration-v2/EffectWorker.test.ts @@ -95,7 +95,6 @@ function makeExecutorLayer(input: { ProviderTurnControlServiceV2.of({ interrupt: () => Effect.void, steer: () => Effect.void, - stopTask: () => Effect.void, interruptAndAwaitTerminal: (request) => record( request.replacementProviderSessionId === undefined diff --git a/apps/server/src/orchestration-v2/EffectWorker.ts b/apps/server/src/orchestration-v2/EffectWorker.ts index 0cbf79b5cf..1139d2fea3 100644 --- a/apps/server/src/orchestration-v2/EffectWorker.ts +++ b/apps/server/src/orchestration-v2/EffectWorker.ts @@ -213,23 +213,6 @@ export const executorLayer: Layer.Layer< }), ), ); - case "subagent.stop": - return providerTurnControl - .stopTask({ - threadId: effect.threadId, - providerSessionId: effect.request.providerSessionId, - nativeTaskId: effect.request.nativeTaskId, - }) - .pipe( - Effect.mapError( - (cause) => - new OrchestrationEffectExecutionError({ - effectId: effect.id, - effectType: effect.request.type, - cause, - }), - ), - ); case "runtime-request.respond": return runtimeRequests .respond({ diff --git a/apps/server/src/orchestration-v2/Orchestrator.subagentStop.test.ts b/apps/server/src/orchestration-v2/Orchestrator.subagentStop.test.ts deleted file mode 100644 index fbd3b42a7c..0000000000 --- a/apps/server/src/orchestration-v2/Orchestrator.subagentStop.test.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { ProviderSessionId, ProviderThreadId, RunId } from "@t3tools/contracts"; -import { assert, it } from "@effect/vitest"; - -import { providerSessionIdForSubagentStop } from "./Orchestrator.ts"; - -const runId = RunId.make("run-subagent-stop"); -const runThreadId = ProviderThreadId.make("provider-thread-run"); -const activeThreadId = ProviderThreadId.make("provider-thread-active"); -const staleThreadId = ProviderThreadId.make("provider-thread-stale"); -const runSessionId = ProviderSessionId.make("provider-session-run"); -const activeSessionId = ProviderSessionId.make("provider-session-active"); -const staleSessionId = ProviderSessionId.make("provider-session-stale"); - -it("prefers the run session when stopping a subagent", () => { - assert.equal( - providerSessionIdForSubagentStop({ - runId, - activeProviderThreadId: activeThreadId, - runs: [{ id: runId, providerThreadId: runThreadId }], - providerThreads: [ - { id: activeThreadId, providerSessionId: activeSessionId }, - { id: runThreadId, providerSessionId: runSessionId }, - ], - }), - runSessionId, - ); -}); - -it("falls back only to the explicitly active provider thread", () => { - assert.equal( - providerSessionIdForSubagentStop({ - runId, - activeProviderThreadId: activeThreadId, - runs: [{ id: runId, providerThreadId: runThreadId }], - providerThreads: [ - { id: staleThreadId, providerSessionId: staleSessionId }, - { id: runThreadId, providerSessionId: null }, - { id: activeThreadId, providerSessionId: activeSessionId }, - ], - }), - activeSessionId, - ); -}); - -it("returns null when neither the run nor active thread has a session", () => { - assert.isNull( - providerSessionIdForSubagentStop({ - runId, - activeProviderThreadId: null, - runs: [{ id: runId, providerThreadId: runThreadId }], - providerThreads: [ - { id: staleThreadId, providerSessionId: staleSessionId }, - { id: runThreadId, providerSessionId: null }, - ], - }), - ); -}); diff --git a/apps/server/src/orchestration-v2/Orchestrator.ts b/apps/server/src/orchestration-v2/Orchestrator.ts index 6d531d5913..b9f0f8db42 100644 --- a/apps/server/src/orchestration-v2/Orchestrator.ts +++ b/apps/server/src/orchestration-v2/Orchestrator.ts @@ -66,11 +66,7 @@ import { subagentResultForRun, subagentThreadTitle, } from "./SubagentProjection.ts"; -import { - appendSubagentActivity, - defaultSubagentRole, - subagentActivationId, -} from "./SubagentObservability.ts"; +import { defaultSubagentRole, subagentActivationId } from "./SubagentObservability.ts"; import { ThreadForkServiceV2 } from "./ThreadForkService.ts"; export class OrchestratorDispatchError extends Schema.TaggedErrorClass()( @@ -217,7 +213,6 @@ function commandThreadId(command: OrchestrationV2Command): ThreadId { case "prepared-run.progress": case "prepared-run.fail": case "run.interrupt": - case "subagent.stop": case "queued-message.promote-to-steer": case "queued-run.reorder": case "queued-run.cancel": @@ -370,29 +365,6 @@ function providerThreadForRun( : projection.providerThreads.find((candidate) => candidate.id === run.providerThreadId); } -export function providerSessionIdForSubagentStop(input: { - readonly runId: OrchestrationV2Subagent["runId"]; - readonly activeProviderThreadId: OrchestrationV2AppThread["activeProviderThreadId"]; - readonly runs: ReadonlyArray>; - readonly providerThreads: ReadonlyArray< - Pick - >; -}) { - const run = - input.runId === null ? undefined : input.runs.find((candidate) => candidate.id === input.runId); - const runSessionId = - run?.providerThreadId === null || run?.providerThreadId === undefined - ? null - : (input.providerThreads.find((candidate) => candidate.id === run.providerThreadId) - ?.providerSessionId ?? null); - if (runSessionId !== null) return runSessionId; - if (input.activeProviderThreadId === null) return null; - return ( - input.providerThreads.find((candidate) => candidate.id === input.activeProviderThreadId) - ?.providerSessionId ?? null - ); -} - function providerTurnForRun( projection: OrchestrationV2ThreadProjection, run: OrchestrationV2Run, @@ -6029,89 +6001,6 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio return undefined; }); - const dispatchSubagentStop = ( - command: Extract, - events: Ref.Ref>, - effects: Ref.Ref>, - ) => - Effect.gen(function* () { - const projection = yield* loadProjectionForCommand(command); - const subagent = projection.subagents.find( - (candidate) => candidate.id === command.subagentId, - ); - if (subagent === undefined) { - return yield* new OrchestratorDispatchError({ - commandId: command.commandId, - commandType: command.type, - cause: `Subagent ${command.subagentId} does not exist.`, - }); - } - if ( - subagent.status !== "pending" && - subagent.status !== "running" && - subagent.status !== "waiting" - ) { - return yield* new OrchestratorDispatchError({ - commandId: command.commandId, - commandType: command.type, - cause: `Subagent ${command.subagentId} is not active (${subagent.status}).`, - }); - } - const nativeTaskId = subagent.nativeTaskRef?.nativeId; - if (nativeTaskId === undefined || nativeTaskId === null) { - return yield* new OrchestratorDispatchError({ - commandId: command.commandId, - commandType: command.type, - cause: `Subagent ${command.subagentId} has no native task reference to stop.`, - }); - } - const providerSessionId = providerSessionIdForSubagentStop({ - runId: subagent.runId, - activeProviderThreadId: projection.thread.activeProviderThreadId, - runs: projection.runs, - providerThreads: projection.providerThreads, - }); - if (providerSessionId === null) { - return yield* new OrchestratorDispatchError({ - commandId: command.commandId, - commandType: command.type, - cause: `Subagent ${command.subagentId} has no active provider session to stop it.`, - }); - } - - // The provider's task_notification is what terminalizes the subagent; - // this only records the user's intent so the panel and card reflect - // the request immediately. - const now = yield* DateTime.now; - const emitEvent = emit(events, command); - yield* emitEvent({ - type: "subagent.updated", - threadId: command.threadId, - ...(subagent.runId === null ? {} : { runId: subagent.runId }), - nodeId: subagent.id, - driver: subagent.driver, - occurredAt: now, - payload: { - ...subagent, - recentActivity: appendSubagentActivity(subagent.recentActivity, "Stop requested", now), - updatedAt: now, - }, - }); - yield* Ref.update(effects, (existing) => [ - ...existing, - { - id: `effect:${command.commandId}:subagent.stop:${subagent.id}`, - commandId: command.commandId, - threadId: command.threadId, - request: { - type: "subagent.stop", - providerSessionId, - nativeTaskId, - }, - } satisfies PendingOrchestrationEffectV2, - ]); - }); - const dispatchCheckpointRollback = ( command: Extract, events: Ref.Ref>, @@ -6972,9 +6861,6 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio case "run.interrupt": cancelUnsettledEffects = yield* dispatchRunInterrupt(command, events, effects); break; - case "subagent.stop": - yield* dispatchSubagentStop(command, events, effects); - break; case "queued-message.promote-to-steer": yield* dispatchQueuedMessagePromoteToSteer(command, events, effects); break; diff --git a/apps/server/src/orchestration-v2/ProviderAdapter.ts b/apps/server/src/orchestration-v2/ProviderAdapter.ts index e37b0a8520..7f0786f1b3 100644 --- a/apps/server/src/orchestration-v2/ProviderAdapter.ts +++ b/apps/server/src/orchestration-v2/ProviderAdapter.ts @@ -535,14 +535,6 @@ export interface ProviderAdapterV2SessionRuntime { readonly interruptTurn: ( input: ProviderAdapterV2InterruptInput, ) => Effect.Effect; - /** - * Stop one background task (e.g. a workflow run) by its native task id - * without interrupting the turn that launched it. Absent on providers - * whose runtime has no task-level stop. - */ - readonly stopTask?: (input: { - readonly nativeTaskId: string; - }) => Effect.Effect; readonly respondToRuntimeRequest: ( input: ProviderAdapterV2RuntimeRequestResponseInput, ) => Effect.Effect; diff --git a/apps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.test.ts b/apps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.test.ts index 652cbc462d..6638d08e9f 100644 --- a/apps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.test.ts +++ b/apps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.test.ts @@ -561,7 +561,6 @@ it.effect( "provider-turn.steer", "provider-turn.restart", "runtime-request.respond", - "subagent.stop", ]); const events = committedInput?.events ?? []; assert.deepEqual( diff --git a/apps/server/src/orchestration-v2/ProviderTurnControlService.test.ts b/apps/server/src/orchestration-v2/ProviderTurnControlService.test.ts index 8b4e4363eb..9d76bc4418 100644 --- a/apps/server/src/orchestration-v2/ProviderTurnControlService.test.ts +++ b/apps/server/src/orchestration-v2/ProviderTurnControlService.test.ts @@ -285,105 +285,3 @@ it.effect( assert.equal(interrupted?.nativeThreadRef?.nativeId, "native-thread:restart-session"); }), ); - -it.effect("stops a task through the live session and tolerates a released one", () => - Effect.gen(function* () { - const now = yield* DateTime.now; - const threadId = ThreadId.make("thread:stop-task"); - const sessionId = ProviderSessionId.make("provider-session:stop-task"); - const noStopSessionId = ProviderSessionId.make("provider-session:stop-task:no-stop"); - const stoppedTaskIds = yield* Ref.make>([]); - const providerSession = { - id: sessionId, - driver, - providerInstanceId, - status: "running" as const, - cwd: "/workspace", - model: modelSelection.model, - capabilities: CodexProviderCapabilitiesV2, - createdAt: now, - updatedAt: now, - lastError: null, - }; - const baseRuntime: ProviderAdapterV2SessionRuntime = { - instanceId: providerInstanceId, - driver, - providerSessionId: sessionId, - providerSession, - events: Stream.empty, - ensureThread: () => Effect.die("unused ensureThread"), - resumeThread: () => Effect.die("unused resumeThread"), - startTurn: () => Effect.die("unused startTurn"), - steerTurn: () => Effect.die("unused steerTurn"), - interruptTurn: () => Effect.die("unused interruptTurn"), - respondToRuntimeRequest: () => Effect.die("unused respondToRuntimeRequest"), - readThreadSnapshot: () => Effect.die("unused readThreadSnapshot"), - rollbackThread: () => Effect.die("unused rollbackThread"), - forkThread: () => Effect.die("unused forkThread"), - }; - const runtime: ProviderAdapterV2SessionRuntime = { - ...baseRuntime, - stopTask: ({ nativeTaskId }) => - Ref.update(stoppedTaskIds, (current) => [...current, nativeTaskId]), - }; - const projectionLayer = Layer.succeed( - ProjectionStoreV2, - ProjectionStoreV2.of({ - apply: () => Effect.void, - getShellSnapshot: () => Effect.die("unused getShellSnapshot"), - getThreadShell: () => Effect.die("unused getThreadShell"), - getThreadProjection: () => Effect.die("stopTask must not read the projection"), - getThreadSnapshot: () => Effect.die("unused getThreadSnapshot"), - }), - ); - const sessionManagerLayer = Layer.succeed( - ProviderSessionManagerV2, - ProviderSessionManagerV2.of({ - shutdown: Effect.void, - open: () => Effect.die("unused open"), - get: (providerSessionId) => - Effect.succeed( - providerSessionId === sessionId - ? Option.some(runtime) - : providerSessionId === noStopSessionId - ? Option.some(baseRuntime) - : Option.none(), - ), - close: () => Effect.void, - release: () => Effect.void, - detach: () => Effect.void, - }), - ); - const controlLayer = providerTurnControlLayer.pipe( - Layer.provide(Layer.merge(projectionLayer, sessionManagerLayer)), - ); - - yield* Effect.gen(function* () { - const control = yield* ProviderTurnControlServiceV2; - yield* control.stopTask({ - threadId, - providerSessionId: sessionId, - nativeTaskId: "wf-task-1", - }); - // A released session cannot be running the task any more — the stop is - // a no-op success, not a durable-effect failure that retries forever. - yield* control.stopTask({ - threadId, - providerSessionId: ProviderSessionId.make("provider-session:stop-task:gone"), - nativeTaskId: "wf-task-2", - }); - // A runtime without task-level stop must fail loudly rather than - // silently pretending it stopped something. - const unsupported = yield* Effect.exit( - control.stopTask({ - threadId, - providerSessionId: noStopSessionId, - nativeTaskId: "wf-task-3", - }), - ); - assert.isTrue(Exit.isFailure(unsupported)); - }).pipe(Effect.provide(controlLayer)); - - assert.deepEqual(yield* Ref.get(stoppedTaskIds), ["wf-task-1"]); - }), -); diff --git a/apps/server/src/orchestration-v2/ProviderTurnControlService.ts b/apps/server/src/orchestration-v2/ProviderTurnControlService.ts index 507c748303..0ce3ce30fb 100644 --- a/apps/server/src/orchestration-v2/ProviderTurnControlService.ts +++ b/apps/server/src/orchestration-v2/ProviderTurnControlService.ts @@ -36,18 +36,7 @@ export class ProviderTurnControlError extends Schema.TaggedErrorClass()( - "ProviderTaskStopError", - { - threadId: ThreadId, - providerSessionId: ProviderSessionId, - nativeTaskId: Schema.String, - cause: Schema.optional(Schema.Defect()), - }, -) {} - const isProviderTurnControlError = Schema.is(ProviderTurnControlError); -export const isProviderTaskStopError = Schema.is(ProviderTaskStopError); export interface ProviderTurnControlServiceV2Shape { readonly interrupt: (input: { @@ -71,11 +60,6 @@ export interface ProviderTurnControlServiceV2Shape { readonly providerTurnId: ProviderTurnId; readonly interruptedAttemptId: RunAttemptId; }) => Effect.Effect; - readonly stopTask: (input: { - readonly threadId: ThreadId; - readonly providerSessionId: ProviderSessionId; - readonly nativeTaskId: string; - }) => Effect.Effect; } export class ProviderTurnControlServiceV2 extends Context.Service< @@ -264,44 +248,6 @@ export const layer: Layer.Layer< }), ), ), - stopTask: (input) => - Effect.gen(function* () { - const session = yield* sessions.get(input.providerSessionId); - if (Option.isNone(session)) { - // The task's session was already released — the task cannot be - // running under it any more, so there is nothing left to stop. - yield* Effect.logWarning( - "Provider task stop found no live session; treating as already stopped", - { - threadId: input.threadId, - providerSessionId: input.providerSessionId, - nativeTaskId: input.nativeTaskId, - }, - ); - return; - } - const stop = session.value.stopTask; - if (stop === undefined) { - return yield* new ProviderTaskStopError({ - threadId: input.threadId, - providerSessionId: input.providerSessionId, - nativeTaskId: input.nativeTaskId, - cause: "The provider runtime for this session does not support stopping tasks.", - }); - } - yield* stop({ nativeTaskId: input.nativeTaskId }); - }).pipe( - Effect.mapError((cause) => - isProviderTaskStopError(cause) - ? cause - : new ProviderTaskStopError({ - threadId: input.threadId, - providerSessionId: input.providerSessionId, - nativeTaskId: input.nativeTaskId, - cause, - }), - ), - ), steer: (input) => Effect.gen(function* () { const loaded = yield* load({ ...input, operation: "steer" }); diff --git a/apps/server/src/orchestration-v2/testkit/OrchestratorScenario.ts b/apps/server/src/orchestration-v2/testkit/OrchestratorScenario.ts index 95dfcb373e..a2e4a06610 100644 --- a/apps/server/src/orchestration-v2/testkit/OrchestratorScenario.ts +++ b/apps/server/src/orchestration-v2/testkit/OrchestratorScenario.ts @@ -137,7 +137,6 @@ function commandThreadIds(command: OrchestrationV2Command): ReadonlyArray( scheduler, concurrency, }), - stopSubagent: createEnvironmentCommand(runtime, { - label: "environment-data:commands:thread:stop-subagent", - execute: (input: StopThreadSubagentInput) => stopThreadSubagent(input), - scheduler, - concurrency, - }), respondToApproval: createEnvironmentCommand(runtime, { label: "environment-data:commands:thread:respond-to-approval", execute: (input: RespondToThreadApprovalInput) => respondToThreadApproval(input), diff --git a/packages/contracts/src/orchestrationV2.ts b/packages/contracts/src/orchestrationV2.ts index d10fda1e76..eee60149b1 100644 --- a/packages/contracts/src/orchestrationV2.ts +++ b/packages/contracts/src/orchestrationV2.ts @@ -2296,14 +2296,6 @@ export const OrchestrationV2Command = Schema.Union([ runId: RunId, reason: Schema.optional(Schema.String), }), - Schema.Struct({ - /** Stop one background subagent task (e.g. a workflow run) without - * interrupting the run that launched it. */ - type: Schema.Literal("subagent.stop"), - commandId: CommandId, - threadId: ThreadId, - subagentId: NodeId, - }), Schema.Struct({ type: Schema.Literal("queued-message.promote-to-steer"), commandId: CommandId,