Agents Manager
A lightweight Python package for managing multi-agent orchestration. Easily define agents with custom instructions, tools, and models, and orchestrate their interactions seamlessly. Perfect for building modular, collaborative AI systems.
Features
- Define agents with specific roles and instructions
- Assign models to agents (e.g., OpenAI models)
- Equip agents with tools and containers for performing tasks
- Seamlessly orchestrate interactions between multiple agents
Supported Models
- OpenAI
- Grok
- DeepSeek
- Anthropic
- Llama
- Genai
Installation
Install the package via pip:
pip install agents-manager
Quick Start
from agents_manager.utils import handover
from agents_manager import Agent, AgentManager
from agents_manager.models import OpenAi, Anthropic, Genai
from dotenv import load_dotenv
load_dotenv()
# Define the OpenAi model
openaiModel = OpenAi(name="gpt-4o-mini")
#Define the Anthropic model
anthropicModel = Anthropic(
name="claude-3-5-sonnet-20241022",
max_tokens= 1024,
)
#Define the Genai model
genaiModel = Genai(name="gemini-2.0-flash-001")
def multiply(a: int, b: int) -> int:
"""
Multiply two numbers.
"""
return a * b
def transfer_to_agent_3_for_math_calculation() -> Agent:
"""
Transfer to agent 3 for math calculation.
"""
return agent3
# The 'handover' function allows for transferring tasks to specific agents by name instead of instance.
# When `share_context` is set to True, the receiving agent will receive the
# chat history of the agent that is invoking the handover.
handover_to_agent2 = handover(name="agent2", description="This is a calculator", share_context=False)
# Define agents
agent3 = Agent(
name="agent3",
instruction="You are a maths teacher, explain properly how you calculated the answer.",
model=genaiModel,
tools=[multiply]
)
agent2 = Agent(
name="agent2",
instruction="You are a maths calculator bro",
model=anthropicModel,
tools=[transfer_to_agent_3_for_math_calculation]
)
agent1 = Agent(
name="agent1",
instruction="You are a helpful assistant",
model=openaiModel,
tools=[handover_to_agent2]
)
# Initialize Agent Manager and run agent
agent_manager = AgentManager()
agent_manager.add_agent(agent1)
# Using transfer doesn't require pre-adding the agent, but with handover, the agent must be added to
# the agent_manager beforehand.
agent_manager.add_agent(agent2)
response = agent_manager.run_agent("agent1", "What is 2 multiplied by 3?")
print(response["content"])
You can run for stream response as well.
response_stream = agent_manager.run_agent_stream("agent1", [
{"role": "user", "content": "What is 2 multiplied by 3?"},
])
for chunk in response_stream:
print(chunk["content"], end="")
You can also pass container as tool to the agent.
from agents_manager import Agent, AgentManager, Container
...
agent4 = Agent(
name="agent4",
instruction="You are a helpful assistant",
model=model,
tools=[Container(
name="hello",
description="A simple hello world container",
image="hello-world:latest",
)]
)
You can also pass the result of the container to the next agent with result variable.
from agents_manager import Agent, Container
...
agent5 = Agent(
name="agent1",
instruction="You are a helpful assistant",
model=model,
tools=[Container(
name="processing",
description="Container to do some processing...",
image="docker/xxxx:latest",
environment=[
{"name": "input1", "type": "integer"},
{"name": "input2", "type": "integer"}
],
authenticate={
"username": "xxxxx",
"password": "xxxxx",
"registry": "xxxxx"
},
return_to={
"agent": agent6,
"instruction": "The result is: {result}" # {result} will be replaced with the result of the container
},
)]
)
You can also pass output_format to agent to format the output.
from pydantic import BaseModel
from agents_manager import Agent
class Answer(BaseModel):
value: str
agent1 = Agent(
name="agent1",
instruction="You are a helpful assistant",
model=model,
output_format=Answer
)
Note 1: The output_format should be a pydantic model.
Note 2: Anthropic model does not support output_format, you can use tool to format the output.
Note 3: handover with share_context does not work correctly for Genai
You can also run the agent with a dictionary as the input content.
response = agent_manager.run_agent("agent1", {"role": "user", "content": "What is 2 multiplied by 3?"})
You can also run the agent with a list of history of messages as the input.
response = agent_manager.run_agent("agent1", [
{"role": "user", "content": "What is 2 multiplied by 3?"},
])
More models
from agents_manager.models import Grok, DeepSeek, Llama
#Define the Grok model
modelGrok = Grok(name="grok-2-latest")
#Define the DeepSeek model
modelDeepSeek = DeepSeek(name="deepseek-chat")
#Define the Llama model
modelLlama = Llama(name="llama3.1-70b")
Troubleshooting
- While using Genai model with functions, if you get the following error:
google.genai.errors.ClientError: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': '* GenerateContentRequest.tools[0].function_declarations[0].parameters.properties: should be non-empty for OBJECT type\n', 'status': 'INVALID_ARGUMENT'}}
It is because google genai does not support functions without parameters. You can fix this by providing a dummy parameter. Please let me know if you have a better solution for this.
- If you get the following error while running the container tool:
Error: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
It is because the docker daemon is not running. You can fix this by starting the docker daemon. and export the following environment variable:
#linux
export DOCKER_HOST=unix:///var/run/docker.sock
#colima
export DOCKER_HOST=unix://$HOME/.colima/default/docker.sock
How It Works
- Define Agents: Each agent has a name, a specific role (instruction), and a model.
- Assign Tools: Agents can be assigned tools (functions and containers) to perform tasks.
- Create an Agent Manager: The
AgentManagermanages the orchestration of agents. - Run an Agent: Start an agent to process a request and interact with other agents as needed.
Use Cases
- AI-powered automation systems
- Multi-agent chatbots
- Complex workflow orchestration
- Research on AI agent collaboration
Contributing
Contributions are welcome! Feel free to submit issues and pull requests.
License
MIT License
Metadata
Release files for agents-manager 1.4.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| agents_manager-1.4.6.tar.gz | 19.7 kB | With provenance | Details for agents_manager-1.4.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agents_manager-1.4.6-py3-none-any.whl | Python 3 | none | any | Details for agents_manager-1.4.6-py3-none-any.whl |
Total release size: 43.0 kB
Release files / agents_manager-1.4.6.tar.gz
| Download URL | agents_manager-1.4.6.tar.gz |
|---|---|
| Size | 19.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
62c312b6045a8048469bd56e2f918555c78ad5e2a8f061573f8c2d7763dd241b
|
|
BLAKE2b-256 checksum How to use checksums |
76e92b4f4631a8e93aac270995adbfb12a204197e35009fb11a0fe909fbd9a74
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 31, 2025.
Transparency logRelease files / agents_manager-1.4.6-py3-none-any.whl
| Download URL | agents_manager-1.4.6-py3-none-any.whl |
|---|---|
| Size | 23.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b763119575cca8275c64b3e349411e481ebd481ccaab1b972e6c04d0014e7deb
|
|
BLAKE2b-256 checksum How to use checksums |
a0edb5320b023b80ce009113982e0b699f12228d5ea714aeea0e33e86485a083
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 31, 2025.
Transparency logSecurity for agents-manager 1.4.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for agents_manager-1.4.6.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 31, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.