Skip to content

Are local MCP tool calls intentionally excluded from session persistence? #2384

@k1eran

Description

@k1eran

Description

I’m using the openai-agents-python SDK with local MCP servers (MCPServerStdio / MCPServerStreamableHttp) and had a question about how tool calls are persisted to session storage.

While instrumenting session persistence, I noticed a difference between function tools and local MCP tools, and wanted to check whether this behavior is intentional or a potential oversight.

Environment

SDK: openai-agents-python @ e0bde88
MCP usage: local MCP servers, not Hosted MCP (HostedMCPTool)
Session persistence: custom SessionStorage implementation

Observed behavior

When logging the items passed from the SDK into session storage, I consistently see:

Persisted:

  • User messages
  • Assistant messages
  • Handoff function calls (transfer_to_*)
  • Function tool calls (@function_tool)

Missing:

  • Local MCP tool calls (from MCP servers)

This behavior appears consistent across turns.

Minimal pseudocode illustrating this

class CustomSessionStorage(SessionStorage):
    async def add_items(self, items: list[dict]) -> None:
        for item in items:
            log(item.get("type"), item)

Observed item types:

  • message
  • tool_call (function tools)
  • handoff

Not observed

  • Any item corresponding to local MCP tool calls

This logging reflects exactly what the SDK passes into SessionStorage; no filtering is applied on my side.

Possible root cause (from code review)

From reviewing the SDK internals, it looks like:

  • Local MCP tools execute out-of-band in turn_resolution.py
  • They do not appear to create ToolCallItem objects?
    As a result, they never reach session_items_for_turn() and are not included in save_result_to_session()
    This may explain why function tools and MCP tools behave differently with respect to session persistence?

Current workaround

I can observe local MCP tool activity via SSE streaming events (e.g. tool_call.in_progress), which provides real-time visibility. However, this doesn’t help with session replay or rehydration, since those events are not persisted.

Questions

  1. Is the exclusion of local MCP tool calls from session persistence intentional?
  2. Are MCP tool calls expected to be non-replayable / non-persisted by design?
  3. If not intentional, would the correct fix be:
  • creating ToolCallItems for MCP tools during turn resolution, or
  • extending session persistence to capture MCP tool execution metadata?
  1. Is there a recommended pattern for persisting MCP tool calls if session replay is needed?

Documentation context

The sessions documentation mentions that

tool calls, etc. are automatically stored

which led me to expect parity between function tools and MCP tools. I didn’t see any explicit exception noted for local MCP tools.

Docs referenced: https://openai.github.io/openai-agents-python/

Prior checks

I’ve read the Agents SDK documentation
I’ve searched existing GitHub issues and didn’t find one addressing local MCP tool persistence specifically

Happy to clarify or test changes if this turns out to be unintended behaviour.

Cheers,
Kieran

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions