가입 후 초대 링크를 공유하면 동영상 재생 및 초대 보상을 받을 수 있습니다.

cv usk
@cv_usk
AI / Software Research Notes AI Agent, LLMOps, MLOps, Software Architecture 投稿は個人の意見です。
가입 May 2026
286 팔로잉 중    470 팬
# Useful but Little-Known Features of OpenAI Agent SDK 🌍 Is every tool list fetch hitting the network even though your tools rarely change? Caching `list_tools()` lets you skip redundant network calls for stable tool definitions, dramatically reducing latency. 📌 Title: list_tools() Caching 🔗 URL: 🧩 Overview When MCP server tool definitions don't change often, calling `list_tools()` over the network every time is wasteful. Simply set `cache_tools_list=True` to cache the tool list in memory, speeding up all subsequent fetches. When tool definitions do change, call `server.invalidate_tools_cache()` to explicitly clear the cache. 🛠 How to use it ```python from agents.mcp import MCPServerStreamableHttp # Enable tool list caching server = MCPServerStreamableHttp( params={"url": ""}, cache_tools_list=True, ) async with server: # First call hits the network, subsequent calls use cache tools = await server.list_tools() # Clear cache when tool definitions change server.invalidate_tools_cache() tools = await server.list_tools() # Fetches fresh list ``` 🏗 Building it into production ・Always set `cache_tools_list=True` for MCP servers with stable tool definitions ・Call `invalidate_tools_cache()` during deployments or tool updates to refresh the cache ・When multiple agents share the same server, caching improves overall system latency ・Periodically refresh the cache during health checks for added reliability 💡 Use cases ⚡ Improving response times in high-frequency chat applications 🔄 Reducing tool list overhead in multi-turn conversations 🏢 Optimizing internal MCP servers with stable tool sets 📉 Cutting costs by reducing request volume to MCP servers ⚠️ Watch out With caching enabled, tool additions or removals on the MCP server won't be reflected until the cache is invalidated. In environments where tool definitions change dynamically, call `invalidate_tools_cache()` at the right moments or leave caching disabled. ✨ One simple flag to eliminate the overhead of MCP tool fetching. #OpenAIAgentSDK# #AIAgent#
더 보기