Skip to content

docs: unified capability-visibility pattern across function tools, MCP tools, and handoffs #4618

Closed

Description

@dgenio

The Agents SDK now has several useful mechanisms for controlling what an agent can see at runtime:

  • "FunctionTool.is_enabled";
  • "Handoff.is_enabled";
  • MCP "tool_filter";
  • tool guardrails / approvals for execution-time checks;
  • handoff input filtering.

Individually these APIs make sense.

I think there is an opportunity to document a single production pattern for using them together when capability availability comes from the same runtime policy.

Production-shaped use case

Consider an agent application where the capabilities valid for a request depend on runtime context such as:

  • authenticated actor/client;
  • channel or source;
  • application variant;
  • tenant;
  • workflow state;
  • feature flags.

The same application may expose capabilities through several SDK mechanisms:

  • local function tools;
  • MCP tools;
  • specialist-agent handoffs.

Ideally the model-visible capability surface is derived consistently from one application policy rather than implementing slightly different conditions independently for each mechanism.

There is also an important distinction between visibility and authorization.

For example:

  • a tool may be hidden entirely because it is irrelevant or unavailable for this client;
  • a tool may be visible, but execution of a particular call may still require resource-level authorization based on its arguments;
  • a handoff may be valid only during one workflow phase;
  • after a handoff, the new agent should resolve its own effective capability set from the same run context.

Suggested documentation pattern

It would be useful to have one example showing something roughly like:

RunContext
|
+-- capability policy
|
+-- FunctionTool.is_enabled
+-- Handoff.is_enabled
+-- MCP tool_filter
|
+-- invocation-time authorization / guardrails

The example could explicitly establish that:

  1. disabled capabilities are removed before the model sees them;
  2. function tools, MCP tools, and handoffs can derive visibility from the same runtime context;
  3. visibility filtering is not itself a security boundary;
  4. argument/resource-level authorization belongs at invocation time;
  5. capability policy is re-evaluated after agent transitions when appropriate.

Optional observability improvement

A related debugging capability would be useful: being able to inspect the effective model-visible capability set for a model invocation.

For production incidents, one of the first questions is often:

«What tools and handoffs did this agent actually see at this point in the run?»

If this information is already available through tracing/hooks, highlighting the recommended approach in the same example may be enough.

Scope

I'm not proposing another authorization framework or tool registry.

The existing primitives appear sufficient.

The main request is a canonical example showing how they compose into one coherent capability-visibility pattern.

I'd be happy to contribute that example/docs PR if maintainers think the pattern belongs in the SDK documentation.

Activity

  1. dgenio commented on Aug 24, 2026

    @dgenio
    Author

    I checked current main more closely. The observability part is mostly already present.

    In both the streaming and non-streaming turn paths, the runner resolves the effective tools and handoffs, applies name-collision handling, and then writes their names to AgentSpanData.tools and .handoffs immediately before the model call:

    https://github.com/openai/openai-agents-python/blob/main/src/agents/run_internal/run_loop.py#L2098-L2114

    That makes AgentSpanData the existing debugging path for the model-visible capability surface, so I do not think this issue needs a new observability API.

    One boundary: the same agent span can cover multiple turns and these fields are updated in place. If the effective capability set changes between turns without a handoff, the exported span may represent the latest set rather than a per-invocation history. I would not broaden this request to solve that unless maintainers consider the distinction important.

    I would therefore keep the proposed contribution docs/example-only. If the direction is welcome, I can add one focused section next to “Conditional tool enabling” that:

    • derives FunctionTool.is_enabled, Handoff.is_enabled, and MCP tool_filter from one RunContext policy;
    • states that visibility is not resource-level authorization;
    • points to AgentSpanData.tools and .handoffs for debugging;
    • notes the per-agent-span limitation above.

    No new runtime abstraction would be required.

  2. dgenio commented on Aug 24, 2026

    @dgenio
    Author

    Small scope update after following the observability thread separately: I opened #4626 for the per-turn tracing limitation mentioned above.

    That lets this issue stay cleanly docs/example-only:

    • derive function-tool, MCP-tool, and handoff visibility from one request-scoped policy/context;
    • show that the same policy can drive FunctionTool.is_enabled, Handoff.is_enabled, and MCP tool_filter;
    • state explicitly that model-visible capability filtering is not resource/action authorization;
    • point to tracing for debugging the effective capability surface, with Trace the effective tools and handoffs for each model turn #4626 tracking the per-turn history gap.

    So I would not add any new runtime abstraction here. If maintainers agree the pattern belongs in the docs, I am still happy to submit the focused example once the issue is triaged.

  3. changed the title [-][Docs/Enhancement]: Unified capability-visibility pattern across function tools, MCP tools, and handoffs[/-] [+]docs: unified capability-visibility pattern across function tools, MCP tools, and handoffs[/+] on Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions