Skip to content

mozilla-ai/any-agent

Repository files navigation

any-agent

any-agent is a Python library designed to provide a single interface to access many different agent frameworks.

Using any-agent, you can more easily switch to a new or different agent framework without needing to worry about the underlying API changes.

any-agent also provides a 'trace-first' llm-as-a-judge powered evaluation tool for flexible evaluation of agent execution traces.

Google ADK LangChain LlamaIndex OpenAI Agents Smolagents Agno AI

Planned for Support (Contributions Welcome!)

Open Github tickets for new frameworks

Requirements

  • Python 3.11 or newer

Quickstart

Refer to pyproject.toml for a list of the options available. Update your pip install command to include the frameworks that you plan on using (or use all to install all the currently supported):

pip install 'any-agent[all]'

To define any agent system you will always use the same imports:

from any_agent import AgentConfig, AnyAgent, TracingConfig

For this example we use a model hosted by openai, but you may need to set the relevant API key for whichever provider being used. See our Model docs for more information about using different models.

export OPENAI_API_KEY="YOUR_KEY_HERE"  # or MISTRAL_API_KEY, etc

Single agent

from any_agent.tools import search_web, visit_webpage

agent = AnyAgent.create(
    "openai",  # Framework type. See all options in https://mozilla-ai.github.io/any-agent/frameworks/
    AgentConfig(
        model_id="gpt-4.1-nano",
        instructions="Use the tools to find an answer",
        tools=[search_web, visit_webpage]
    ),
    tracing=TracingConfig(output_dir="traces") # Optional, but recommended for saving and viewing traces
)

agent.run("Which Agent Framework is the best??")

Multi-agent

from any_agent.tools import search_web, visit_webpage

agent = AnyAgent.create(
    "openai",  # Framework type. See all options in https://mozilla-ai.github.io/any-agent/frameworks/
    AgentConfig(
        model_id="gpt-4.1-mini",
        instructions="You are the main agent. Use the other available agents to find an answer",
    ),
    managed_agents=[
        AgentConfig(
            name="search_web_agent",
            description="An agent that can search the web",
            model_id="gpt-4.1-nano",
            tools=[search_web]
        ),
        AgentConfig(
            name="visit_webpage_agent",
            description="An agent that can visit webpages",
            model_id="gpt-4.1-nano",
            tools=[visit_webpage]
        )
    ]
)

agent.run("Which Agent Framework is the best??")

Features

any-agent supports the use of Model Context Protocol (MCP) servers, and if the agent framework allows, any LLM and provider using LiteLLM syntax.

Learn more in the docs:

Contributions

The AI agent space is moving fast! If you see a new agentic framework that AnyAgent doesn't yet support, we would love for you to create a Github issue. We also welcome your support in development of additional features or functionality.

Running in Jupyter Notebook

If running in Jupyter Notebook you will need to add the following two lines before running AnyAgent, otherwise you may see the error RuntimeError: This event loop is already running. This is a known limitation of Jupyter Notebooks, see Github Issue

import nest_asyncio
nest_asyncio.apply()