Skip to content

[FEATURE] Agent to_tool methodΒ #1002

@Unshure

Description

@Unshure

Problem Statement

I would like to easily pass an agent as a tool to anther agent with as little boiler plate code as possible.

Proposed Solution

researcher = Agent(system_prompt="You research topics")

manager = Agent(system_prompt="You delegate to the researcher", tools=[researcher.to_tool()])

The to_tool method returns an AgentTool instance for invoking an agent as a tool. It will initially take in a single parameter named preserve_context: bool to determine if each time the agent as a tool is invoked, if the previous conversation context should be wiped or not.

Use Case

Make it easier to use one agent as a tool for another agent.

Alternatives Solutions

researcher = Agent(system_prompt="You research topics")

manager = Agent(system_prompt="You delegate to the researcher", tools=[researcher])

Allow an agent to be passed in directly to the tool array. We can do this as a follow up, but for configuration, we want to have a specific method on the agent class that enables this behavior.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions