SkillAgentSearch skills...

SPL-FRAMEWORK

SUBSUMPTION PATTERN LEARNING (SPL) MULTI-AGENT FRAMEWORK: Hierarchical foundation model agent architecture that reduces costs by 10-50x through intelligent suppression of expensive foundation model calls. Grounded in R. Arkin's behavior-based robotics and R.

Install / Use

claude mcp add daseinpbc -- npx -y github:daseinpbc/SPL-FRAMEWORK

If the server publishes to npm under a different name, use that package instead — check the repo README.

About this skill
🔌

MCP Server

Model Context Protocol server

Quality Score

80/100

Category

Automation

Supported Platforms

Claude Code
Claude Desktop

Tags

Subsumption Pattern Learning (SPL) Framework

License: MIT Python 3.8+ Model Context Protocol arXiv Cost Reduction: 13.9x

A hierarchical multi-agent framework that transforms collections of autonomous AI agents into a self-distilling swarm intelligence through shared collective memory.

SPL adapts Brooks' subsumption architecture from behavioral robotics to foundation model economics, implementing a formally-defined three-layer hierarchy (Reactive, Tactical, Deliberative) where learned patterns are distilled into a centralized Shared State via explicit inhibition signals. Interactive demo: https://spl-demo.vercel.app/

Paper: Subsumption Pattern Learning: A Formal Framework for Self-Distilling Swarm Intelligence Through Shared Collective Memory (Cuce, 2026)


📊 Key Results

| Metric | SPL | vs. Monolithic LLM | vs. FrugalGPT | |--------|-----|-------------------|---------------| | Cost (100K tasks) | $89.47 | 13.9× reduction | 3.2× reduction | | Latency (median) | 7ms | 22× faster | 4× faster | | Accuracy | 96.9% | -1.3% | -0.5% | | Suppression Rate | 94.5% | — | — |

Multi-agent swarm learning achieves an additional 42% reduction in foundation model escalations.


🎯 The Isolated Agent Problem

Modern LLM-based agents operate as isolated computational units, each invoking expensive foundation models independently without mechanisms for inter-agent learning or knowledge reuse. This isolation contradicts four decades of insights from behavioral robotics, swarm biology, and organizational psychology.

The economic consequences are significant:

  • Reasoning models generate 5× more tokens per request
  • Multi-step agentic workflows compound costs further
  • Daily costs can reach thousands of dollars
  • Costs remain constant even as agents repeatedly solve nearly identical problems

✨ The SPL Solution

SPL unifies three previously disparate research streams:

  1. Subsumption Architecture (Brooks, 1986): Layered behavioral control where simpler reactive modules suppress more complex deliberative ones
  2. Social Learning Theory (Bandura, 1977): Collectives outperform individuals when knowledge is effectively shared
  3. Swarm Intelligence (Kennedy & Eberhart, 2001): Decentralized systems with shared environmental state solve optimization problems through local interactions

Three-Layer Architecture

┌─────────────────────────────────────────────────────────────────┐
│                     Incoming Request x                          │
└─────────────────────────────┬───────────────────────────────────┘
                              ↓
┌─────────────────────────────────────────────────────────────────┐
│  LAYER 0: Reactive / Structural Validation                      │
│  ─────────────────────────────────────────                      │
│  L₀(x) = (ERROR, e) if ¬valid(x), else (PASS, x)               │
│  Cost: $0  |  Latency: <1ms  |  Deterministic checks            │
└─────────────────────────────┬───────────────────────────────────┘
                              ↓ I₀ = false
┌─────────────────────────────────────────────────────────────────┐
│  LAYER 1: Tactical / Pattern Matching                           │
│  ─────────────────────────────────────                          │
│  L₁(x) = (MATCH, ψ_p*(x)) if ∃p*: φ_p*(x) ≥ θ ∧ complexity(x) ≤ α│
│  Cost: ~$0.0001  |  Latency: <10ms  |  Pattern library lookup   │
│                                                                  │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │  Inhibition Signal: I₁(x) = true → SUPPRESS Layer 2      │   │
│  └──────────────────────────────────────────────────────────┘   │
└─────────────────────────────┬───────────────────────────────────┘
                              ↓ I₁ = false (escalate)
┌─────────────────────────────────────────────────────────────────┐
│  LAYER 2: Deliberative / Foundation Model Reasoning             │
│  ─────────────────────────────────────────────────              │
│  L₂(x) = (SOLVED, L(x), distill(L, x))                         │
│  Cost: $0.01-$0.10  |  Latency: 100-500ms  |  LLM inference     │
│                                                                  │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │  Pattern Distillation: New patterns → Shared State       │   │
│  └──────────────────────────────────────────────────────────┘   │
└─────────────────────────────────────────────────────────────────┘

🔬 Formal Framework

Definition 1: SPL Agent

An SPL agent is a tuple A = (P_local, S, θ, α, L) where:

  • P_local: Agent's local pattern set
  • S: Reference to the shared collective memory
  • θ ∈ (0, 1): Confidence threshold for Layer 1 suppression
  • α ∈ ℝ⁺: Complexity threshold
  • L : X → Y: Layer 2 foundation model

Definition 2: Pattern

A pattern p = (φ_p, ψ_p, κ_p) consists of:

  • φ_p : X → [0, 1]: Matcher returning match confidence
  • ψ_p : X → Y: Responder producing outputs for matched inputs
  • κ_p ∈ ℝ⁺: Complexity bound

Definition 3: Inhibition Signal

The Layer 1 inhibition signal I₁ : X → {true, false}:

I₁(x) = true   if max_{p∈P_e} φ_p(x) ≥ θ ∧ complexity(x) ≤ α
        false  otherwise

When I₁(x) = true, Layer 2 execution is suppressed.

Definition 4: Suppression Rate

ρ = |{x ∈ X_test : I₁(x) = true}| / |X_test|

📦 Shared State Protocol

The Shared State S serves as the swarm's collective memory, enabling stigmergic coordination across agents.

Structure

S = (P_shared, C, M, A) where:

  • P_shared: Global pattern library
  • C : P_shared → [0, 1]: Pattern → confidence scores
  • M : P_shared → ℕ: Pattern → match counts (reinforcement)
  • A : P_shared → AgentID: Pattern provenance tracking

Confidence Update Rules

Reinforcement (successful match):

C'(p) = C(p) + η(1 - C(p))

Decay (incorrect response):

C'(p) = C(p) · (1 - δ)

This implements stigmergic reinforcement: successful patterns accumulate confidence like pheromone trails, while failed patterns decay.

Multi-Agent Architecture

┌─────────────┐     ┌─────────────┐     ┌─────────────┐
│   Agent A   │     │   Agent B   │     │   Agent C   │
├─────────────┤     ├─────────────┤     ├─────────────┤
│  Layer 0    │     │  Layer 0    │     │  Layer 0    │
│  Layer 1    │     │  Layer 1    │     │  Layer 1    │
│  Layer 2    │     │  Layer 2    │     │  Layer 2    │
└──────┬──────┘     └──────┬──────┘     └──────┬──────┘
       │ Write              │ Read/Write        │ Write
       ↓                    ↓                   ↓
┌─────────────────────────────────────────────────────┐
│              SHARED STATE (Collective Memory)        │
├─────────────────────────────────────────────────────┤
│  Learned Patterns  │  Confidence  │  Cross-Agent    │
│  P_shared          │  Scores C(p) │  Markers M(p)   │
└─────────────────────────────────────────────────────┘
                           ↓
              Emergent Swarm Intelligence

📈 Intelligence Compounding Theory

Theorem (Intelligence Compounding)

Under mild assumptions, collective competency satisfies:

Γ(n) = 1 - e^(-πμn/k)

where:

  • n: Number of processed requests
  • π: Probability a novel input yields a distillable pattern
  • μ: Measure of input space covered by each pattern
  • k: Coverage constant

Corollary (Logarithmic Learning)

To achieve competency Γ*, the swarm requires:

n* = (k/πμ) · ln(1/(1 - Γ*))

Key insight: Multi-agent systems amplify this effect—if m agents share state, the effective rate is m · π, reducing time to competency by factor m.


🚀 Quick Start

Installation

# Clone repository
git clone https://github.com/daseinpbc/SPL-FRAMEWORK.git
cd SPL-FRAMEWORK

# Install dependencies
pip install -r requirements.txt

# For multi-agent shared state
pip install redis

Basic Usage

from spl import SPLAgent

# Initialize agent with formal parameters
agent = SPLAgent(
    theta=0.87,      # Confidence threshold (θ)
    alpha=0.6,       # Complexity threshold (α)
    eta=0.1,         # Learning rate (η)
    delta=0.05       # Decay rate (δ)
)

# Add patterns to Layer 1 (P_local)
agent.layer1.add_pattern(
    name='urgent',
    matcher=r'urgent|asap|emergency',  # φ_p
    responder='urgent',                 # ψ_p
    confidence=0.95                     # Initial C(p)
)

# Process request
result = agent.process({
    'user_id': 'user123',
    'content': 'URGENT: Server outage in production'
})

print(result)
# {
#   'result': 'urgent',
#   'layer': 1,                    # Handled by Layer 1
#   'cost': 0.0001,
#   'confidence': 0.95,
#   'inhibition': True,            # I₁(x) = true
#   'suppressed_layer2': True      # Layer 2 NOT invoked
# }

Multi-Agent Swarm Configuration

from spl import SPLAgent, SharedState
import redis

# Initialize shared state (collective memory)
redis_client = redis.Redis(host='localhost', port=6379)
shared_state = SharedState(
    client=redis_client,
    theta_inherit=0.75,    # Inheritance threshold
    sync_interval=100      # ms
)

# Create swarm of agents sharing state
agents = [
    SPLAgent(shared_state=shared_state, agent_id=f'agent_{i}')
    for i in range(5)
]

# When Agent A learns a pattern...
agents[0].process({'content': 'Complex query requiring Layer 2...'})

# ...Agents B-E automatically inherit it via Shared State
# Future similar queries resolved at Layer 1 (zero FM cost)

MCP Integration (Foundation Model Agnostic)

from spl import SPLAgent
from spl.mcp_integration import MCPClient
import anthropic

# Layer 2 can use any foundation model via MCP
client = anthropic.Anthropic()
layer2_mcp = MCPClient(
    model="claude-sonnet-4-20250514",
    api_client=client,
)

agent = SPLAgent()
agent.layer2 = layer2_mcp

# Automatic pattern distillation from Layer 2 responses
result = agent.process({
    'content': 'Novel query requiring deliberative reasoning...'
})
# New pattern extracted and added to Shared State

📊 Experimental Results

Benchmark: 100,000 Heterogeneous Enterprise Tasks

Dataset composition:

  • Email Classification: 40,000 tasks
  • Customer Inquiry Resolution: 35,000 tasks
  • Data Pipeline Orchestration: 25,000 tasks

Single-Agent Performance

| System | Cost (USD) | Latency (ms) | Accuracy | Suppression Rate | |--------|-----------|--------------|----------|------------------| | Monolithic LLM | $1,247.32 | 847 ± 312 | 98.2% | 0.0% | | FrugalGPT | $312.18 | 523 ± 287 | 97.4% | — | | RouteLLM | $287.45 | 498 ± 264 | 97.1% | — | | SPL (Ours) | $89.47 | 38 ± 142 | 96.9% | 94.5% |

Layer Distribution

| Layer | Requests | Percentage | Cost Contribution | |-------|----------|------------|-------------------| | Layer 0 (Reactive) | 4,823 | 4.8% | $0.00 (0.0%) | | Layer 1 (Tactical) | 89,672 | 89.7% | $8.97 (10.0%) | | Layer 2 (Deliberative) | 5,505 | 5.5% | $80.50 (90.0%) |

Despite handling only 5.5% of requests, Layer 2 accounts for 90% of costs—validating the economic case for hierarchical suppression.

Multi-Agent Swarm Learning

| Agent | Tasks | Isolated ρ | Swarm ρ | Improvement | |-------|-------|-----------|---------|-------------| | Agent A | 1–20,000 | 87.2% | 87.2% | — | | Agent B | 20,001–40,000 | 88.1% | 93.4% | +6.0% | | Agent C | 40,001–60,0

Truncated for display — read the full file on GitHub.

Related Skills

View on GitHub
GitHub Stars10
CategoryAutomation
Updated7mo ago
Forks3

Languages

Python

Security Score

91/100

Audited on Jan 31, 2026

1 low1 info