Concepts Copy

Experience Engine

Translating human developer interventions and real-world execution into reusable procedural skills and institutionalized agent habits.

LLMs possess broad general knowledge, but zero organizational memory. When an experienced staff engineer solves a subtle concurrency bug or refactors a sensitive payment flow, that knowledge traditionally remains locked in PR review comments or ephemeral Slack threads.

The Experience Engine captures human corrections and successful resolutions, compiling them into structured procedural memory that agents apply across future tasks.

The Three Memory Layers

Automated Habit Formation

The Experience Engine continuously analyzes developer interactions:

  1. Correction Ingestion: When a senior engineer rewrites an AI agent's proposed code, the diff is analyzed to isolate the underlying stylistic or architectural rule.
  2. Rule Generalization: The pattern is distilled into a concise procedural invariant (e.g. "Always sanitize tenant IDs using the multi-tenant middleware before invoking db queries").
  3. Skill Compilation: The rule is compiled into a high-priority guardrail node within the knowledge graph.
  4. Proactive Injection: Whenever any agent on the team attempts a similar refactor, the procedural habit is injected before execution occurs.
FRAME 01 · CODE DELTA & CORRECTION INGESTION 01 · Correction Ingest Senior Dev Code Edits Pull Request Reviews AST Syntax Diff Delta Ground Truth Capture OBSERVED Git Commit & Review Watcher • Diffs parsed via Tree-sitter AST delta • Captures negative constraints & habits • Streamed to Candidate Pipeline GENERALIZE FRAME 02 · RULE DISTILLATION & PEARL CAUSAL VERIFICATION 02 · Rule Induction Procedural Pattern Mining Rule Invariant Formulation Context Scope Assignment Candidate State Entry EXTRACTED 03 · Causal Gate P(Y|do(X)) Verification Pearl Backdoor Defense Confidence Half-Life Model Zero Spurious Rules VERIFIED PROMOTE FRAME 03 · PROACTIVE AGENT INJECTION & FLEET RUNTIME 04 · Guardrail Injection Sub-180ms Injection Universal MCP Hook Claude & Cursor Guard Automatic Bug Prevention GUARDRAIL Fleet Enforcement Active • Invariants injected into prompt prefix • Non-conforming code blocked pre-commit • 99.2% Habit Adherence Rate Continuous Human-in-the-Loop Refinement

Recording Experiences via SDK

Teams can explicitly record procedural playbooks programmatically:

from bettercontext import BetterContextClient

client = BetterContextClient()

# Record an institutional procedural habit
client.experience.record(
    title="Postgres Connection Pool Handling",
    trigger_patterns=["database", "db_pool", "sqlalchemy", "connections"],
    guideline="Always wrap async session scopes in a context manager to prevent pool exhaustion.",
    severity="critical",
    tags=["backend", "database", "reliability"]
)

Next Steps

Was this page helpful?

Powered By BetterContext