Observed since 21 Oct, 09:16 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
A multi-agentic python framework.
agnets is a modern, Python-first framework designed for building powerful AI agents and orchestrating them into collaborative, multi-agent systems—a "fleet." It provides a flexible, type-safe foundation for creating everything from simple automated assistants to complex, coordinated AI organizations that can delegate tasks and specialize.
Our vision is to empower developers to build sophisticated AI-powered applications by providing a framework that makes defining agents, their tools, and their inter-agent escalations intuitive and robust, allowing you to construct pseudo-organizations as collections of inference-powered Python objects.
Fleet class is the core of multi-agent coordination, managing agent interactions, escalations, and communication pathways.Agent class with integrated tool management, configuration, and lifecycle handling.agnets?agnets stands out by treating multi-agent systems as a first-class citizen:
agnets is built around the Fleet concept, making it natural to design organizations of AI agents.Install agnets with core dependencies:
pip install agnets
Or, using UV (recommended):
uv add agnets
To use with a specific backend, install the optional dependencies:
# For OpenAI-compatible backends
pip install "agnets[openai]"
# For Ollama
pip install "agnets[ollama]"
Before diving into fleets, let's set up a single agent.
import os
from agnets import Agent, Config
from agnets.backends.openai import OpenAICompatibleBackend
# os.environ["OPENAI_API_KEY"] = "your-api-key"
agent_config = Config(
model_name="gpt-4o-mini",
system_prompt="You are a helpful assistant."
)
backend = OpenAICompatibleBackend(config={"api_key": os.environ.get("OPENAI_API_KEY")})
agent = Agent(config=agent_config, backend=backend)
@agent.add_tool
def get_weather(location: str) -> str:
"""Gets the current weather for a given location."""
return f"The weather in {location} is sunny and 25°C."
response = agent.invoke("What's the weather in Paris?")
print(response.content)
# Expected output: The weather in Paris is sunny and 25°C.
This is where agnets truly shines. Let's create a small fleet of two agents: one for general queries and another specialized for calculations.
1. Define your Specialist Agents (e.g., Calculator Agent)
(This could be in a separate file like calculator.py)
# calculator_agent.py
from agnets import Agent, Config
from agnets.backends.ollama import OllamaBackend # Or any backend
calc_config = Config(
model_name="llama3.1:8b", # Or your preferred model
system_prompt="You are a calculator agent. Only perform calculations."
)
calc_backend = OllamaBackend()
calculator_agent = Agent(config=calc_config, backend=calc_backend)
@calculator_agent.add_tool
def add(a: int, b: int) -> int:
"""Adds two integers."""
return a + b
@calculator_agent.add_tool
def multiply(a: int, b: int) -> int:
"""Multiplies two integers."""
return a * b
2. Define your Main/Orchestrator Agent
# main_agent.py
from agnets import Agent, Config
from agnets.backends.openai import OpenAICompatibleBackend
main_config = Config(
model_name="gpt-4o-mini",
system_prompt="""
You are a helpful assistant. If the user asks for a calculation,
you MUST delegate it to the 'calculator_agent' using the available tools.
When ready to reply to the user, use the 'respond_to_user' tool.
"""
)
main_backend = OpenAICompatibleBackend(config={"api_key": os.environ.get("OPENAI_API_KEY")})
main_agent = Agent(config=main_config, backend=main_backend)
# This tool is for the main agent to communicate its final answer back to the user/fleet orchestrator
@main_agent.add_tool
def respond_to_user(message: str) -> str:
"""Use this tool to provide the final response to the user."""
return message
3. Assemble and Manage the Fleet
# fleet_setup.py
from agnets.fleet import Fleet
from calculator_agent import calculator_agent # Assuming saved as above
from main_agent import main_agent # Assuming saved as above
# Initialize the fleet
my_fleet = Fleet()
# Add agents to the fleet, defining escalation paths
# 'main_agent' is allowed to escalate to 'calculator_agent'
my_fleet.add_agent('main_agent', main_agent, allowed_escalation_agent_names=['calculator_agent'])
my_fleet.add_agent('calculator_agent', calculator_agent) # No escalations needed for this specialist
# Now, interact with the fleet through the main agent
if __name__ == "__main__":
user_input = "What is 15 times 32?"
# The prompt can be structured; the agent will use its tools to interact.
# The `stop_on` condition tells the fleet when the agent has finalized its response.
response_messages = my_fleet.invoke_agent(
"main_agent",
user_input,
stop_on=['respond_to_user']
)
# The final response from 'respond_to_user' will be in the last message's components
final_response_component = response_messages[-1].components[-1]
if hasattr(final_response_component, 'content') and hasattr(final_response_component.content, 'content'):
print(f"Final Answer: {final_response_component.content.content[0].text}")
else:
print("No clear final response found.")
# Expected Output:
# Final Answer: 15 times 32 is 480.
@agent.add_tool.allowed_escalation_agent_names). This dictates which other agents an agent is permitted to delegate tasks to or ask for help.The examples/ directory provides practical demonstrations:
calculator.py: A simple, single agent with basic math tools. Good for understanding individual agent setup.openai_example.py & ollama_example.py: Basic single-agent setups for specific backends.org_fleet_example.py: (Highly Recommended) A comprehensive example demonstrating how to build a mini-organization of agents. It shows how to set up a fleet, define escalation paths between agents (e.g., a generalist agent escalating to a specialist calculator agent), and manage interactions within the fleet. This example is the best illustration of the framework's multi-agent power.We strongly recommend reviewing org_fleet_example.py to grasp the full potential of the Fleet system.
For the most stable release, install from PyPI as shown in the Quick Start.
To install the latest development version from source:
git clone https://github.com/Sceptyre/agnets.git
cd agnets
pip install -e .
Or with UV:
git clone https://github.com/Sceptyre/agnets.git
cd agnets
uv pip install -e .
You can also install with specific backend dependencies from source:
pip install -e ".[openai,ollama]"
We welcome contributions! Please see our CONTRIBUTING.md for guidelines on how to get involved.
This project is licensed under the GPLv3 License. See LICENSE.md for details.
For questions, bug reports, or feature requests, please open an issue on our GitHub Issues page.
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.4.0 | 3 Oct 2025 | 6 |
This describes our collected data; it is not a security assessment.
Observed since 21 Oct, 09:16 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:75553b27ddc48e472dc163ec2e0304d79e284311cac499d899b71116685af7e2