Skip to content

Toolset, take 3 #1973

@samuelcolvin

Description

@samuelcolvin

Toolsets live again! Phoenix of #110

Rough working:

from abc import abstractmethod, ABC
from contextlib import asynccontextmanager


mcp_thing = MCPThing()

agent = Agent(
    mcp_servers=[mcp_thing],
)

# ---
#
class Toolset(ABC):

    async def __aenter__(self, run_context, sampling_callback, agent_name: str):
        pass

    async def __aexit__(self, exc_type, exc_val, exc_tb):
        pass

    @abstractmethod
    async def list_tools(self):
        return []

    async def call_tools(self, tools) -> list[Part]:
        ...

agent = Agent(
    toolset=mcp_thing,
)

agent = Agent(
    toolset=[
        FilterToolsToolset(MCPToolset(mcp_thing1), exclude='foo'),
        MCPToolset(mcp_thing2),
    ],
)

@agent.tool
def foo():
    pass


agent.run_sync()

async def main():
    async with agent.run_toolsets():

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions