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