Skip to Content
prxy.monster v1 is in early access. See what shipped →
Modulespatterns

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 injection

Metrics 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.85

Aggressive learning — forge eagerly, inject many:

patterns: maxInjected: 8 minSuccessRate: 0.5 forgeOnSuccess: true

Read-only mode — use existing patterns, don’t forge new ones:

patterns: forgeOnSuccess: false

How it works

Pre hook (injection)

  1. Extract last user message text.
  2. Embed it.
  3. Vector search the patterns table for the user, scoped by minSuccessRate and decayAfterDays.
  4. Take top maxInjected matches.
  5. Format as a <learned-patterns> block, prepend to the system prompt.

Post hook (forging)

  1. Extract response text.
  2. Run regex detection for fix-pattern shape:
    • the (issue|bug|problem) was X, (the fix|solution) is Y
    • to (fix|solve|resolve) X, do Y
    • And similar variants.
  3. 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 decayAfterDays stop being injected even if rate is high (likely stale).

Privacy

  • Patterns are scoped to the userId by default. They are never shared across users in v1.
  • v1.1 introduces opt-in collective patterns — anonymized, rated, shareable.

Cloud vs Local

ModeBackend
CloudPostgres + pgvector
LocalSQLite + sqlite-vec (or JSON-cosine fallback)

Local patterns stay on your machine forever. Survive container restarts (they live in ~/.prxy/prxy.db).

Source

packages/modules-core/src/patterns.ts

Last updated on