File tree Expand file tree Collapse file tree
packages/provider-acp/src/server Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -296,6 +296,38 @@ describe("AcpRuntimeModel", () => {
296296 }
297297 } ) ;
298298
299+ it ( "ends a tool call that ACP reports as cancelled" , ( ) => {
300+ const toolCall = ( status : EffectAcpSchema . ToolCallStatus ) => {
301+ const parsed = parseSessionUpdateEvent ( {
302+ sessionId : "session-1" ,
303+ update : {
304+ sessionUpdate : status === "in_progress" ? "tool_call" : "tool_call_update" ,
305+ toolCallId : "tool-1" ,
306+ title : "Run `sleep 60`" ,
307+ kind : "execute" ,
308+ status,
309+ } ,
310+ } as EffectAcpSchema . SessionNotification ) ;
311+ const event = parsed . events [ 0 ] ;
312+ if ( event ?. _tag !== "ToolCallUpdated" ) {
313+ throw new Error ( "expected a tool call update" ) ;
314+ }
315+ return event . toolCall ;
316+ } ;
317+
318+ const running = toolCall ( "in_progress" ) ;
319+ const cancelled = mergeToolCallState ( running , toolCall ( "cancelled" ) ) ;
320+ expect ( cancelled . status ) . toBe ( "failed" ) ;
321+ expect (
322+ decideToolCallUpdateEmission ( {
323+ previous : running ,
324+ next : cancelled ,
325+ lastEmittedDetailLength : 0 ,
326+ skippedSinceEmit : 0 ,
327+ } ) . emit ,
328+ ) . toBe ( true ) ;
329+ } ) ;
330+
299331 it ( "clears prior ACP locations when an update explicitly replaces them" , ( ) => {
300332 const toolCall = ( locations ?: EffectAcpSchema . ToolCallLocation [ ] | null ) => {
301333 const parsed = parseSessionUpdateEvent ( {
Original file line number Diff line number Diff line change @@ -522,6 +522,7 @@ function normalizeToolCallStatus(
522522 case "completed" :
523523 return "completed" ;
524524 case "failed" :
525+ case "cancelled" :
525526 return "failed" ;
526527 default :
527528 return fallback ;
You can’t perform that action at this time.
0 commit comments