MCPcopy Create free account
hub / github.com/Noumena-Network/code / getDeferredToolsDeltaAttachment

Function getDeferredToolsDeltaAttachment

src/utils/attachments.ts:1461–1481  ·  view source on GitHub ↗
(
  tools: Tools,
  model: string,
  messages: Message[] | undefined,
  scanContext?: DeferredToolsDeltaScanContext,
)

Source from the content-addressed store, hash-verified

1459
1460// Exported for compact.ts — the gate must be identical at both call sites.
1461export function getDeferredToolsDeltaAttachment(
1462 tools: Tools,
1463 model: string,
1464 messages: Message[] | undefined,
1465 scanContext?: DeferredToolsDeltaScanContext,
1466): Attachment[] {
1467 if (!isDeferredToolsDeltaEnabled()) return []
1468 // These three checks mirror the sync parts of isToolSearchEnabled —
1469 // the attachment text says "available via ToolSearch", so ToolSearch
1470 // has to actually be in the request. The async auto-threshold check
1471 // is not replicated (would double-fire ncode_tool_search_mode_decision);
1472 // in tst-auto below-threshold the attachment can fire while ToolSearch
1473 // is filtered out, but that's a narrow case and the tools announced
1474 // are directly callable anyway.
1475 if (!isToolSearchEnabledOptimistic()) return []
1476 if (!modelSupportsToolReference(model)) return []
1477 if (!isToolSearchToolAvailable(tools)) return []
1478 const delta = getDeferredToolsDelta(tools, messages ?? [], scanContext)
1479 if (!delta) return []
1480 return [{ type: 'deferred_tools_delta', ...delta }]
1481}
1482
1483/**
1484 * Diff the current filtered agent pool against what's already been announced

Callers 3

getAttachmentsFunction · 0.85
compactConversationFunction · 0.85

Calls 5

getDeferredToolsDeltaFunction · 0.85

Tested by

no test coverage detected