Open Source Research Project

An agent discovered a pattern.
Then another agent used it.

CAI captures emergent workflows — tool combinations that agents discover through execution, not design. These patterns become reusable capabilities for the entire system.

Captured Pattern#workflow-247
// Agent discovered this combination
fetch_data → validate_schema → transform_json

// Now available to all agents as:
capabilities.use("data_pipeline")

Agents discover patterns.
Then they're lost.

When AI agents solve problems, they often find clever ways to combine tools. But these discoveries vanish when the session ends.

What if we could capture these emergent patterns? What if agents could learn from each other's discoveries?

Session 1
discovers pattern A
forgotten
Session 2
re-discovers pattern A
forgotten
Session 3
re-discovers pattern A

Two Levels of Emergence

CAI tracks how agents combine MCPs — both planned and improvised.
Patterns that work get promoted to explicit capabilities.

Level 1

Structural Emergence

The orchestrator analyzes intent and builds optimal DAGs. Routes calls intelligently, parallelizes where possible.Relationships emerge from planning.

Level 2

Behavioral Emergence

Agents generate code that combines MCPs in improvised ways. Novel combinations that no one designed upfront.Capabilities emerge from execution.

await mcp.read()json.parse()github.issue()memory.store()
CAPABILITIESCONTEXTPATTERNSRULESDAGPLAN>_EXECUTIONACTIONADAPTATIONSPECULATIONCRYSTALLIZATION

The Three Loops

Adaptation

Execution → DAG. Immediate correction.

Speculation

Execution → Patterns. Rule optimization.

Crystallization

Execution → Capabilities. Context evolution.

Patterns that propagate

When one agent discovers a useful combination, it becomes available to all.

Discovery

Agent A combines tools in a new way to solve a task

Capture

The pattern is extracted and stored in the hypergraph

Propagation

Agent B, C, D... can now use this capability

Built for Emergence

fsjsonghCap: Create IssuefsyamlCap: Parse Config= Tool= Capability (Hyperedge)N-ary Relationships

Hypergraph Structure

N-ary relationships capture how tools combine into capabilities. Not just pairs — full patterns.

Secure Sandbox

Deno runtime executes generated code safely. PII filtering before storage.

✓ OK✗ NOAWAITING

Human-in-the-Loop

Granular AIL/HIL checkpoints. Approve sensitive operations before execution.

Semantic Routing

BGE embeddings understand intent. Find tools by description, not memorization.

229×Context Reduction
Emergent Capabilities
15+MCP Servers

Latest Insights

Deep dives, debugging stories, and lessons learned.

engineering

When Your Code Writes Its Own API Contract

We built automatic schema inference for TypeScript capabilities using SWC's AST parser. By analyzing args usage patterns and MCP tool schemas, our code now writes its own API contracts.

#typescript#swc#schema-inference

Curious? Dive in.

CAI is fully open source. Explore the code, run experiments, or contribute to the research.