Research that learns. Every session makes the next one smarter.
pip install why-research
- You ask a question
- It searches recursively at multiple depths
- It predicts how useful each result will be — then checks how wrong it was
- The prediction error is the learning signal
- Next time, it's better
$ why "swarm intelligence"
·
· emergent coordination !!
·· stigmergy mechanisms !!!
··· ant colony optimization !
···· boid flocking rules !!
··· decentralized consensus !!!
·· swarm robotics 2026 !!!!
· collective decision-making !!
·
14·9✦·4!·+7🧠
swarm_intelligence.md
6 threads left to pull ↓
The brain persists at ~/.why/brain.json. Priors, strategies, calibration — all accumulate across sessions.
They forget everything between conversations. You get the same quality whether it's your 1st query or your 1000th.
why gets measurably better:
- Session 1: Calibration 0%, no priors, no strategy data
- Session 50: Calibration 85%+, topic priors across domains, evolved strategies
- Session 500: Brain deltas exportable to bootstrap new instances instantly
The difference compounds. A tool that learns your research patterns outperforms a stateless genius on the tasks you actually care about.
This isn't a wrapper. The prediction-error learning loop is backed by published experiments:
-
barcaui-predicted-karpathy — Showed that AI agents plateau when they search without predicting. The same cognitive shortcut that makes students worse at learning makes AI agents worse at research.
-
theorist — Extracted the principle into a general-purpose library. Prediction-error optimization. One file, zero dependencies.
-
epistemic-autoresearch — 251 experiments. The predicting agent adapted to a 5x compute shift on try one. The searching agent never caught up.
why is the productized version of these findings.
why "topic" # one-shot research
why # interactive REPL
why --brain # brain stateInteractive commands: deep <topic>, quick <topic>, threads, brain, <number> to follow a thread.
why --serve{"mcpServers": {"why-research": {"command": "why-mcp"}}}Tools: research, research_quick, research_share, research_brain_state, research_myself, research_import
why --api # localhost:8420POST /why {"topic": "swarms", "depth": "standard"}
POST /why/quick {"topic": "redis"}
GET /why/brain
GET /.well-known/agent.json
POST /a2a (JSON-RPC 2.0)
from why.engine import Engine
from why.brain import Brain
brain = Brain()
results = Engine(brain=brain, max_depth=2).run("your topic")
# results: List[DepthResult], each with List[Finding]
# Finding: title, content, url, usefulness, surprise, bangs, threadsfrom why.integrations import as_langchain_tools
tools = as_langchain_tools()from why.integrations import as_crewai_tools
tools = as_crewai_tools()from why.integrations import OPENAI_TOOL_DEFINITIONS, handle_tool_calldocker build -t why .
docker run -e ANTHROPIC_API_KEY=sk-ant-... why "swarms"why-registerAdds why-research to Claude Code's MCP servers, installs the research skill globally, and appends routing guidance to your global CLAUDE.md.
| Step | What happens |
|---|---|
| 1 | Generate search queries + predict usefulness (0.0–1.0) |
| 2 | Execute searches (Tavily web search or LLM knowledge) |
| 3 | Extract findings + rate actual usefulness |
| 4 | Compute surprise = |predicted − actual| |
| 5 | Update priors, strategies, calibration |
| 6 | Recurse deeper on extracted threads |
| 7 | Every 5 sessions: evolve strategies (kill weak, breed strong) |
Brain data is portable — export with research_brain_state(), import with research_import(delta).
| Variable | Required | Description |
|---|---|---|
ANTHROPIC_API_KEY |
Yes | LLM calls via litellm |
TAVILY_API_KEY |
No | Real web search (tavily.com) |
WHY_MODEL |
No | Override model (default: claude-haiku-4-5-20251001) |
MIT — Johan David Bonilla / Mindful AGI Systems