README: complete rewrite with visual architecture, animations, feature map, usage guide
Browse files
README.md
CHANGED
|
@@ -1,143 +1,426 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
<div align="center">
|
| 2 |
-
<img src="assets/hero_animation.svg" alt="Purpose Agent Hero" width="100%">
|
| 3 |
-
</div>
|
| 4 |
|
| 5 |
-
# Purpose Agent
|
| 6 |
|
| 7 |
-
|
| 8 |
|
| 9 |
-
|
| 10 |
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
pip install purpose-agent
|
| 13 |
```
|
| 14 |
|
| 15 |
-
|
| 16 |
|
| 17 |
-
|
| 18 |
-
> Purpose Agent v3.0 hardens the kernel for production use, focusing on security, token efficiency, and absolute execution reliability.
|
| 19 |
|
| 20 |
-
|
| 21 |
-
- **O(1) Markovian Critic**: The new `delta` stateβevaluator saves tokens by evaluating *only what changed* instead of the full environment state.
|
| 22 |
-
- **Popperian Falsification**: Mathematical, zeroβhallucination code scoring where assertions evaluate code correctness automatically.
|
| 23 |
-
- **PEPβ―578 Sandboxing**: Secure, isolated execution for the Python environment.
|
| 24 |
|
| 25 |
-
|
| 26 |
|
| 27 |
-
|
| 28 |
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
-
|
| 32 |
|
| 33 |
-
|
| 34 |
|
| 35 |
-
|
| 36 |
-
graph LR
|
| 37 |
-
A[pa.purpose] --> B(AutoβTeam Assembly)
|
| 38 |
-
B --> C{Execution Loop}
|
| 39 |
-
C -->|Success| D[Heuristics Extracted]
|
| 40 |
-
C -->|Fail| E[Feedback Provided]
|
| 41 |
-
D --> F[Smarter Next Run]
|
| 42 |
-
```
|
| 43 |
|
| 44 |
```python
|
| 45 |
import purpose_agent as pa
|
| 46 |
|
| 47 |
-
team = pa.purpose("
|
| 48 |
-
result = team.run("Write a
|
| 49 |
-
team.teach("Always handle edge cases") # Injects into procedural memory
|
| 50 |
-
print(team.status())
|
| 51 |
```
|
| 52 |
|
| 53 |
-
|
|
|
|
|
|
|
| 54 |
|
| 55 |
-
|
| 56 |
|
| 57 |
-
```mermaid
|
| 58 |
-
graph TD
|
| 59 |
-
A[Your Application] --> B(purpose_agent)
|
| 60 |
-
B --> C[Ollama local]
|
| 61 |
-
B --> D[OpenRouter / Cloud]
|
| 62 |
-
B --> E[HuggingFace Hub]
|
| 63 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
```python
|
| 66 |
-
|
| 67 |
-
team = pa.purpose("Code helper", model="qwen3:1.7b")
|
| 68 |
|
| 69 |
-
#
|
| 70 |
-
team = pa.purpose("
|
| 71 |
-
team = pa.purpose("
|
| 72 |
-
team = pa.purpose("
|
|
|
|
| 73 |
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
```
|
| 78 |
|
| 79 |
-
###
|
| 80 |
|
| 81 |
-
|
|
|
|
| 82 |
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
```
|
| 91 |
|
|
|
|
|
|
|
| 92 |
```python
|
| 93 |
import purpose_agent as pa
|
| 94 |
|
| 95 |
-
# ββ Spark:
|
| 96 |
-
spark = pa.Spark("coder", model="
|
| 97 |
-
result = spark.run("Write
|
| 98 |
|
| 99 |
-
# ββ Flow: workflow
|
| 100 |
flow = pa.Flow()
|
| 101 |
-
flow.add_node("research", pa.Spark("researcher"
|
| 102 |
-
flow.add_node("write", pa.Spark("writer"
|
| 103 |
flow.add_edge(pa.BEGIN, "research")
|
| 104 |
-
flow.
|
| 105 |
-
|
| 106 |
-
result = flow.run(initial_state)
|
| 107 |
|
| 108 |
-
# ββ
|
| 109 |
-
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
```
|
| 112 |
|
| 113 |
---
|
| 114 |
|
| 115 |
-
## π‘οΈ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
|
| 117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
```
|
| 127 |
|
| 128 |
-
-
|
| 129 |
-
|
| 130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
|
| 132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
|
| 134 |
```bash
|
| 135 |
pip install purpose-agent # Core (zero dependencies)
|
| 136 |
-
pip install purpose-agent[openai] # + OpenAI
|
| 137 |
pip install purpose-agent[ollama] # + Local Ollama
|
| 138 |
-
pip install purpose-agent[all]
|
| 139 |
```
|
| 140 |
|
| 141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
|
| 143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: purpose-agent
|
| 3 |
+
license: mit
|
| 4 |
+
language:
|
| 5 |
+
- en
|
| 6 |
+
tags:
|
| 7 |
+
- agents
|
| 8 |
+
- self-improving
|
| 9 |
+
- multi-agent
|
| 10 |
+
- memory-system
|
| 11 |
+
- local-first
|
| 12 |
+
- slm
|
| 13 |
+
- safety
|
| 14 |
+
- event-driven
|
| 15 |
+
- rag
|
| 16 |
+
- tools
|
| 17 |
+
pipeline_tag: text-generation
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
<div align="center">
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
# π§ Purpose Agent
|
| 23 |
|
| 24 |
+
### The framework where AI agents actually learn from experience.
|
| 25 |
|
| 26 |
+
**Local-first Β· Self-improving Β· Domain-agnostic Β· Production-hardened**
|
| 27 |
|
| 28 |
+
[](https://pypi.org/project/purpose-agent/)
|
| 29 |
+
[](https://pypi.org/project/purpose-agent/)
|
| 30 |
+
[](LICENSE)
|
| 31 |
+
[]()
|
| 32 |
+
[]()
|
| 33 |
+
|
| 34 |
+
---
|
| 35 |
+
|
| 36 |
+
```
|
| 37 |
pip install purpose-agent
|
| 38 |
```
|
| 39 |
|
| 40 |
+
</div>
|
| 41 |
|
| 42 |
+
---
|
|
|
|
| 43 |
|
| 44 |
+
## π― What Problem Does This Solve?
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
+
Every other agent framework (LangChain, CrewAI, AutoGen) runs **the same way every time**. Your agent fails at a task? Next time, it fails the exact same way. No learning. No memory. No improvement.
|
| 47 |
|
| 48 |
+
**Purpose Agent is different.** After every task:
|
| 49 |
|
| 50 |
+
```
|
| 51 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 52 |
+
β β
|
| 53 |
+
β Task β Execute β Score β Extract Lessons β Remember β
|
| 54 |
+
β β β β
|
| 55 |
+
β ββββββ Next task uses lessons βββββββββββββββ β
|
| 56 |
+
β β
|
| 57 |
+
β Run 1: Agent struggles ββββββββ Ξ¦ = 3.0 β
|
| 58 |
+
β Run 2: Uses learned heuristics β Ξ¦ = 7.0 β
|
| 59 |
+
β Run 3: Refined further ββββββββ Ξ¦ = 9.5 β
|
| 60 |
+
β β
|
| 61 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 62 |
+
```
|
| 63 |
|
| 64 |
+
**No fine-tuning. No GPU training. Just memory + experience.**
|
| 65 |
|
| 66 |
+
---
|
| 67 |
|
| 68 |
+
## β‘ 3-Line Quickstart
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
```python
|
| 71 |
import purpose_agent as pa
|
| 72 |
|
| 73 |
+
team = pa.purpose("Help me write Python code")
|
| 74 |
+
result = team.run("Write a fibonacci function")
|
|
|
|
|
|
|
| 75 |
```
|
| 76 |
|
| 77 |
+
That's it. The framework auto-detects your model, builds the right team, executes the task, scores the result, and stores lessons for next time.
|
| 78 |
+
|
| 79 |
+
---
|
| 80 |
|
| 81 |
+
## ποΈ Architecture at a Glance
|
| 82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
```
|
| 84 |
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 85 |
+
β PURPOSE AGENT v3.0 β
|
| 86 |
+
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ£
|
| 87 |
+
β β
|
| 88 |
+
β ββββββββββββ βββββββββββββββ ββββββββββββββββββββ β
|
| 89 |
+
β β YOU βββββΆβ EASY API βββββΆβ ORCHESTRATOR β β
|
| 90 |
+
β β (purpose) β β (auto-team) β β (step loop) β β
|
| 91 |
+
β ββββββββββββ βββββββββββββββ ββββββββββ¬ββββββββββ β
|
| 92 |
+
β β β
|
| 93 |
+
β ββββββββββββββββββββββββββββββββββΌβββββββββββ β
|
| 94 |
+
β β βΌ β β
|
| 95 |
+
β β ββββββββββββ ββββββββββββββββββββ β β
|
| 96 |
+
β β β ACTOR βββββΆβ ENVIRONMENT β β β
|
| 97 |
+
β β β (decide) β β (execute) β β β
|
| 98 |
+
β β ββββββββββββ ββββββββββ¬ββββββββββ β β
|
| 99 |
+
β β β β β
|
| 100 |
+
β β βββββββββββββββββββββΌββββββ β β
|
| 101 |
+
β β β PURPOSE FUNCTION (Ξ¦) β β β
|
| 102 |
+
β β β Score: 0 ββββββββ 10 β β β
|
| 103 |
+
β β β O(1) state-delta mode β β β
|
| 104 |
+
β β βββββββββββββββββββββ¬ββββββ β β
|
| 105 |
+
β β β β β
|
| 106 |
+
β β ββββββββββββββββββββββββββΌββββββββββ β β
|
| 107 |
+
β β β MEMORY (immune-scanned) β β β
|
| 108 |
+
β β β 7 types Β· 5 statuses Β· scoped β β β
|
| 109 |
+
β β β quarantine β test β promote β β β
|
| 110 |
+
β β ββββββββββββββββββββββββββββββββββββ β β
|
| 111 |
+
β β β β
|
| 112 |
+
β βββββ SELF-IMPROVEMENT LOOP ββββββββββββββββ β
|
| 113 |
+
β β
|
| 114 |
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 115 |
+
```
|
| 116 |
+
|
| 117 |
+
---
|
| 118 |
+
|
| 119 |
+
## π¨ Three Ways to Use It
|
| 120 |
+
|
| 121 |
+
### π’ Level 1 β Just Describe What You Want
|
| 122 |
|
| 123 |
```python
|
| 124 |
+
import purpose_agent as pa
|
|
|
|
| 125 |
|
| 126 |
+
# Auto-detects the right team composition
|
| 127 |
+
team = pa.purpose("Write Python code and test it") # β architect + coder + tester
|
| 128 |
+
team = pa.purpose("Research quantum computing") # β researcher + analyst
|
| 129 |
+
team = pa.purpose("Analyze sales data") # β analyst + reporter
|
| 130 |
+
team = pa.purpose("Write a blog post") # β writer + editor
|
| 131 |
|
| 132 |
+
result = team.run("Create a sorting algorithm")
|
| 133 |
+
team.teach("Always handle edge cases") # Inject knowledge directly
|
| 134 |
+
print(team.status()) # See what it's learned
|
| 135 |
```
|
| 136 |
|
| 137 |
+
### π‘ Level 2 β Choose Your Model & Add Knowledge
|
| 138 |
|
| 139 |
+
```python
|
| 140 |
+
import purpose_agent as pa
|
| 141 |
|
| 142 |
+
# 10+ providers supported
|
| 143 |
+
team = pa.purpose("Code helper", model="ollama:qwen3:1.7b") # Local, free
|
| 144 |
+
team = pa.purpose("Code helper", model="openrouter:meta-llama/llama-3.3-70b-instruct")
|
| 145 |
+
team = pa.purpose("Code helper", model="groq:llama-3.3-70b-versatile")
|
| 146 |
+
team = pa.purpose("Code helper", model="openai:gpt-4o")
|
| 147 |
+
|
| 148 |
+
# Add your own documents as knowledge
|
| 149 |
+
team = pa.purpose("Answer questions about our product",
|
| 150 |
+
knowledge="./docs/", # Load entire folder
|
| 151 |
+
model="qwen3:1.7b",
|
| 152 |
+
)
|
| 153 |
+
answer = team.ask("What's our refund policy?")
|
| 154 |
```
|
| 155 |
|
| 156 |
+
### π΄ Level 3 β Full Control
|
| 157 |
+
|
| 158 |
```python
|
| 159 |
import purpose_agent as pa
|
| 160 |
|
| 161 |
+
# ββ Spark: single intelligent agent ββ
|
| 162 |
+
spark = pa.Spark("coder", model="ollama:qwen3:1.7b", tools=[pa.PythonExecTool()])
|
| 163 |
+
result = spark.run("Write fibonacci")
|
| 164 |
|
| 165 |
+
# ββ Flow: workflow with conditional routing ββ
|
| 166 |
flow = pa.Flow()
|
| 167 |
+
flow.add_node("research", pa.Spark("researcher"))
|
| 168 |
+
flow.add_node("write", pa.Spark("writer"))
|
| 169 |
flow.add_edge(pa.BEGIN, "research")
|
| 170 |
+
flow.add_conditional_edge("write", check_fn, {"pass": pa.DONE_SIGNAL, "revise": "research"})
|
| 171 |
+
result = flow.run(state)
|
|
|
|
| 172 |
|
| 173 |
+
# ββ swarm: parallel execution ββ
|
| 174 |
+
results = pa.swarm(["task_a", "task_b", "task_c"], agents=[a1, a2, a3])
|
| 175 |
+
|
| 176 |
+
# ββ Council: multi-agent deliberation ββ
|
| 177 |
+
council = pa.Council([pa.Spark("alice"), pa.Spark("bob"), pa.Spark("carol")])
|
| 178 |
+
result = council.run("Should we use microservices?", rounds=3)
|
| 179 |
+
|
| 180 |
+
# ββ Vault: knowledge RAG ββ
|
| 181 |
+
vault = pa.Vault.from_directory("./research_papers/")
|
| 182 |
+
agent = pa.Spark("analyst", tools=[vault.as_tool()])
|
| 183 |
+
|
| 184 |
+
# ββ Generate entire systems ββ
|
| 185 |
+
from purpose_agent.mas_generator import generate
|
| 186 |
+
system = generate("Monitor GitHub repos for CVEs and alert the team")
|
| 187 |
+
# β 4 agents + workflow + tools + eval suite + routing policy
|
| 188 |
```
|
| 189 |
|
| 190 |
---
|
| 191 |
|
| 192 |
+
## π‘οΈ Safety & Security
|
| 193 |
+
|
| 194 |
+
```
|
| 195 |
+
βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 196 |
+
β MEMORY IMMUNE SYSTEM β
|
| 197 |
+
β β
|
| 198 |
+
β candidate βββ immune scan βββ quarantine β
|
| 199 |
+
β β β β
|
| 200 |
+
β βββββββΌββββββ ββββββΌβββββ β
|
| 201 |
+
β β REJECTED β β TEST β β
|
| 202 |
+
β β (5 scans) β β (replay)β β
|
| 203 |
+
β ββββββββββββββ ββββββ¬βββββ β
|
| 204 |
+
β β β
|
| 205 |
+
β βββββββΌββββββ β
|
| 206 |
+
β β PROMOTED β β
|
| 207 |
+
β β (active) β β
|
| 208 |
+
β βββββββββββββ β
|
| 209 |
+
βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 210 |
+
```
|
| 211 |
+
|
| 212 |
+
**5 threat scanners:** prompt injection, score manipulation, tool misuse, privacy leaks, scope overreach
|
| 213 |
+
|
| 214 |
+
**PEP 578 kernel sandbox:** Unbypassable audit hooks at the C-interpreter level. No Docker needed.
|
| 215 |
+
|
| 216 |
+
**Falsification critic:** Code is scored by CPU-executed assertions, not LLM hallucinations.
|
| 217 |
+
|
| 218 |
+
---
|
| 219 |
+
|
| 220 |
+
## π¬ First-Principles Engineering
|
| 221 |
+
|
| 222 |
+
| Problem | Old Approach | Purpose Agent |
|
| 223 |
+
|---------|-------------|---------------|
|
| 224 |
+
| Token cost grows O(NΒ²) | Pass full history to critic | **O(1) state-delta** β only pass what changed |
|
| 225 |
+
| SLMs hallucinate scores | "Rate this 0-10" β guess | **Falsification** β generate asserts, CPU executes, score = math |
|
| 226 |
+
| Sandbox bypassed via dynamic code | AST analysis (weak) | **PEP 578 audit hooks** β kernel-level, unbypassable |
|
| 227 |
+
| Heuristics overflow context | Inject all 200 heuristics | **MoH cap K=10** β only top heuristics by Q-value |
|
| 228 |
+
| UNKNOWN action crashes | Parse failure β crash | **Safe fallback to DONE** β never propagates garbage |
|
| 229 |
+
|
| 230 |
+
---
|
| 231 |
+
|
| 232 |
+
## π¦ What's Inside (45+ modules)
|
| 233 |
+
|
| 234 |
+
<details>
|
| 235 |
+
<summary><b>π§ Core Engine</b></summary>
|
| 236 |
+
|
| 237 |
+
| Module | What |
|
| 238 |
+
|--------|------|
|
| 239 |
+
| `orchestrator.py` | Main step loop with 3 critic modes (standard/delta/falsification) |
|
| 240 |
+
| `actor.py` | ReAct agent with 3-tier memory + heuristic cap |
|
| 241 |
+
| `purpose_function.py` | Ξ¦(s) scorer with 7 anti-gaming rules |
|
| 242 |
+
| `experience_replay.py` | Thread-safe trajectory storage with Q-value retrieval |
|
| 243 |
+
| `optimizer.py` | Trajectory οΏ½οΏ½οΏ½ heuristic distillation |
|
| 244 |
+
|
| 245 |
+
</details>
|
| 246 |
+
|
| 247 |
+
<details>
|
| 248 |
+
<summary><b>𧬠Self-Improvement</b></summary>
|
| 249 |
|
| 250 |
+
| Module | What |
|
| 251 |
+
|--------|------|
|
| 252 |
+
| `memory.py` | 7 memory kinds Γ 5 statuses, scoped, versioned |
|
| 253 |
+
| `memory_ci.py` | Quarantine β immune scan β test β promote/reject |
|
| 254 |
+
| `memory_homeostasis.py` | Budget enforcement, consolidation, archive |
|
| 255 |
+
| `immune.py` | 5 threat scanners for memory safety |
|
| 256 |
+
| `breakthroughs.py` | Self-improving critic, MoH, hindsight relabeling, evolution |
|
| 257 |
|
| 258 |
+
</details>
|
| 259 |
+
|
| 260 |
+
<details>
|
| 261 |
+
<summary><b>β‘ First-Principles</b></summary>
|
| 262 |
+
|
| 263 |
+
| Module | What |
|
| 264 |
+
|--------|------|
|
| 265 |
+
| `state_delta.py` | O(1) Markovian state-diff for critic |
|
| 266 |
+
| `falsification_critic.py` | Popperian scoring via adversarial assertions |
|
| 267 |
+
| `sandbox_hooks.py` | PEP 578 kernel-level audit hooks |
|
| 268 |
+
| `hardening.py` | Null safety, timeouts, validation, graceful degradation |
|
| 269 |
+
| `sre_patches.py` | 5 auto-applied critical vulnerability fixes |
|
| 270 |
+
|
| 271 |
+
</details>
|
| 272 |
+
|
| 273 |
+
<details>
|
| 274 |
+
<summary><b>π Protocols & Interop</b></summary>
|
| 275 |
+
|
| 276 |
+
| Module | What |
|
| 277 |
+
|--------|------|
|
| 278 |
+
| `protocols/mcp_bridge.py` | MCP tool server integration |
|
| 279 |
+
| `protocols/a2a.py` | Agent-to-Agent delegation with circuit breaker |
|
| 280 |
+
| `protocols/agui.py` | AG-UI frontend streaming |
|
| 281 |
+
| `protocols/agents_md.py` | AGENTS.md repo-local instructions |
|
| 282 |
+
| `quorum.py` | Consensus/disagreement topology switching |
|
| 283 |
+
|
| 284 |
+
</details>
|
| 285 |
+
|
| 286 |
+
<details>
|
| 287 |
+
<summary><b>π§ Intelligence</b></summary>
|
| 288 |
+
|
| 289 |
+
| Module | What |
|
| 290 |
+
|--------|------|
|
| 291 |
+
| `routing.py` | Smart model selection (local-first, cost-aware) |
|
| 292 |
+
| `mas_generator.py` | Use-case β complete multi-agent system |
|
| 293 |
+
| `skills/schema.py` | Versioned, evolvable, testable skill cards |
|
| 294 |
+
| `skills/ci.py` | Skill testing + rollback + Darwinian selection |
|
| 295 |
+
| `llm_compiler.py` | Parallel tool execution via DAG planning |
|
| 296 |
+
|
| 297 |
+
</details>
|
| 298 |
+
|
| 299 |
+
<details>
|
| 300 |
+
<summary><b>π Optimization</b></summary>
|
| 301 |
+
|
| 302 |
+
| Module | What |
|
| 303 |
+
|--------|------|
|
| 304 |
+
| `optimization/fingerprint.py` | Capability profiling from traces |
|
| 305 |
+
| `optimization/dataset.py` | Trace β filtered training dataset |
|
| 306 |
+
| `optimization/prompt_pack.py` | Epigenetic prompt optimization |
|
| 307 |
+
| `optimization/shadow_eval.py` | Candidate vs baseline comparison |
|
| 308 |
+
| `optimization/optimizer.py` | Improving/plateau/degrading policy |
|
| 309 |
+
| `optimization/lora_plan.py` | LoRA/distillation dry-run planning |
|
| 310 |
+
|
| 311 |
+
</details>
|
| 312 |
+
|
| 313 |
+
<details>
|
| 314 |
+
<summary><b>ποΈ Runtime</b></summary>
|
| 315 |
+
|
| 316 |
+
| Module | What |
|
| 317 |
+
|--------|------|
|
| 318 |
+
| `runtime/events.py` | 30 canonical event types |
|
| 319 |
+
| `runtime/event_bus.py` | Async pub/sub with backpressure |
|
| 320 |
+
| `runtime/state.py` | Typed execution state for checkpointing |
|
| 321 |
+
| `runtime/checkpoint.py` | InMemory/JSONL/SQLite durability |
|
| 322 |
+
| `streaming_v3.py` | AG-UI compatible stream adapters |
|
| 323 |
+
|
| 324 |
+
</details>
|
| 325 |
+
|
| 326 |
+
---
|
| 327 |
+
|
| 328 |
+
## π Supported Providers
|
| 329 |
+
|
| 330 |
+
```python
|
| 331 |
+
from purpose_agent import resolve_backend
|
| 332 |
+
|
| 333 |
+
resolve_backend("ollama:qwen3:1.7b") # Local (free)
|
| 334 |
+
resolve_backend("openrouter:meta-llama/llama-3.3-70b-instruct")
|
| 335 |
+
resolve_backend("groq:llama-3.3-70b-versatile")
|
| 336 |
+
resolve_backend("openai:gpt-4o")
|
| 337 |
+
resolve_backend("together:meta-llama/Llama-3.3-70B-Instruct-Turbo")
|
| 338 |
+
resolve_backend("fireworks:accounts/fireworks/models/llama-v3p1-70b")
|
| 339 |
+
resolve_backend("cerebras:llama-3.3-70b")
|
| 340 |
+
resolve_backend("deepseek:deepseek-chat")
|
| 341 |
+
resolve_backend("mistral:mistral-large-latest")
|
| 342 |
+
resolve_backend("hf:Qwen/Qwen3-32B")
|
| 343 |
```
|
| 344 |
|
| 345 |
+
---
|
| 346 |
+
|
| 347 |
+
## π Real-World Test Results
|
| 348 |
+
|
| 349 |
+
Tested with **Llama-3.3-70B** and **Gemma-4-26B** via OpenRouter:
|
| 350 |
+
|
| 351 |
+
| Test | Llama-70B | Gemma-26B |
|
| 352 |
+
|------|:---------:|:---------:|
|
| 353 |
+
| fibonacci (4 unit tests) | β
100% | β
100% |
|
| 354 |
+
| fizzbuzz (4 unit tests) | β
100% | β
100% |
|
| 355 |
+
| factorial (3 unit tests) | β
100% | β
100% |
|
| 356 |
+
| Self-improvement (heuristic growth) | 0β18 | 0β11 |
|
| 357 |
+
| Immune system (adversarial) | 93% catch | β |
|
| 358 |
+
| Production test (19 checks) | 19/19 β
| β |
|
| 359 |
+
|
| 360 |
+
**250+ automated tests. Zero failures required for release.**
|
| 361 |
|
| 362 |
+
---
|
| 363 |
+
|
| 364 |
+
## π Research Foundation
|
| 365 |
+
|
| 366 |
+
Built on **13 published papers**. Every module traces back to a specific result.
|
| 367 |
+
|
| 368 |
+
| Paper | Module | Contribution |
|
| 369 |
+
|-------|--------|-------------|
|
| 370 |
+
| Ng et al. 1999 (PBRS) | purpose_function | Ξ¦ preserves optimal policy |
|
| 371 |
+
| MUSE (2510.08002) | actor, optimizer | 3-tier memory hierarchy |
|
| 372 |
+
| REMEMBERER (2306.07929) | experience_replay | Q-value retrieval |
|
| 373 |
+
| Reflexion (2303.11366) | orchestrator | Verbal reinforcement |
|
| 374 |
+
| SPC (2504.19162) | immune | Anti-reward-hacking |
|
| 375 |
+
| Meta-Rewarding (2407.19594) | meta_rewarding | Self-improving critic |
|
| 376 |
+
| DSPy (2310.03714) | prompt_optimizer | Automatic few-shot bootstrap |
|
| 377 |
+
| LLMCompiler (2312.04511) | llm_compiler | Parallel tool DAG |
|
| 378 |
+
| Retroformer (2308.02151) | retroformer | Structured reflection |
|
| 379 |
+
| TinyAgent (2409.00608) | slm_backends | SLM-native patterns |
|
| 380 |
+
| DeepSeek MoE (2401.06066) | breakthroughs | MoH sparse selection |
|
| 381 |
+
| HER (1707.01495) | breakthroughs | Hindsight relabeling |
|
| 382 |
+
| Self-Taught Eval (2408.02666) | self_taught | Synthetic critic training |
|
| 383 |
+
|
| 384 |
+
Full proofs: [PURPOSE_LEARNING.md](PURPOSE_LEARNING.md) Β· Research trace: [COMPILED_RESEARCH.md](COMPILED_RESEARCH.md)
|
| 385 |
+
|
| 386 |
+
---
|
| 387 |
+
|
| 388 |
+
## π Install
|
| 389 |
|
| 390 |
```bash
|
| 391 |
pip install purpose-agent # Core (zero dependencies)
|
| 392 |
+
pip install purpose-agent[openai] # + OpenAI/Groq/OpenRouter
|
| 393 |
pip install purpose-agent[ollama] # + Local Ollama
|
| 394 |
+
pip install purpose-agent[all] # Everything
|
| 395 |
```
|
| 396 |
|
| 397 |
+
**For local models (recommended β free, private):**
|
| 398 |
+
```bash
|
| 399 |
+
curl -fsSL https://ollama.ai/install.sh | sh
|
| 400 |
+
ollama pull qwen3:1.7b
|
| 401 |
+
```
|
| 402 |
|
| 403 |
+
---
|
| 404 |
+
|
| 405 |
+
## π₯οΈ CLI
|
| 406 |
+
|
| 407 |
+
```bash
|
| 408 |
+
python -m purpose_agent # Interactive wizard
|
| 409 |
+
purpose-agent # Same, via entry point
|
| 410 |
+
```
|
| 411 |
+
|
| 412 |
+
---
|
| 413 |
+
|
| 414 |
+
## π License
|
| 415 |
+
|
| 416 |
+
MIT β use it for anything.
|
| 417 |
+
|
| 418 |
+
---
|
| 419 |
+
|
| 420 |
+
<div align="center">
|
| 421 |
+
|
| 422 |
+
**Built on 13 papers. Zero fine-tuning. Agents that actually improve.**
|
| 423 |
+
|
| 424 |
+
[PyPI](https://pypi.org/project/purpose-agent/) Β· [Architecture](ARCHITECTURE.md) Β· [Formal Proofs](PURPOSE_LEARNING.md) Β· [Changelog](CHANGELOG.md)
|
| 425 |
+
|
| 426 |
+
</div>
|