yc2bgr8 17f4722d2b
feat(community): migrate tavily tools to AsyncTavilyClient (#5784)
* feat(community): migrate tavily tools to AsyncTavilyClient

Replace the synchronous TavilyClient with AsyncTavilyClient in the tavily
community tools, as tracked in backend/docs/TODO.md planned features
('Replace sync requests with httpx.AsyncClient in community tools').

web_search_tool and web_fetch_tool become async functions and await
client.search()/client.extract(). External behavior (return values,
error strings, credentials handling) is unchanged; the client is still
constructed with api_key=None when the tool config has no key, letting
the SDK read TAVILY_API_KEY from the environment.

Tests are updated to invoke the async tools via ainvoke under
@pytest.mark.anyio, and the credential assertions now verify the client
is constructed with the right api_key (AsyncTavilyClient keeps the key
inside its httpx client and exposes no public api_key attribute).

* fix(tavily): close async clients after each tool request

---------

Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
2026-09-26 11:43:32 +08:00
..