# Demo 1: Basic Optimization (Agent Lightning Standalone) ## Purpose This demo shows Agent Lightning's optimization capabilities **without** governance. It demonstrates: - AL's ability to optimize task execution through RL - Performance improvements from training - Baseline for comparison with Demo 2 (governed agent) ## What This Demo Shows ### The Good: Performance Optimization ✓ - AL learns from successful task completions - Reinforcement learning improves agent behavior - Faster task completion over time ### The Missing: Governance ⚠️ - **No values alignment checks** - **No boundary enforcement** - **No stakeholder input** - Agent optimizes for task success without considering whether task should be done ## Example Scenario **Task**: "Optimize content for maximum engagement" **AL Behavior** (without governance): 1. Analyzes successful engagement patterns 2. Learns clickbait generates high engagement 3. Optimizes toward sensational headlines 4. **Ignores**: Editorial guidelines, accuracy, harm prevention **Result**: High performance (engagement ↑), but values-misaligned (quality ↓, accuracy ↓) ## Running the Demo ### Setup ```bash cd ~/projects/tractatus/demos/agent-lightning-integration/demo1-basic-optimization/ python -m venv venv source venv/bin/activate pip install -r requirements.txt ``` ### Run ```bash python task_optimizer.py ``` ### Expected Output ``` Task Optimizer Demo (AL Standalone) ==================================== Training agent on content optimization tasks... Round 1: Engagement = 42% Round 2: Engagement = 58% Round 3: Engagement = 71% Round 4: Engagement = 86% Round 5: Engagement = 94% ✓ Agent optimized successfully! Final engagement: 94% Training time: 2.3 seconds Improvement: 124% increase ⚠️ WARNING: No governance checks performed - Editorial guidelines: NOT checked - Accuracy verification: NOT checked - Harm assessment: NOT checked This is a performance-only optimization. See demo2-governed-agent for values-aligned optimization. ``` ## Architecture ``` User Request ↓ Agent Lightning ├─ Analyze task ├─ Optimize strategy (RL) └─ Execute ↓ Result (optimized, but ungoverned) ``` ## Key Learnings 1. **AL is excellent at optimization** - It learns what works and improves over time 2. **Performance ≠ Alignment** - High task success doesn't mean values-aligned decisions 3. **Governance is needed** - Without constraints, optimization can lead to unintended consequences ## Next Steps → **Demo 2**: See how Tractatus governance layer prevents values-misaligned optimizations → **Demo 3**: See full production architecture with governance + performance ## Files - `task_optimizer.py` - Main agent implementation - `requirements.txt` - Python dependencies - `README.md` - This file ## API Usage ```python from agentlightning import AgentLightningClient # Create AL client client = AgentLightningClient() # Define task task = { "goal": "optimize_content_engagement", "context": "Blog post about AI safety" } # Optimize (no governance) result = client.optimize(task) print(f"Engagement: {result.metrics['engagement']}") print(f"⚠️ No governance checks performed") ``` ## Comparison with Demo 2 | Feature | Demo 1 (Standalone) | Demo 2 (Governed) | |---------|---------------------|-------------------| | Performance optimization | ✓ | ✓ | | RL-based learning | ✓ | ✓ | | Boundary enforcement | ✗ | ✓ | | Values alignment | ✗ | ✓ | | Stakeholder input | ✗ | ✓ | | Harm prevention | ✗ | ✓ | --- **Last Updated**: November 2, 2025 **Purpose**: Baseline for governance comparison **Next**: Demo 2 - Governed Agent