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

Function closeNativeReasoningBlock

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

Source from the content-addressed store, hash-verified

361 * been added after the reasoning block but before text output starts.
362 */
363export const closeNativeReasoningBlock = (
364 blocks: ContentBlock[],
365): ContentBlock[] => {
366 // Find the last native reasoning block (not just the last block)
367 let lastReasoningIndex = -1
368 for (let i = blocks.length - 1; i >= 0; i--) {
369 if (isNativeReasoningBlock(blocks[i])) {
370 lastReasoningIndex = i
371 break
372 }
373 }
374
375 if (lastReasoningIndex === -1) {
376 return blocks
377 }
378
379 const reasoningBlock = blocks[lastReasoningIndex]
380 if (reasoningBlock.type !== 'text') {
381 return blocks
382 }
383
384 const nextBlocks = [...blocks]
385 nextBlocks[lastReasoningIndex] = {
386 ...reasoningBlock,
387 thinkingOpen: false,
388 }
389 return nextBlocks
390}
391
392export const appendTextToRootStream = (
393 blocks: ContentBlock[],

Callers 7

updateAgentTextFunction · 0.85
appendTextToRootStreamFunction · 0.85
appendToolToAgentBlockFunction · 0.85
markAgentCompleteFunction · 0.85

Calls 1

isNativeReasoningBlockFunction · 0.85

Tested by

no test coverage detected