Welcome! This guide will help you get up and running with the Self-Evolving Agent Framework in just a few minutes.
# Clone the repository
git clone https://github.com/microsoft/agent-governance-toolkit.git
cd self-evaluating-agent-sample
# Install dependencies
pip install -r requirements.txt
# Or install as a package
pip install -e .# Copy the example environment file
cp .env.example .env
# Edit .env and add your OpenAI API key
OPENAI_API_KEY=your_api_key_here# Test basic functionality (no API key required)
python tests/test_agent.py
# Run a simple agent (requires API key)
python examples/example.pyself-evaluating-agent-sample/
├── src/ # Core framework modules
│ ├── agent.py # Main agent implementation
│ ├── observer.py # Asynchronous learning agent
│ ├── telemetry.py # Event tracking system
│ ├── polymorphic_output.py # Adaptive output rendering
│ ├── universal_signal_bus.py # Omni-channel input
│ ├── agent_brokerage.py # Agent marketplace
│ ├── orchestrator.py # Workflow management
│ ├── constraint_engine.py # Safety constraints
│ ├── evaluation_engineering.py # Test-driven development
│ ├── wisdom_curator.py # Human-in-the-loop review
│ ├── circuit_breaker.py # Automated rollout management
│ ├── intent_detection.py # Conversation intent analysis
│ ├── ghost_mode.py # Passive observation
│ ├── prioritization.py # Context prioritization
│ ├── model_upgrade.py # Model upgrade management
│ └── generative_ui_engine.py # Dynamic UI generation
│
├── tests/ # Comprehensive test suite
│ ├── test_agent.py
│ ├── test_telemetry.py
│ ├── test_polymorphic_output.py
│ └── ... # Tests for all modules
│
├── examples/ # Usage examples
│ ├── example.py # Basic usage
│ ├── sample_full_stack_agent.py # Comprehensive integration
│ ├── sample_monitoring_agent.py # Real-world monitoring
│ ├── example_polymorphic_output.py
│ ├── example_universal_signal_bus.py
│ └── ... # Examples for all features
│
├── docs/ # Documentation
│ ├── ARCHITECTURE.md
│ ├── POLYMORPHIC_OUTPUT.md
│ ├── UNIVERSAL_SIGNAL_BUS.md
│ └── ... # Detailed docs for each feature
│
├── README.md # Main documentation
├── requirements.txt # Python dependencies
└── setup.py # Package installation
The DoerAgent executes tasks quickly without learning overhead:
from src.agent import DoerAgent
# Initialize agent
agent = DoerAgent()
# Execute a task
result = agent.run("What is 10 + 20?")
print(result['response'])The ObserverAgent processes telemetry events to improve the wisdom database:
from src.observer import ObserverAgent
# Create observer
observer = ObserverAgent()
# Process events from telemetry stream
observer.process_events()Process input from any source (text, files, logs, audio):
from src.universal_signal_bus import UniversalSignalBus, create_signal_from_log
bus = UniversalSignalBus()
# Ingest a log stream
signal = create_signal_from_log(
level="ERROR",
message="Database connection failed",
service="user-api"
)
context = bus.ingest(signal)
print(f"Priority: {context.priority}")Generate output in the most appropriate format:
from src.polymorphic_output import PolymorphicOutputEngine, InputContext
engine = PolymorphicOutputEngine()
# Generate response based on context
response = engine.generate_response(
data={"metric": "CPU", "value": "95%"},
input_context=InputContext.MONITORING
)
print(f"Output type: {response.modality}") # dashboard_widgetfrom src.agent import DoerAgent
agent = DoerAgent()
# Simple Q&A
result = agent.run("What is the current time?")
print(result['response'])
# Calculations
result = agent.run("Calculate 15 * 24 + 100")
print(result['response'])from src.universal_signal_bus import create_signal_from_file_change
from src.agent import DoerAgent
agent = DoerAgent()
bus = UniversalSignalBus()
# Monitor file changes
signal = create_signal_from_file_change(
file_path="/src/auth.py",
change_type="modified",
content_before="password = 'admin'",
content_after="hashed = bcrypt.hash(password)"
)
context = bus.ingest(signal)
result = agent.run(context.query)from src.ghost_mode import GhostModeObserver
from src.universal_signal_bus import create_signal_from_log
def on_alert(observation):
print(f"🚨 Alert: {observation.observation}")
observer = GhostModeObserver(
confidence_threshold=0.7,
surfacing_callback=on_alert
)
observer.start_observing()
# Feed logs
signal = create_signal_from_log(
level="CRITICAL",
message="Service down",
service="api-gateway"
)
observer.observe_signal({"type": "log_stream", "data": signal})from src.agent_brokerage import AgentMarketplace, AgentBroker
# Create marketplace
marketplace = AgentMarketplace()
# Register agents (see example_agent_brokerage.py for details)
# ...
# Create broker
broker = AgentBroker(marketplace)
# Execute task with automatic agent selection
result = broker.execute_task(
task="Extract text from PDF",
selection_strategy="best_value",
user_constraints={"max_budget": 0.05}
)
print(f"Selected: {result['agent_name']}")
print(f"Cost: ${result['actual_cost']:.4f}")- Explore Examples: Check out the
examples/directory for comprehensive samples - Read Documentation: Visit
docs/for detailed feature documentation - Run Tests: Execute tests to understand how each module works
- Build Your Agent: Start with a simple use case and expand
-
Full Stack Agent (
examples/sample_full_stack_agent.py)- Demonstrates integration of multiple modules
- Shows real-world usage patterns
-
Monitoring Agent (
examples/sample_monitoring_agent.py)- Real-world system monitoring
- Ghost Mode passive observation
- Dashboard widget rendering
-
Polymorphic Output (
examples/example_polymorphic_output.py)- Adaptive output rendering
- Context-aware UI generation
-
Universal Signal Bus (
examples/example_universal_signal_bus.py)- Omni-channel input processing
- Signal normalization
# Run all tests
python tests/test_agent.py
python tests/test_telemetry.py
python tests/test_polymorphic_output.py
python tests/test_universal_signal_bus.py
# ... and so on
# Run a specific test
python tests/test_agent.pyKey environment variables (in .env):
# Required
OPENAI_API_KEY=your_api_key_here
# Optional - Model Configuration
AGENT_MODEL=gpt-4o-mini
REFLECTION_MODEL=gpt-4o-mini
EVOLUTION_MODEL=gpt-4o-mini
# Optional - Performance
SCORE_THRESHOLD=0.8
MAX_RETRIES=3-
Import Errors
- Make sure you're running from the project root
- Ensure all dependencies are installed:
pip install -r requirements.txt
-
API Key Errors
- Check that
.envfile exists and containsOPENAI_API_KEY - Verify the API key is valid
- Check that
-
File Not Found
- Some examples create files like
system_instructions.jsonon first run - These are expected and will be created automatically
- Some examples create files like
- Documentation: Check the
docs/directory for detailed guides - Examples: Review
examples/for usage patterns - Issues: Report bugs on GitHub Issues
- Tests: Look at
tests/to understand expected behavior
Now that you're set up, you can:
- Build a Custom Agent: Extend DoerAgent with your own tools and logic
- Integrate with Your System: Use Universal Signal Bus to accept input from your application
- Add Safety Constraints: Use Constraint Engineering to add safety guardrails
- Deploy to Production: Use Circuit Breaker for automated rollout management
- Enable Learning: Use Observer for continuous improvement
Happy building! 🚀