MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / markRunningAgentsAsCancelled

Function markRunningAgentsAsCancelled

cli/src/utils/block-operations.ts:491–523  ·  view source on GitHub ↗
(
  blocks: ContentBlock[],
)

Source from the content-addressed store, hash-verified

489 * Also closes any open native reasoning blocks so they don't appear "streaming".
490 */
491export const markRunningAgentsAsCancelled = (
492 blocks: ContentBlock[],
493): ContentBlock[] => {
494 return blocks.map((block) => {
495 if (block.type !== 'agent') {
496 return block
497 }
498
499 // First recursively process nested agents, then close any reasoning blocks
500 let updatedBlocks = block.blocks
501 ? markRunningAgentsAsCancelled(block.blocks)
502 : undefined
503
504 // Close any open native reasoning blocks in this agent
505 if (updatedBlocks) {
506 updatedBlocks = closeNativeReasoningBlock(updatedBlocks)
507 }
508
509 if (block.status === 'running') {
510 return {
511 ...block,
512 status: 'cancelled' as const,
513 ...(updatedBlocks && { blocks: updatedBlocks }),
514 }
515 }
516
517 if (updatedBlocks && updatedBlocks !== block.blocks) {
518 return { ...block, blocks: updatedBlocks }
519 }
520
521 return block
522 })
523}

Callers 2

setupStreamingContextFunction · 0.90

Calls 1

Tested by

no test coverage detected