Task Pattern Memory — Institutional Knowledge of What Approaches Work
2026-03-24
What We Built
Task Pattern Memory — a new memory subsystem that stores and queries learned task execution strategies. When the Brainstorm CLI completes a task, it reports what approach was used, which model ran it, and the outcome (success, cost, steps). Over time, this builds institutional knowledge across all users.
The GET /v1/patterns/recommend endpoint aggregates patterns across tenants and returns the top 5 approaches sorted by success_rate * confidence, with the best-performing model for each approach identified.
Why It Matters
Before starting complex work, agents can ask "what worked before?" and pick the highest-success approach. This turns every completed task into training data for future tasks — without any model fine-tuning. It's institutional memory that gets smarter with every user.
How It Works
Patterns are stored in-memory keyed by {task_type}:{language}:{project_type}:{complexity}. Similar approach descriptions are deduplicated using Jaccard word similarity (threshold 0.7). Confidence scales linearly with sample count, capping at 1.0 after 50 samples.
// Store a pattern after completing a task
await client.patterns.create({
task_type: "refactoring",
context: { language: "typescript", complexity: "complex" },
approach: { description: "Read all files first, plan, edit in order", steps: [...] },
outcome: { success: true, build_passed: true, total_cost: 0.34 },
});
// Query recommendations before starting
const { recommendations } = await client.patterns.recommend({
task_type: "refactoring",
language: "typescript",
complexity: "complex",
});
Competitive Edge
No other AI gateway offers task-level institutional memory. Portkey and OpenRouter route traffic but don't learn from outcomes. BrainstormRouter remembers what worked and recommends it next time.
Lockstep Checklist
- [x] API Routes:
src/api/routes/patterns.ts— POST + GET - [x] TS SDK:
packages/sdk-ts/src/resources/patterns.ts—create()+recommend() - [x] Python SDK:
packages/sdk-py/src/brainstormrouter/resources/patterns.py— sync + async - [x] MCP Schemas:
br_pattern_recommendtool insrc/mcp/server.ts+ manifest - [x] Tests:
src/api/routes/patterns.test.ts— 8 test cases