Skip to Content
FeaturesMemory & Learning

Memory & Learning

Pilot learns from every execution. The memory subsystem stores execution history, extracts patterns, and applies learned knowledge to future tasks.

Execution History

Every task execution is recorded in SQLite (~/.pilot/data/pilot.db). Each record captures:

FieldDescription
task_idIssue or task identifier
project_pathProject where task ran
statuscompleted, failed, running
duration_msExecution time
tokens_input/outputToken usage
estimated_cost_usdCost estimate
files_changedNumber of files modified
lines_added/removedCode churn
pr_urlCreated PR link
commit_shaFinal commit

Query execution history:

# Recent executions pilot metrics summary # Per-project breakdown pilot metrics projects # Daily trends pilot metrics daily --days 30

Lifetime Metrics

Metrics persist across Pilot restarts. The dashboard’s “Lifetime” section shows cumulative totals:

  • Tasks completed/failed — Total count across all time
  • Tokens used — Cumulative input/output tokens
  • Total cost — Estimated API spend

These values are computed from the executions table, not ephemeral session state.

# View lifetime summary in dashboard pilot start --dashboard

Cross-Project Patterns

Pilot extracts patterns from successful executions and applies them across projects.

Pattern Types

TypeDescriptionExample
codeCode structure patterns”Use dependency injection for services”
structureDirectory/file conventions”Tests live in __tests__/ directories”
namingNaming conventions”Use handle* prefix for event handlers”
workflowProcess patterns”Run lint before commit”
errorAnti-patterns to avoid”Don’t use any type in TypeScript”

Pattern Commands

# List all learned patterns pilot patterns list # Search patterns by keyword pilot patterns search "authentication" # View pattern statistics pilot patterns stats

How Patterns Work

  1. Extraction — After each execution, the pattern extractor analyzes changes
  2. Storage — Patterns are saved with confidence scores (0.0–1.0)
  3. Feedback — Success/failure outcomes adjust confidence
  4. Pruning — Low-confidence patterns decay over time

Patterns with confidence below 0.1 are automatically pruned. High-confidence patterns (>0.7) are prioritized in future task prompts.

Review Learning

After a PR is merged, Pilot processes review comments left by human reviewers to learn patterns for future tasks. The LearnFromReview() method fetches PR review comments via the GitHub API and categorizes them by review type.

Review TypeSignalEffect
Approved (with text)PositiveBoost pattern confidence
Changes requestedNegativeCreate anti-pattern (max 0.85 confidence)
Approved (no text)NoneSkipped
  • Approved reviews with text — Reviewer comments on approved PRs are treated as positive signals. Patterns used in the execution get a confidence boost.
  • Changes-requested reviews — Reviewer feedback is extracted as anti-patterns, capped at 0.85 confidence to allow future override if conventions change.
  • Empty approvals — Approval clicks without review text are skipped since there is no actionable signal to extract.

Learned patterns are injected into future execution prompts, so Pilot’s code quality improves over time based on your team’s feedback.

Review learning runs automatically after PR merge. No configuration needed — it uses the same GitHub token configured for the GitHub adapter.

CI Failure Pattern Extraction

Since v2.52.0

Pilot extracts error patterns from CI failure logs and stores them for future reference. When a similar CI failure occurs later, the learned pattern is injected into the execution prompt to help prevent repeat failures.

Error Categories

CategoryExample
compilationMissing imports, type mismatches
test_failureAssertion errors, timeout flakes
lintStyle violations, unused variables
dependencyVersion conflicts, missing modules
runtimeNil dereference, out of memory

How It Works

  1. Detection — CI fails on a Pilot PR
  2. Extraction — Failure logs are parsed for error patterns with category and frequency
  3. Storage — Patterns are saved to the cross_patterns table with error type metadata
  4. Injection — On future tasks in the same project, relevant CI failure patterns are included in the prompt

CI failure extraction is automatic when autopilot monitors CI. No additional configuration needed.

Self-Review Pattern Extraction

Since v2.48.0

Findings from Pilot’s self-review step feed back into the learning system. When self-review identifies an issue in generated code, ExtractFromSelfReview() captures it as a pattern so the same mistake is avoided next time.

This creates a feedback loop:

  1. Generate — Pilot writes code for a task
  2. Review — Self-review identifies issues (e.g., missing error handling)
  3. Learn — Issues are stored as anti-patterns with source self_review
  4. Prevent — Future prompts include the learned anti-patterns

Self-review patterns follow the same confidence scoring as other patterns — they decay if not reinforced and are pruned below the configured threshold.

Knowledge Graph

The knowledge graph stores relationships between concepts, files, and patterns.

Node Types

  • pattern — Learned code/workflow patterns
  • learning — Insights from debugging sessions
  • decision — Architectural choices made
  • pitfall — Common mistakes to avoid

Graph Structure

~/.pilot/data/knowledge.json

Nodes can have relations to other nodes, enabling queries like “what patterns relate to authentication?”

Adding Knowledge

Knowledge is added automatically during execution. graph.AddLearning() stores task metadata after each execution, while graph.GetRelated(keywords) queries related learnings across node relationships: task type → files → patterns → outcomes.

graph.AddLearning("JWT refresh flow", "Use sliding window...", metadata) graph.AddPattern("error_handling", "Always wrap in try/catch", nil) related := graph.GetRelated([]string{"auth", "jwt"})

Full knowledge graph wiring for execution prompts is in progress — see GH-2012 .

Knowledge Store (Memories)

Separate from patterns, the knowledge store holds experiential memories with time-based decay.

Memory Types

TypeUse Case
patternRecurring patterns discovered
pitfallMistakes to avoid
decisionArchitectural decisions
learningDebug insights

Confidence Decay

Memories have a confidence score that decays over time if not reinforced:

  • Initial: 1.0 (full confidence)
  • Decay rate: Configurable per-day reduction
  • Reinforcement: Using a memory increases confidence
  • Pruning: Memories below threshold (default 0.1) are removed

This ensures stale knowledge doesn’t pollute future prompts while validated patterns remain available.

Temporal Pattern Relevance (Upcoming)

Per-project, per-task-type confidence tracking with recency decay. Patterns unused for 90+ days receive reduced weight, ensuring that stale conventions don’t override current practices.

Temporal relevance scoring is in progress — see GH-2013 .

Data Storage

~/.pilot/data/ ├── pilot.db # SQLite database (executions, patterns, metrics) ├── knowledge.json # Knowledge graph nodes └── global_patterns.json # Cross-project pattern store

Database Tables

TablePurpose
executionsTask execution history
patternsProject-specific patterns
cross_patternsOrganization-wide patterns
pattern_projectsPattern-to-project relationships
pattern_feedbackSuccess/failure outcomes
memoriesExperiential knowledge store
sessionsDashboard session metrics
usage_eventsBilling/metering data

Performance Indexes

Since v2.47.0

The cross_patterns table has performance indexes on frequently queried columns: title, description, scope, and updated_at. These indexes speed up pattern lookups during prompt construction, especially for organizations with large pattern stores.

Configuration

Memory features are enabled by default. Configuration options:

# ~/.pilot/config.yaml memory: enabled: true db_path: ~/.pilot/data # SQLite location pattern_min_confidence: 0.3 # Minimum for prompt inclusion decay_rate: 0.02 # Confidence decay per day prune_threshold: 0.1 # Remove below this

Privacy

Pilot stores execution data locally by default. If you enable multi-repo polling or team features, data may be shared across projects within your organization.

  • All data is stored in ~/.pilot/data/
  • No data is sent to external services (unless you configure webhooks)
  • Patterns are scoped: project (single project), org (your projects), or global