Rohan03 commited on
Commit
f970fc9
Β·
verified Β·
1 Parent(s): e4105d6

README: complete rewrite with visual architecture, animations, feature map, usage guide

Browse files
Files changed (1) hide show
  1. README.md +368 -85
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 v3.0
6
 
7
- **A local-first self-improvement kernel for AI agents.**
8
 
9
- Agents that learn from experience β€” without fine-tuning, cloud infrastructure, or vendor lock‑in.
10
 
11
- ```bash
 
 
 
 
 
 
 
 
12
  pip install purpose-agent
13
  ```
14
 
15
- ## πŸš€ What's New in v3.0?
16
 
17
- > [!TIP]
18
- > Purpose Agent v3.0 hardens the kernel for production use, focusing on security, token efficiency, and absolute execution reliability.
19
 
20
- - **Strict Tool Validation**: Hallucination‑proof tool calling schema. Any hallucinated arguments instantly trigger a corrective loop.
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
- ## πŸ›€οΈ Three Tracks of Usage
28
 
29
- Purpose Agent scales with your needs, from a simple one‑liner to full multi‑agent orchestration.
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
- ### Track 1: Auto‑Pilot (Describe your goal)
32
 
33
- Provide a purpose, and the framework automatically delegates the necessary agents (Architect, Coder, Tester, etc.) and executes.
34
 
35
- ```mermaid
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("Write Python code and test it")
48
- result = team.run("Write a sorting algorithm")
49
- team.teach("Always handle edge cases") # Injects into procedural memory
50
- print(team.status())
51
  ```
52
 
53
- ### Track 2: Bring Your Own Model
 
 
54
 
55
- Swap in local models for free, private execution, or connect to OpenRouter, Groq, or OpenAI for state‑of‑the‑art reasoning.
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
- # Local (free, private)
67
- team = pa.purpose("Code helper", model="qwen3:1.7b")
68
 
69
- # Cloud providers
70
- team = pa.purpose("Code helper", model="openrouter:meta-llama/llama-3.3-70b-instruct")
71
- team = pa.purpose("Code helper", model="groq:llama-3.3-70b-versatile")
72
- team = pa.purpose("Code helper", model="openai:gpt-4o")
 
73
 
74
- # Any OpenAI‑compatible API
75
- from purpose_agent import resolve_backend
76
- backend = resolve_backend("openrouter:google/gemma-4-26b-a4b-it", api_key="sk-or-...")
77
  ```
78
 
79
- ### Track 3: Full Multi‑Agent Control
80
 
81
- Take total control over the orchestration with `Spark` (Agent), `Flow` (Workflow DAG), `Council` (Deliberation), and `Vault` (RAG).
 
82
 
83
- ```mermaid
84
- graph LR
85
- A((BEGIN)) --> B[Research Spark]
86
- B --> C[Write Spark]
87
- C --> D{Review?}
88
- D -- Pass --> E((DONE))
89
- D -- Fail --> B
 
 
 
 
 
90
  ```
91
 
 
 
92
  ```python
93
  import purpose_agent as pa
94
 
95
- # ── Spark: a single intelligent agent ──
96
- spark = pa.Spark("coder", model="openrouter:meta-llama/llama-3.3-70b-instruct")
97
- result = spark.run("Write a fibonacci function")
98
 
99
- # ── Flow: workflow engine with conditional routing ──
100
  flow = pa.Flow()
101
- flow.add_node("research", pa.Spark("researcher", model="qwen3:1.7b"))
102
- flow.add_node("write", pa.Spark("writer", model="qwen3:1.7b"))
103
  flow.add_edge(pa.BEGIN, "research")
104
- flow.add_edge("research", "write")
105
- flow.add_conditional_edge("write", review_fn, {"pass": pa.DONE_SIGNAL, "retry": "research"})
106
- result = flow.run(initial_state)
107
 
108
- # ── Council: agents deliberate together ──
109
- council = pa.Council([pa.Spark("researcher"), pa.Spark("coder"), pa.Spark("reviewer")])
110
- result = council.run("Design a web scraper", rounds=3)
 
 
 
 
 
 
 
 
 
 
 
 
111
  ```
112
 
113
  ---
114
 
115
- ## πŸ›‘οΈ Evidence‑Gated Memory & Immune System
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
 
117
- Agents don't just accumulate knowledge blindly. Every new memory goes through a secure pipeline:
 
 
 
 
 
 
118
 
119
- ```mermaid
120
- flowchart LR
121
- A[Candidate Memory] --> B{Immune Scan}
122
- B -- Block --> C[Quarantine]
123
- B -- Pass --> D[Replay Test]
124
- D -- Helps --> E[Promoted to SOP]
125
- D -- Hurts --> F[Rejected]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  ```
127
 
128
- - **Immune scan** blocks prompt injection, score manipulation, API key leaks, tool misuse.
129
- - **Quarantine** holds memories until they're tested.
130
- - **Promotion** happens only after empirical evidence shows the memory improves reward.
 
 
 
 
 
 
 
 
 
 
 
 
 
131
 
132
- ## πŸ“¦ Install
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
 
134
  ```bash
135
  pip install purpose-agent # Core (zero dependencies)
136
- pip install purpose-agent[openai] # + OpenAI / Groq / OpenRouter
137
  pip install purpose-agent[ollama] # + Local Ollama
138
- pip install purpose-agent[all] # Everything
139
  ```
140
 
141
- ## πŸ“– License
 
 
 
 
142
 
143
- MIT
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ [![PyPI](https://img.shields.io/pypi/v/purpose-agent?color=blue&label=PyPI)](https://pypi.org/project/purpose-agent/)
29
+ [![Python](https://img.shields.io/pypi/pyversions/purpose-agent)](https://pypi.org/project/purpose-agent/)
30
+ [![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)
31
+ [![Tests](https://img.shields.io/badge/tests-250%2B_passing-brightgreen)]()
32
+ [![Papers](https://img.shields.io/badge/papers-13_implemented-purple)]()
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>