AI Agents who create AI Agents and own tools

Iman Johari
7 min readFeb 27, 2025

--

Introduction

It may sound like a scene from a sci-fi movie, one similar to the movie Matrix in the scene which Neo was fighting all those agents.

Agents creating agents ? What would that mean? My take is that let’s say a task is given to an agent, and the agent itself comes up with the agents it needs to complete the task. Let’s go even further, the agent is not limited by the tools that has been defined for it, the agent can create its own tools in addition to creating agents with specific tools. Sounds kinda exciting let’s explore these concepts.

Agents creating agents

Let’s take a look at a very common use case for AI Agents. The research agent and the report agent. In this use case we have:

  • A researcher AI agent that does research on a given topic
  • A Report agent who creates a nicely formatted report from the output of the researcher agent.

The researcher agent has tools such as “web search tool” which searches the web for given topic, as well as search capability to search private repositories through api calls. To build above solution first we need to choose an agent framework such as crew ai, langchain or IBM bee agent. then we define our two agents and then create the tools for our agents; In the end we execute these agents having defined an orchestration in which we define the order in which these agents would run passing the topic to the system and the output will be a nicely formatted report.

How can we come up with a solution in which we provide the problems and the problem goes through one agent and that one agent comes up with required agents for the job?

In our Example above, the problem could be uttered as “to create a nicely formatted report from a research on a given topic” and it could come up with the above solution.

A Solution to above problem could be Another AI Agent; Let’s call this agent the “Mother Agent”. Mother agents can

  • Decide what agents required for the task
  • Create agents in the execution environment
  • Define relationship between agent in the execution environment
  • Create tools for the agents
  • Execute agents

Agents creating their own tools

What are tools for agents? A famous scene from “Matrix movie” in which Neo says “I know Kung fu” has always been mesmerizing for me!

In this context “Kung fu” is a tool that was uploaded for Neo so he can fight. For AI agents They could be functions, api calls, database calls etc. Majority of Large Language Models nowadays can also generate code; what can stop an agent from coming up with the logic of the tools it needs, implementing it and actually executing it?

For an agent to be able to have this capability, A possible solution is for each agent to have a tool which enables the agent to create other tools. It acts as a magic box for the agent to give itself more capabilities.

Tool Factory

A tool factory is a place that agent would create its own tools, It can be a tool itself. The agent can even share their tools with other agents in a Tool Marketplace! An AI agent who utilizes tools, may not necessarily need to build them or have them defined initially when agent is created, it could search a tool factory and obtain tools available for its purpose!

With that then we’d need to consider access control to tools from agents to agents ! At the moment we have resource access control for human users, then we’d probably need to define “agent tool access control”. All Of these of course would be limited to their execution environment.

We could even go further and see if agents can live in another execution environment? Could a research agent running in enterprise A replicate itself in enterprise B and do research ?

Architecture and implementation (Bonus challenge)

I will divide the essence of mentioned requirements from above into 4 functional requirements :

Functional requirement 1: A user passes a problem to the “Mother Agent” and get a list of agents and tools

Functional requirement 2: A “Mother Agent” creating agents given a list of agents

Functional requirement 3: Any agent can creates it’s own tools through a default agent tool aka “tool factory

Functional requirement 4: Any agent can search for a tool in a “Tool marketplace” and obtain appropriate tool(s) for it’s purpose

Implementation

Writing a simple prompt in any LLM of your choice creates the code for you for Functional Requirement 1 and Functional Requirement 2:

I want to create an AI agent that receives a problem and it tells me what agents, tools I would need to solve that problem

This prompt will generate a nice code that once a problem statement is entered, then it creates various agents and tasks and performs some thoughtful results : for example I entered my problem statement as “I want to come up with a plan for world domination”; this program ran and created 6 agents : below is each agent and their thoughts on “World Domination

  • Research Agent
  • Strategy Agent
  • Resource Agent
  • Diplomacy Agent
  • Execution Agent
  • Monitoring Agent

quite neat eh ! :) that was EASY…

Functional Requirement 3 : An agent creates it’s own tools through another tool aka tool factory

Now let’s move to the more challenging part ! above approach does not necessarily create tools for you! it only creates agents, and some tasks! the biggest challenge is to :

  • Create a tool that does not exist dynamically at runtime for the agent
  • register it to the agent at run time as part of own tools to be used as part of the agents capability
  • Execute the Tool at runtime

For Example let’s consider a very common tool which is calling an api in particular the Serper api tool ; with this tool we can do web searches for agents if the tool is already defined. What if this tool is not defined for the agent but mentioned as part of the problem; I did an experiment with a Tool Factory approach that each agent would be able to build their own tools and gave my problem as

use serperapi.com to compare google and micro-soft stock price in the last few weeks;serper apikey is XXXXX<my key>; you can create a tool to do the search

Summarize the results after analyzing the problem and creating these agents are:

  • DataRetrieval Agent
  • DataComparison Agent
  • Report Agent

The agents are created, the flow of agents is defined well, it does create the code for the tools however it is not able to run this code at the agent runtime.

For “Data Retrieval agent”

and the code provided as

For “Data comparison agent”

and finally for the “Report agent

There is a partial solution that creates the tools however it does not execute the tool at runtime.

Alternatively there can be a manual step through Creating User Interface in which the user would have a step to choose or generate a tool without any coding!But, a fully automated approach is still something more desireable and at the same time risky!

Functional requirement 4: Any agent can search for a tool in a “Tool marketplace” and obtain appropriate tool(s) for it’s purpose

This functionality enables agents to dynamically discover and acquire tools as needed, enhancing flexibility and automation. The marketplace should provide an efficient search mechanism, allowing agents to filter tools based on relevant attributes such as functionality, compatibility, and availability. Once a suitable tool is identified, the agent should be able to acquire and integrate it seamlessly into its workflow, ensuring smooth task execution and optimal performance.

I leave the implementation for this to another post. This is the challenge, see if you can create a Marketplace from which the agent can search the tool it requires at runtime and obtain the tool and run it as part of its workflow :)

Resources

github code: https://github.com/ijgitsh/mother-agent/

Matrix: https://www.imdb.com/title/tt0133093/

--

--

No responses yet