π Quick Start GuideΒΆ
Welcome to Haive Agents! This guide will get you up and running with dynamic, self-modifying agents in minutes.
What is Haive Agents?ΒΆ
Haive Agents is the most advanced agent framework available today, providing:
π§ True Intelligence: Agents that reason, plan, and execute complex workflows π§ Self-Modification: Agents that adapt their behavior based on performance π€ Self-Replication: Agents that create specialized copies of themselves π₯ Multi-Agent Coordination: Seamless orchestration of agent teams π Advanced Memory: Graph-based memory with automatic knowledge extraction β‘ Real-Time Adaptation: Runtime reconfiguration without restarts
InstallationΒΆ
# Install the package
pip install haive-agents
# Or with poetry
poetry add haive-agents
# For development
git clone https://github.com/pr1m8/haive-agents
cd haive-agents
poetry install
First Agent in 30 SecondsΒΆ
Create your first intelligent agent:
from haive.agents import SimpleAgent
from haive.core.engine.aug_llm import AugLLMConfig
# Create an agent
agent = SimpleAgent(
name="assistant",
engine=AugLLMConfig(temperature=0.7)
)
# Chat with your agent
result = await agent.arun("What are the benefits of renewable energy?")
print(result)
Output:
Renewable energy offers numerous benefits including reduced greenhouse gas
emissions, energy independence, long-term cost savings, and sustainable
economic growth. Solar and wind power are now the cheapest forms of
electricity in many regions...
Tool-Powered Agent in 2 MinutesΒΆ
Create an agent that can use tools to solve problems:
from haive.agents import ReactAgent
from langchain_core.tools import tool
@tool
def calculator(expression: str) -> str:
"""Calculate mathematical expressions safely."""
try:
result = eval(expression.replace('^', '**'))
return f"Result: {result}"
except Exception as e:
return f"Error: {e}"
@tool
def web_search(query: str) -> str:
"""Search the web for current information."""
return f"Latest search results for: {query}"
# Create ReAct agent with tools
agent = ReactAgent(
name="research_assistant",
engine=AugLLMConfig(),
tools=[calculator, web_search]
)
# Agent reasons and uses tools
result = await agent.arun(
"What is 15^3 + 7^2 and find recent news about that number?"
)
The agent will:
Think: βI need to calculate 15^3 + 7^2 firstβ
Act: Use calculator tool β
calculator("15**3 + 7**2")
Observe: Result: 3424
Think: βNow I need to search for news about 3424β
Act: Use web search β
web_search("3424 news")
Respond: Provide comprehensive answer with calculation and search results
Multi-Agent Workflow in 3 MinutesΒΆ
Coordinate multiple agents for complex tasks:
from haive.agents import SimpleAgent, ReactAgent, MultiAgent
# Create specialized agents
researcher = ReactAgent(
name="researcher",
tools=[web_search, data_analyzer],
engine=AugLLMConfig(temperature=0.3) # Focused
)
writer = SimpleAgent(
name="writer",
engine=AugLLMConfig(temperature=0.8) # Creative
)
reviewer = SimpleAgent(
name="reviewer",
engine=AugLLMConfig(temperature=0.1) # Precise
)
# Create workflow
content_pipeline = MultiAgent(
name="content_team",
agents=[researcher, writer, reviewer],
execution_mode="sequential"
)
# Execute complex workflow
result = await content_pipeline.arun(
"Create a blog post about quantum computing trends"
)
Execution Flow:
Researcher β Gathers data, analyzes trends, creates research brief
Writer β Takes research brief, creates engaging blog post
Reviewer β Reviews post, suggests improvements, finalizes content
Self-Modifying Agent in 5 MinutesΒΆ
Create agents that improve themselves:
from haive.agents.agent import SelfModifyingAgent
from pydantic import BaseModel, Field
class PerformanceMetrics(BaseModel):
accuracy: float = Field(ge=0.0, le=1.0)
response_time: float
user_satisfaction: float = Field(ge=0.0, le=1.0)
class AdaptiveAgent(SelfModifyingAgent):
"""Agent that modifies itself based on performance."""
performance_threshold: float = 0.7
async def arun(self, input_data):
# Execute task
result = await super().arun(input_data)
# Analyze performance (in real implementation, use actual metrics)
metrics = self.analyze_performance(result)
# Self-modify if performance is poor
if metrics.accuracy < self.performance_threshold:
await self.modify_behavior({
"temperature": max(0.1, self.engine.temperature * 0.8),
"system_message": self.engine.system_message + "\nFocus on accuracy over creativity.",
"tools": self.tools + [fact_checker_tool] # Add verification tool
})
print(f"π§ Agent self-modified: Lower temperature, added fact-checker")
return result
def analyze_performance(self, result):
# Simplified - in practice, use real metrics
return PerformanceMetrics(
accuracy=0.6, # Below threshold
response_time=1.2,
user_satisfaction=0.8
)
# Create self-improving agent
adaptive_agent = AdaptiveAgent(
name="learning_assistant",
engine=AugLLMConfig(temperature=0.7)
)
# Agent improves itself after poor performance
result = await adaptive_agent.arun("Explain quantum entanglement")
Self-Replicating Agents in 6 MinutesΒΆ
Create agents that spawn specialized versions of themselves:
from haive.agents.agent import SelfReplicatingAgent
class TeamBuilderAgent(SelfReplicatingAgent):
"""Agent that creates specialized team members."""
async def handle_complex_project(self, project_description: str):
"""Analyze project and create specialized agents."""
# Analyze what specialists are needed
analysis = await self.arun(
f"Analyze this project and identify required specializations: {project_description}"
)
# Create specialist agents
specialists = []
if "data analysis" in analysis.lower():
data_analyst = await self.replicate({
"name": f"{self.name}_data_analyst",
"temperature": 0.2, # Precise for data work
"system_message": "You are an expert data analyst. Focus on accuracy and statistical rigor.",
"tools": [data_tools, visualization_tools]
})
specialists.append(data_analyst)
if "writing" in analysis.lower():
writer = await self.replicate({
"name": f"{self.name}_writer",
"temperature": 0.8, # Creative for writing
"system_message": "You are an expert technical writer. Create clear, engaging content.",
"tools": [research_tools, style_checker]
})
specialists.append(writer)
if "review" in analysis.lower():
reviewer = await self.replicate({
"name": f"{self.name}_reviewer",
"temperature": 0.1, # Conservative for review
"system_message": "You are a meticulous reviewer. Ensure quality and accuracy.",
"tools": [fact_checker, grammar_checker]
})
specialists.append(reviewer)
return specialists
# Create team builder
team_builder = TeamBuilderAgent(
name="project_manager",
engine=AugLLMConfig()
)
# Automatically create specialized team
specialists = await team_builder.handle_complex_project(
"Create a data-driven report on renewable energy adoption with visualizations"
)
print(f"Created {len(specialists)} specialists:")
for agent in specialists:
print(f" - {agent.name}: {agent.engine.system_message[:50]}...")
Dynamic Supervision in 7 MinutesΒΆ
Create supervisors that build and manage agent teams:
from haive.agents.agent import DynamicSupervisorAgent
# Create supervisor with agent-building capabilities
supervisor = DynamicSupervisorAgent(
name="ai_project_manager",
engine=AugLLMConfig(),
enable_agent_builder=True,
auto_team_optimization=True
)
# Supervisor analyzes task and creates appropriate team
result = await supervisor.arun({
"task": "Build a customer service chatbot",
"requirements": [
"Handle customer inquiries",
"Escalate complex issues",
"Generate satisfaction reports",
"Maintain conversation history"
],
"timeline": "2 weeks",
"budget": "medium"
})
What the supervisor does:
Analyzes the requirements and constraints
Designs optimal team structure
Creates specialized agents: -
ChatbotAgent
(customer interaction) -EscalationAgent
(complex issue routing) -AnalyticsAgent
(reporting and insights) -MemoryAgent
(conversation persistence)Coordinates the team execution
Monitors progress and optimizes performance
Delivers final solution with documentation
Advanced Memory System in 10 MinutesΒΆ
Create agents with sophisticated memory capabilities:
from haive.agents.memory_reorganized import SimpleMemoryAgent
from haive.agents.memory_reorganized.coordination import IntegratedMemorySystem
# Configure advanced memory system
memory_config = {
"mode": "INTEGRATED", # Graph + Vector + Temporal
"enable_classification": True, # 11 memory types
"enable_consolidation": True, # Long-term memory formation
"enable_importance_scoring": True, # Priority-based retention
"neo4j_config": {
"uri": "neo4j://localhost:7687",
"username": "neo4j",
"password": "password"
}
}
# Create memory-enhanced agent
memory_agent = SimpleMemoryAgent(
name="knowledge_assistant",
engine=AugLLMConfig(),
memory_config=memory_config
)
# Store complex information - automatic processing
await memory_agent.store_memory(
"Alice Johnson works as a Senior ML Engineer at TechCorp. She completed her PhD in AI at Stanford in 2019 and specializes in computer vision. She mentors junior engineers and leads the autonomous vehicle project."
)
# Memory system automatically:
# 1. Classifies as CONTEXTUAL + PROFESSIONAL + EPISODIC memory
# 2. Extracts entities: Alice Johnson, TechCorp, Stanford, AI, computer vision
# 3. Creates relationships: Alice works_at TechCorp, Alice studied_at Stanford
# 4. Assigns importance score based on detail richness
# 5. Stores in graph, vector, and temporal indices
# Query with intelligent retrieval
response = await memory_agent.arun(
"Who do we know that works on AI in the autonomous vehicle industry?"
)
# Memory system:
# 1. Vector search for "AI autonomous vehicle"
# 2. Graph traversal: AI β computer vision β Alice β autonomous vehicle project
# 3. Temporal weighting for recent vs. old memories
# 4. Importance scoring for relevance
# 5. Multi-factor ranking combines all signals
Output:
Based on my memory, Alice Johnson is highly relevant to your query. She's a Senior ML Engineer
at TechCorp who specializes in computer vision (a key AI technology for autonomous vehicles)
and currently leads the autonomous vehicle project. She has strong AI credentials with a PhD
from Stanford in 2019. Her combination of AI expertise and direct involvement in autonomous
vehicle development makes her an excellent contact for AI in the autonomous vehicle industry.
Graph RAG Retrieval ExampleΒΆ
from haive.agents.memory_reorganized.retrieval import GraphRAGRetriever
# Advanced retrieval with graph traversal
retriever = GraphRAGRetriever(
enable_graph_traversal=True,
max_depth=3, # Explore 3 levels of relationships
min_similarity=0.7,
max_results=10
)
# Query with relationship context
results = await retriever.retrieve_memories(
"What's the connection between machine learning and business outcomes?"
)
# System explores:
# ML β AI projects β business value β revenue impact
# ML β engineers β products β customer satisfaction
# ML β research β publications β industry reputation
print(f"Found {len(results.memories)} relevant memories")
print(f"Explored {results.graph_nodes_explored} graph nodes")
print(f"Discovered {len(results.relationship_paths)} relationship paths")
print(f"Total retrieval time: {results.total_time_ms:.1f}ms")
Next StepsΒΆ
Now that youβve seen the basics, explore advanced capabilities:
π Deep Dive Tutorials
Agent Types - Complete guide to all agent types
Memory Systems - Advanced memory and knowledge management
Dynamic Supervisor System - Building self-organizing agent teams
π― Advanced Examples
π§ API Reference
agents - Complete API documentation
βοΈ Configuration Guide - Configuration options and best practices
π§ Troubleshooting Guide - Common issues and solutions
π Production Deployment
π Production Deployment Guide - Scaling agents in production
monitoring - Performance monitoring and optimization
security - Security best practices for agent systems
Key Concepts to RememberΒΆ
- π‘ Dynamic Adaptation
Agents modify themselves at runtime based on performance and requirements
- π Self-Organization
Teams of agents coordinate and optimize themselves without manual intervention
- π§ Intelligent Memory
Graph-based memory systems with automatic knowledge extraction and relationship discovery
- β‘ Real-Time Flexibility
Add tools, change models, modify behavior - all without system restarts
- π― Task-Focused Design
Agents specialized for specific domains while maintaining general intelligence
Ready to Build?ΒΆ
You now have everything you need to build sophisticated AI agent systems. Start with simple agents, then progressively add:
Tools for real-world interaction
Multiple agents for complex workflows
Self-modification for adaptive behavior
Advanced memory for intelligent context
Dynamic supervision for autonomous team management
Happy building! π
Note
All examples use real LLM calls - no mocking. This ensures your agents work exactly the same in development and production. For testing, use focused test scenarios rather than mocked responses.
Tip
Start simple and add complexity gradually. The most powerful agent systems are often composed of simple, well-defined agents working together rather than single complex agents trying to do everything.