Procedural Memory
Agents often solve the same kind of problem repeatedly — refund a delayed order, onboard a new user, debug a failing deployment. Procedural memory lets agents learn successful tool-call sequences and reuse them when a similar situation arises. Instead of reasoning from scratch every time, the agent can recall a proven procedure and follow it, reducing latency, token usage, and error rates.How It Works
- After a successful run, the memory system analyzes the tool-call sequence
- If the sequence is multi-step and coherent, it’s extracted as a procedure
- On future runs,
buildContext()checks if any stored procedure matches the current query - If a match is found, the procedure is injected into the system prompt as a suggested plan
Quick Start
Scope hierarchy (v2.3+)
Procedures are shareable across users — a workflow like “invoice reconciliation” should be available to every accountant on the team, not just whoever first ran it. Each procedure carries an explicit scope:
Reads union all accessible scopes. When alice (working with the
invoice-recon agent at tenant acme) calls recall_procedure, the
framework searches her personal procedures plus the agent’s shared
procedures plus the tenant’s procedures plus global defaults.
Writes choose one scope. Auto-extracted procedures always save as
"user" — the framework never auto-promotes a personal procedure to a
shared scope without an explicit caller choice.
Configuration
For fine-grained control, pass a configuration object:Procedure Structure
Each stored procedure contains:Example Procedure
After the agent successfully processes a refund, this procedure might be extracted:How Procedures Are Learned
After each run, the memory system evaluates the tool-call sequence:successCount is incremented rather than creating a duplicate.
Procedure Matching with suggestProcedure
Before each run, the memory system checks for matching procedures:
The recall_procedure Tool
When procedural memory is enabled, the agent gains access to the recall_procedure tool, which it can call at any time during a run:
Full Example: Learning and Reusing
successCount grows, and the agent can reference its track record when deciding to follow it.
How Procedures Evolve
Procedures aren’t static. Over time:- Success reinforcement — each successful use increments
successCount - Failure tracking — if the agent deviates or the user reports a bad outcome,
failureCountincrements - Eviction — when
maxProceduresis reached, procedures with the lowest success-to-failure ratio and oldestlastUseddate are evicted - Merging — if two procedures are semantically very similar, they’re merged (steps unified, counts combined)
Cross-References
- Memory Overview — Unified memory system
- Composite Scoring — How procedure suggestions are ranked
- Memory Stores — Other memory subsystems
- Agents: Tools — Tool definitions used in procedures