From 28b748f74d5da4d2d347739f94df308ed9d91104 Mon Sep 17 00:00:00 2001 From: Lakshya Agarwal Date: Fri, 20 Mar 2026 12:44:21 -0400 Subject: [PATCH] feat(tavily): add X-Client-Source attribution header Add optional extraHeaders param to postTrustedWebToolsJson and use it to send X-Client-Source: openclaw on all Tavily API requests (search and extract), matching the Tavily Python SDK's client_source mechanism. --- extensions/tavily/src/tavily-client.ts | 2 ++ src/agents/tools/web-search-provider-common.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/extensions/tavily/src/tavily-client.ts b/extensions/tavily/src/tavily-client.ts index c57f5850af3..867e1e3deaa 100644 --- a/extensions/tavily/src/tavily-client.ts +++ b/extensions/tavily/src/tavily-client.ts @@ -119,6 +119,7 @@ export async function runTavilySearch( apiKey, body, errorLabel: "Tavily Search", + extraHeaders: { "X-Client-Source": "openclaw" }, }, async (response) => (await response.json()) as Record, ); @@ -200,6 +201,7 @@ export async function runTavilyExtract( apiKey, body, errorLabel: "Tavily Extract", + extraHeaders: { "X-Client-Source": "openclaw" }, }, async (response) => (await response.json()) as Record, ); diff --git a/src/agents/tools/web-search-provider-common.ts b/src/agents/tools/web-search-provider-common.ts index 79827ef7cb8..a08ad97915e 100644 --- a/src/agents/tools/web-search-provider-common.ts +++ b/src/agents/tools/web-search-provider-common.ts @@ -100,6 +100,7 @@ export async function postTrustedWebToolsJson( body: Record; errorLabel: string; maxErrorBytes?: number; + extraHeaders?: Record; }, parseResponse: (response: Response) => Promise, ): Promise { @@ -110,6 +111,7 @@ export async function postTrustedWebToolsJson( init: { method: "POST", headers: { + ...params.extraHeaders, Accept: "application/json", Authorization: `Bearer ${params.apiKey}`, "Content-Type": "application/json",