Register and share your invite link to earn from video plays and referrals.

cv usk
@cv_usk
AI / Software Research Notes AI Agent, LLMOps, MLOps, Software Architecture 投稿は個人の意見です。
Joined May 2026
258 Following    219 Followers
# Useful but Little-Known Features of OpenAI Agent SDK 🌍 Want to dynamically toggle which tools are available based on user permissions or plan tier? The `is_enabled` parameter lets you conditionally control tool availability, providing context-appropriate toolsets. 📌 Title: Conditional Tool Enabling 🔗 URL: 🧩 Overview By passing a boolean `True`/`False` or a callback function `(ctx, agent) -> bool` to the `is_enabled` parameter on `as_tool()`, you can dynamically control whether a tool is enabled or disabled. Disabled tools don't appear in the model's tool list and consume no tokens. This is ideal for feature gating and permission-based access control. 🛠 How to use it ```python from agents import Agent, function_tool, RunContextWrapper @function_tool def admin_tool(command: str) -> str: return execute_admin(command) @function_tool def basic_tool(query: str) -> str: return basic_search(query) # Dynamic check via callback def is_admin(ctx: RunContextWrapper, agent: Agent) -> bool: return ctx.context.user_role == "admin" agent = Agent( name="assistant", tools=[ admin_tool.as_tool(is_enabled=is_admin), basic_tool, ], ) ``` 🏗 Building it into production ・Gate premium feature tools based on SaaS plan tiers ・Control tool access by user role (admin/member/viewer) ・Integrate with feature flags for A/B testing or canary releases of new capabilities ・Optimize toolsets based on context (region, time of day, etc.) 💡 Use cases 🔐 Restricting operational tools to administrators only 💎 Offering advanced tools exclusively to paid-plan users 🚀 Feature flag-driven gradual rollouts 🌏 Switching available services by region ⚠️ Watch out When `is_enabled` is `False`, the tool is not presented to the model at all, so the model has no awareness it exists. While effective for security, if you want to inform users that a feature is unavailable, you'll need a separate messaging mechanism. ✨ Deliver the optimal agent experience for each user with conditional tool enabling. #OpenAIAgentSDK# #AIAgent#
Show more