Your agent should remember your corrections
This page runs a real Postgres (PGlite, compiled to WebAssembly) with pgvector and a small embedding model, all inside this tab. Every approve, edit and reject is stored with an embedding of the task. Before the next draft, the agent pulls feedback from similar past tasks into its prompt. Nothing leaves your browser.
Starting Postgres in your browser…
1. What the agent reads before drafting
Type a new customer comment. The sample data below is a made-up candle shop.
…
The SQL behind it
-- every approve / edit / reject is a row, with an embedding of the task
create table agent_learning.feedback (
id uuid primary key default gen_random_uuid(),
run_id uuid not null references agent_learning.runs(id),
rating smallint not null check (rating between -1 and 1),
correction text, reason text, situation text not null,
situation_embedding vector(1536),
created_at timestamptz not null default now()
);
-- before the next draft: closest past corrections (plain approvals carry no lesson)
select f.rating, f.correction, f.reason, f.situation,
1 - (f.situation_embedding <=> $1) as similarity
from agent_learning.feedback f
where (f.rating <= 0 or f.reason is not null)
and 1 - (f.situation_embedding <=> $1) >= $2
order by f.situation_embedding <=> $1
limit 5;
Same schema works on Supabase or any Postgres with pgvector: schema.sql2. Stored decisions
3. Add your own decision
Embeddings come from all-MiniLM-L6-v2 running in this tab (Transformers.js, a 23 MB download the first time), so "similar" means similar meaning. Until the model has loaded, the page falls back to hashing words, where similar only means shared words. In production you'd plug in your own embedding model: the repo's loop takes any embed function. Plain approvals are stored but not retrieved: they carry no lesson.
Use the same loop in Claude Code, Cursor or Claude Desktop
It ships as a small MCP server: your agent calls recall_corrections before it drafts and record_decision after you approve, edit or reject. Local Postgres + pgvector on your machine, nothing to host.
claude mcp add feedback-memory -- npx -y github:ssap-pa/self-learning-agent-setup
"command": "npx", "args": ["-y", "github:ssap-pa/self-learning-agent-setup"]