Skip to content

Python: [Bug]: Multiple FileAccessProvider context providers fail with duplicate tool names #9646

Description

Observed Behavior

Configuring an Agent with two FileAccessProvider context providers, each backed by a different store and using a distinct source_id, causes the run to fail before the chat client is invoked.

Both providers expose the same file_access_* tool names. During option merging, the framework raises a duplicate-tool error, so an agent cannot use file access across multiple independently rooted stores.

Expected Behavior

Multiple FileAccessProvider context providers should be usable on one agent without their tools colliding. The providers should expose distinguishable tools or otherwise preserve enough provider identity to route each call to the intended store.

Steps to Reproduce

  1. Create two FileAccessProvider instances backed by separate stores.
  2. Give each provider a unique source_id.
  3. Add both providers to one Agent through context_providers.
  4. Run the agent.
  5. Observe that the run fails while merging tools.

Minimal Reproduction

import asyncio

from agent_framework import (
    Agent,
    BaseChatClient,
    ChatResponse,
    FileAccessProvider,
    InMemoryAgentFileStore,
    Message,
)


class Client(BaseChatClient):
    async def _inner_get_response(self, *, messages, stream, options, **kwargs):
        return ChatResponse(
            messages=[Message(role="assistant", contents=["ok"])]
        )


async def main():
    agent = Agent(
        Client(),
        context_providers=[
            FileAccessProvider(
                InMemoryAgentFileStore(),
                source_id="spec_files",
                disable_readonly_tool_approval=True,
                disable_write_tool_approval=True,
            ),
            FileAccessProvider(
                InMemoryAgentFileStore(),
                source_id="sdk_files",
                disable_readonly_tool_approval=True,
                disable_write_tool_approval=True,
            ),
        ],
    )

    await agent.run("test")


asyncio.run(main())

Error Messages and Stack Traces

ValueError: Duplicate tool name 'file_access_read'. Tool names must be unique.

The exception is raised from _merge_options() while _prepare_run_context() merges the tools supplied by both providers.

Package Versions

  • agent-framework-core: 1.23.0
  • agent-framework-foundry: 1.15.0

Python Version

Python 3.14.7

Operating System

Windows

Regression

Unknown

Additional Context

source_id records provider attribution but does not alter the fixed file_access_* tool names. Disabling tool approval in the reproduction isolates the duplicate-name failure from approval middleware behavior.

Acknowledgements

  • I searched existing issues and did not find a duplicate.
  • I personally verified this behavior and the reproduction details are authentic.
  • I will wait for explicit maintainer agreement before starting implementation of a non-trivial change.

Proposed Solution

Add an optional prefix parameter to the FileAccessProvider constructor and use it when naming the provider's tools. The default should preserve the current file_access_* names for backward compatibility.

context_providers=[
    FileAccessProvider(spec_store, prefix="spec_files"),
    FileAccessProvider(sdk_store, prefix="sdk_files"),
]

This would expose distinct names such as spec_files_read and sdk_files_read, allowing multiple file-access providers to coexist while making the target store clear to the model.

Metadata

Metadata

Labels

pythonUsage: [Issues, PRs], Target: Python

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions