( tools: Tools, model: string, messages: Message[] | undefined, scanContext?: DeferredToolsDeltaScanContext, )
| 1507 | |
| 1508 | // Exported for compact.ts — the gate must be identical at both call sites. |
| 1509 | export function getDeferredToolsDeltaAttachment( |
| 1510 | tools: Tools, |
| 1511 | model: string, |
| 1512 | messages: Message[] | undefined, |
| 1513 | scanContext?: DeferredToolsDeltaScanContext, |
| 1514 | ): Attachment[] { |
| 1515 | if (!isDeferredToolsDeltaEnabled()) return [] |
| 1516 | // These three checks mirror the sync parts of isSearchExtraToolsEnabled — |
| 1517 | // the attachment text says "available via SearchExtraTools", so SearchExtraTools |
| 1518 | // has to actually be in the request. The async auto-threshold check |
| 1519 | // is not replicated (would double-fire tengu_search_extra_tools_mode_decision); |
| 1520 | // in tst-auto below-threshold the attachment can fire while SearchExtraTools |
| 1521 | // is filtered out, but that's a narrow case and the tools announced |
| 1522 | // are directly callable anyway. |
| 1523 | if (!isSearchExtraToolsEnabledOptimistic()) return [] |
| 1524 | if (!isSearchExtraToolsToolAvailable(tools)) return [] |
| 1525 | const delta = getDeferredToolsDelta(tools, messages ?? [], scanContext) |
| 1526 | if (!delta) return [] |
| 1527 | return [{ type: 'deferred_tools_delta', ...delta }] |
| 1528 | } |
| 1529 | |
| 1530 | /** |
| 1531 | * Diff the current filtered agent pool against what's already been announced |
no test coverage detected