MCPcopy Create free account
hub / github.com/IIIIQIIII/claude-code / stripAdvisorBlocks

Function stripAdvisorBlocks

src/utils/messages.ts:5466–5494  ·  view source on GitHub ↗
(
  messages: (UserMessage | AssistantMessage)[],
)

Source from the content-addressed store, hash-verified

5464 * with name "advisor" unless the advisor beta header is present.
5465 */
5466export function stripAdvisorBlocks(
5467 messages: (UserMessage | AssistantMessage)[],
5468): (UserMessage | AssistantMessage)[] {
5469 let changed = false
5470 const result = messages.map(msg => {
5471 if (msg.type !== 'assistant') return msg
5472 const content = msg.message.content
5473 const filtered = content.filter(b => !isAdvisorBlock(b))
5474 if (filtered.length === content.length) return msg
5475 changed = true
5476 if (
5477 filtered.length === 0 ||
5478 filtered.every(
5479 b =>
5480 b.type === 'thinking' ||
5481 b.type === 'redacted_thinking' ||
5482 (b.type === 'text' && (!b.text || !b.text.trim())),
5483 )
5484 ) {
5485 filtered.push({
5486 type: 'text' as const,
5487 text: '[Advisor response]',
5488 citations: [],
5489 })
5490 }
5491 return { ...msg, message: { ...msg.message, content: filtered } }
5492 })
5493 return changed ? result : messages
5494}
5495
5496export function wrapCommandText(
5497 raw: string,

Callers 1

queryModelFunction · 0.85

Calls 1

isAdvisorBlockFunction · 0.85

Tested by

no test coverage detected