Agentic Pattern Libraryby Vikas Goyal
← All patterns
38

Habit Formation

Also known as: System 2 → System 1 distillation, skill caching, learned shortcuts

Repeated System 2 solutions get compiled into fast System 1 skills or rules.

TrackAgentic systems FamilyFast & slow Maturity Horizon ChangesContext
01

Problem

An agent that escalates to slow reasoning keeps solving the same hard cases from scratch. The tenth time it handles a cancelled flight or a duplicate invoice, it spends the same time and tokens as the first. People get faster at familiar problems; agents usually don’t.

  • Many “hard” cases repeat with small variations.
  • Reusing a past solution is far cheaper than reasoning again.
  • A shortcut learned from bad examples spreads mistakes quickly.
  • Cached knowledge goes stale as policies and systems change.
02

Solution

Log every System 2 solution with its inputs, reasoning and outcome. Periodically group similar solved cases and look for ones that succeeded consistently. Turn each stable cluster into something System 1 can use directly: a skill with step-by-step instructions, a rule, a few-shot example, a cached answer or, at larger scale, fine-tuning data. Gate every new habit on an evaluation set, give it an owner and an expiry date, and re-check it whenever the underlying policy or system changes.

03

Diagram

RUN TIME Request System 1uses skills System 2hard cases Case loginput · steps · outcome OFFLINE Clusterrepeated + successful Evalgate New skillowner · expiry escalate log pass promote

The slow path writes the cases; an offline step promotes repeated, successful ones into fast skills. Escalation rates should fall over time.

04

When to use

Use it when

  • The same kinds of hard case keep reaching System 2
  • Outcomes can be judged, so you know which solutions worked
  • You already log traces from the slow path
  • Cost or latency of escalations is a real concern

Avoid it when

  • Hard cases are genuinely unique each time
  • You can't tell good solutions from bad ones
  • Policies change so fast that habits expire before they pay off
05

Trade-offs

Latency Repeated cases move to the fast path
Cost Fewer escalations over time
Complexity Logging, clustering, evals and expiry
Reliability Good when gated; risky if bad habits slip in

Gains

  • The agent gets faster and cheaper at familiar problems over time
  • Reasoning effort shifts to genuinely new cases
  • Promoted skills are readable and reviewable by people

Costs

  • {"Needs a pipeline"=>"trace logging, grouping, evaluation and rollout"}
  • A bad habit applies confidently to every matching case
  • Stale habits need active expiry and re-checks
06

Worked example

Scenario
A travel-desk agent uses Fast/Slow Escalation. Same-day rebookings after cancellations always escalate to System 2.
  1. Month 1214 cancellation rebookings escalate. Each takes about 18 seconds of reasoning.
  2. ClusteringGroups solved cases and finds that 160 of them followed the same steps: same-day, same airline, in-policy fare, preferred seat. The outcome was accepted 96% of the time.
  3. PromotionThat cluster becomes a skill, rebook_same_day_in_policy, with step-by-step instructions System 1 can follow.
  4. Eval gateOn 40 held-out cases, the skill matches System 2’s choice 38 times. The 2 misses involved partner airlines, so they’re excluded from the skill.
  5. Month 2Escalations for cancellations drop from 214 to 61. The skill has an owner and a 90-day expiry, and gets re-checked when the travel policy changes.
07

Failure modes

FailureSymptomMitigation
Learning bad habitsA shortcut copies a solution that only looked successfulPromote only cases with verified good outcomes; gate on evals
Over-generalizationSkill applied to cases that look similar but aren'tWrite explicit preconditions; exclude known edge cases
Stale habitsSkill follows last quarter's policyOwners, expiry dates and re-checks on policy change
Invisible changesNobody knows why behavior shiftedVersion skills and log which one handled each case