A recipe for building multi-agent systems using Llama models, with context layers, agent discovery, and safety wrappers.
A 3-agent pipeline where:
- Researcher analyzes a topic and produces structured findings
- Builder creates a solution based on research
- Reviewer evaluates the solution against quality criteria
Each agent has a persistent identity, discovers others via capability cards, and every LLM call is wrapped with safety guards.
| Concept | What | Why |
|---|---|---|
| Context Layers | Agents have identity (static) + state (dynamic) + knowledge (searchable) | Consistent behavior across sessions |
| Agent Cards | JSON capability descriptors per agent | Agents find each other without hardcoding |
| Safety Guard | Output validation, cost caps, rollback | Production-grade reliability |
| Phase Gates | Research → Build → Review with quality checks | Prevent garbage from propagating |
pip install -r requirements.txt
# Set your Llama API endpoint (or use ollama)
export LLAMA_BASE_URL=http://localhost:11434/v1
export LLAMA_MODEL=llama3.2
python orchestrator.py "Build a CLI tool that converts CSV to JSON"| File | What |
|---|---|
context_layers.py |
4-layer context system (identity → state → relevant → archive) |
agent_cards.py |
Agent capability discovery and routing |
safety_guard.py |
Output validation, cost tracking, rollback |
orchestrator.py |
3-agent pipeline with phase gates |
requirements.txt |
Dependencies |
User provides task
↓
Orchestrator reads agent cards → finds Researcher
↓
Researcher (context: identity + task) → structured findings
↓ [safety guard: validate JSON output]
Orchestrator finds Builder
↓
Builder (context: identity + research findings) → solution
↓ [safety guard: validate + cost check]
Orchestrator finds Reviewer
↓
Reviewer (context: identity + solution + criteria) → evaluation
↓ [phase gate: score > 7/10 to pass]
Output: solution + evaluation report
Built by PA·co — A Penguin Alley System.