@@ -402,6 +402,7 @@ export interface AcpAdapterV2Flavor {
402402 ) => AcpAdapterV2SubagentUpdate | undefined ;
403403 readonly isProvisionalSubagentTool ?: ( toolCall : AcpToolCallState ) => boolean ;
404404 readonly normalizeToolCall ?: ( toolCall : AcpToolCallState ) => AcpToolCallState ;
405+ readonly isCancelledToolCall ?: ( payload : unknown ) => boolean ;
405406 readonly extractProposedPlanMarkdown ?: ( toolCall : AcpToolCallState ) => string | undefined ;
406407 readonly extractBackgroundTaskId ?: ( toolCall : AcpToolCallState ) => string | undefined ;
407408 /** Distinguishes commands from monitors when lifecycle notifications omit their kind. */
@@ -3511,6 +3512,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
35113512 context : ActiveAcpTurn ,
35123513 incoming : AcpToolCallState ,
35133514 projectedStatus ?: ProjectedToolStatus ,
3515+ rawPayload ?: unknown ,
35143516 ) => Effect . Effect < void > = ( ) => Effect . void ;
35153517
35163518 const markAwaitingBackgroundHydration =
@@ -3563,6 +3565,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
35633565 context : ActiveAcpTurn ,
35643566 incoming : AcpToolCallState ,
35653567 projectedStatus ?: ProjectedToolStatus ,
3568+ rawPayload ?: unknown ,
35663569 ) {
35673570 if ( context . assistant . current ?. sourceMessageId == null )
35683571 yield * closeTextStream ( context , "assistant" ) ;
@@ -3603,11 +3606,12 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
36033606 ? toolCall
36043607 : { ...toolCall , backgroundCommandTaskId } ,
36053608 ) ;
3606- // fx 0.0.15 fails the tools a Stop cut off; they read as interrupted, like ones left open .
3609+ // A failure racing Stop needs the provider's cancellation signal before relabeling it .
36073610 const previousStatus = previous === undefined ? undefined : toolStatus ( previous . status ) ;
36083611 if (
36093612 context . interrupted &&
36103613 toolCall . status === "failed" &&
3614+ flavor . isCancelledToolCall ?.( rawPayload ) === true &&
36113615 ( previousStatus === "pending" ||
36123616 previousStatus === "running" ||
36133617 previousStatus === "waiting" )
@@ -5275,7 +5279,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
52755279 const parsed = parseSessionUpdateEvent ( notification ) ;
52765280 for ( const event of parsed . events ) {
52775281 if ( event . _tag === "ToolCallUpdated" ) {
5278- yield * emitTool ( context , event . toolCall ) ;
5282+ yield * emitTool ( context , event . toolCall , undefined , event . rawPayload ) ;
52795283 } else if ( event . _tag === "PlanUpdated" ) {
52805284 yield * emitPlan ( context , event . payload ) ;
52815285 } else if ( event . _tag === "NoticeReceived" ) {
0 commit comments