patterns
Category: injection · Cloud + Local · Status: v1 — production
The model gets measurably smarter per user over time. patterns watches for fixes (“the issue was X, the solution is Y”) in successful conversations and saves them. On future requests, it injects relevant patterns into the system prompt.
What it does
Two halves:
- Inject (pre hook): find patterns relevant to the current query, prepend them to the system prompt.
- Forge (post hook): scan the response for fix-pattern shape (“the bug was X, the fix is Y”), save it.
Repeated problem types get solved faster each time. After a few weeks, the model has effectively learned your codebase’s quirks, your team’s conventions, and your common gotchas.
When to use it
✅ Coding assistants (huge wins per-codebase) ✅ Customer support (recurring ticket types) ✅ Any workflow where similar problems recur
❌ One-shot creative tasks ❌ Workflows with no learning signal (no “this was the fix” feedback)
Configuration
patterns:
maxInjected: 5 # max patterns per request
minSuccessRate: 0.6 # only inject patterns with this success rate
forgeOnSuccess: true # forge new patterns from response detection
decayAfterDays: 90 # don't inject patterns older than N days
similarity: 0.6 # min relevance for injectionMetrics emitted
patterns.injected(number)patterns.forged(number; post-hook)patterns.lookup_ms(number)
Examples
Conservative injection — only highly-trusted patterns:
patterns:
maxInjected: 3
minSuccessRate: 0.85Aggressive learning — forge eagerly, inject many:
patterns:
maxInjected: 8
minSuccessRate: 0.5
forgeOnSuccess: trueRead-only mode — use existing patterns, don’t forge new ones:
patterns:
forgeOnSuccess: falseHow it works
Pre hook (injection)
- Extract last user message text.
- Embed it.
- Vector search the patterns table for the user, scoped by
minSuccessRateanddecayAfterDays. - Take top
maxInjectedmatches. - Format as a
<learned-patterns>block, prepend to the system prompt.
Post hook (forging)
- Extract response text.
- Run regex detection for fix-pattern shape:
the (issue|bug|problem) was X, (the fix|solution) is Yto (fix|solve|resolve) X, do Y- And similar variants.
- If detected, store as a new pattern with the request embedding as the lookup vector.
v1 forging uses regex-based detection. v1.1 swaps in a small LLM-driven detector with outcome tracking — patterns whose injection led to user “yes that worked” responses get reinforced; patterns that didn’t get retired.
Pattern lifecycle
created ──▶ injected ──▶ outcome (success/failure) ──▶ reinforced or retired- Reinforced: success counter increments, success rate updates.
- Retired: if success rate drops below 30% over 10+ uses, pattern is no longer injected.
- Decayed: patterns older than
decayAfterDaysstop being injected even if rate is high (likely stale).
Privacy
- Patterns are scoped to the
userIdby default. They are never shared across users in v1. - v1.1 introduces opt-in
collectivepatterns — anonymized, rated, shareable.
Cloud vs Local
| Mode | Backend |
|---|---|
| Cloud | Postgres + pgvector |
| Local | SQLite + sqlite-vec (or JSON-cosine fallback) |
Local patterns stay on your machine forever. Survive container restarts (they live in ~/.prxy/prxy.db).