Instinct Clustering (Homunculus Pattern)
Behavioral pattern mining from tool-call telemetry. Observes what the agent does across sessions, clusters high-frequency patterns into “instincts,” and injects only high-confidence instincts at session start. Implemented infmflurry/settings-opencode.
Unlike Agentic Memory Tool (explicit memory calls) and Agent Self-Correction (query-on-deviation), instinct clustering is implicit and continuous — it learns from behavior, not from conversation.
Three-Plugin Pipeline
What Instincts Look Like
Instincts are not conversation summaries — they are behavioral regularities extracted from tool use:- “Agent consistently runs
npm testafter editingsrc/files” - “Agent always reads
CONTEXT.mdbefore touching domain logic” - “Agent uses
git worktree addbefore any multi-file refactor” - “Agent queries
qmdwhen context exceeds 80K tokens”
Storage
- Observations:
~/.claude/homunculus/projects/<id>/observations.jsonl(gitignored) - Instincts:
~/.claude/homunculus/projects/<id>/instincts.json - Shared between OpenCode and Claude Code (same path)
Auto-Learned Skill Problem
The homunculus system also auto-generates skills at session end (v1 pipeline:continuous-learning-stop-hook.js → evaluate-session.js → skills/learned/). Without triage, duplicate skills accumulate:
instinct-digest.ts shows the diff; human triages periodically. When running multiple harnesses (CC + OpenCode), this compounds — each harness generates its own learned skills from the same sessions.
If adopting this pattern: schedule periodic triage. Do not let learned skills accumulate more than 1 week without review.
Vs. Other Memory Patterns
Instinct clustering is the only implicit pattern — it requires no agent action to learn from behavior.
ECC v2 — Production Implementation
Everything Claude Code (ECC) (ECC) ships a concrete, production-grade implementation inskills/continuous-learning-v2/. This upgrades the pattern from theoretically described to adoptable.
ECC v1 (Stop-hook pipeline)
session-end.js (Stop hook) → evaluate-session.js → writes to skills/learned/. Problem: without triage, duplicates accumulate.
ECC v2 (Instinct-based with confidence scoring)
/learn-eval vs /learn: /learn extracts and saves immediately; /learn-eval adds an evaluation step (confidence scoring, deduplication check) before writing. Prefer /learn-eval in production to avoid accumulating noise.
Honcho
toadi in the r/opencodeCLI thread mentioned Honcho as an alternative memory system: “It captures well. But my problem is that I can not make the models use the memories well.” This is the adoption problem — memory systems that capture well but aren’t queried are inert. Instinct injection at session start sidesteps this by pushing high-confidence patterns rather than waiting for the agent to pull.
Related Pages
- Agent Self-Correction — complementary explicit deviation detection
- Agentic Memory Tool — explicit cross-session memory (Anthropic)
- Mnemory — explicit cross-session memory (OSS)
- OpenCode — plugin system that implements this pattern
- Everything Claude Code (ECC) — ECC: production implementation of this pattern
- Context Compression Strategies — what gets injected competes with task context