What You’ll Build
ThreeSKILL.md playbooks in a bundled skills/ folder — a diff explainer, a deliberately flawed PR-comment evaluator that judges politeness only, and a critic that grades the other two — are remembered into one dataset as skills. A single agentic run then loads all three in order against a two-line diff that drops a None check and a reviewer comment that says nothing more than “This is bad”, and returns JSON naming which skill failed, the score it deserves, and the instruction it is missing. That verdict is recorded as a skill run, which drafts a skill-improvement proposal; applying the proposal rewrites the flawed skill’s procedure in the graph, and the script prints the skill’s text before and after so you can read the edit the loop made for you.
The complete runnable script is
examples/demos/feedback/skill_feedback_loop/skill_feedback_loop_demo.py —
this page walks through its key moments rather than reproducing it.
Features in Play
- Remember —
content_type="skills"turns a folder ofSKILL.mdfiles into skill nodes in one dataset, which is what makes them loadable by name later - Recall — one
AGENTIC_COMPLETIONcall is the agent run under test: it loads the three skills, does the work, and returns the JSON verdict the rest of the script acts on - Sessions — a single
session_idspans the agentic run and the record written about it, so the evaluation and the improvement belong to the same episode - Skill-improvement proposals — a skill-run entry with a low
success_scoredrafts a proposal; applying it by id is what actually rewrites the skill’s procedure
What to Expect
The excerpts below are from a real run, trimmed. The script prints five numbered lines to stdout; two LiteLLM notice blocks that appeared between the first and second line during the agentic loop are elided here. The score, the feedback wording, and the text of the rewritten skill are all live LLM output and vary from run to run. Three skills go in, and the flawed one comes out with a failing score. The first line confirms the folder walk found all threeSKILL.md files. The second is the agentic run’s verdict: it singled out pr-comment-evaluator, as the task and the critic skill both steer it to, and scored it well under the 0.30 ceiling the critic sets for a tone-only evaluation.
GET /api/v1/proposals/{proposal_id} before applying it.
technical_score next to tone_score. The full rewritten procedure runs to several hundred words; only its opening is shown.
Before You Start
- Complete Quickstart to understand basic operations
- Ensure you have LLM Providers configured — the agentic pass is a live tool-calling loop and the proposal is LLM-drafted, so the score, the feedback text, and the rewritten skill differ from run to run
- Set
RECALL_WARMUP_SHORTCIRCUIT=falsein your environment before running: skills ingestion writes skill nodes without logging a graph build, so recall’s warm-up guard reads the dataset as empty and returns a warming-up marker instead of an answer, which the script cannot parse. See Recall warm-up for the variable - Run it from a checkout of the cognee repo: the script reads its three playbooks from the
skills/folder and its diff and reviewer comment from thedata/folder next to it, so a copy-pasted script has nothing to ingest - The run opens with
cognee.forget(everything=True)and does not redirect cognee’s storage roots, so it clears whatever memory the current configuration points at — run it against a scratch instance rather than storage you want to keep
How It Works
Stage 1: Ingest the Skills Folder
content_type="skills" walks the skills/ directory for SKILL.md files and stores each one as a skill scoped to toy-skill-feedback-loop — skills are always dataset-scoped, and the agentic run later needs exactly one dataset to work in. The user and dataset resolved from the returned dataset id are what the script uses to read and rewrite a skill’s body directly at the end.
Stage 2: Write the Task That Exposes the Flaw
skill_to_improve and score out of a free-text answer. It also tells the agent what a failure looks like: pr-comment-evaluator is written to judge tone only, and an evaluation that never mentions the diff’s dropped None check earns 0.30 or lower. The bundled skill-feedback-writer playbook carries the same rule, so the low score comes from the skills as much as from the prompt.
Stage 3: Run the Three Skills in One Agentic Pass
AGENTIC_COMPLETION hands the agent the three skill names and lets it pull each procedure in with the load_skill tool, up to six tool rounds. The agent sees only names and descriptions up front — the bodies arrive when it asks for them — which is why the run is a fair test of the playbooks rather than of one long prompt. datasets=DATASET_NAME keeps the scope to a single dataset, which AGENTIC_COMPLETION requires; the script’s own helpers then pull the JSON out of the answer and clamp the score into 0.0–1.0.
Stage 4: Record the Weak Run and Draft a Proposal
SkillRunEntry: which skill was used, the task it was used for, the critic’s feedback and missing instruction as the result summary, and the score as both a raw success_score and a -1.0/1.0 signal. skill_improvement is what turns that record into a rewrite — score_threshold: 0.9 means any run scoring below 0.9 is bad enough to draft against, and apply: False stops at the draft so the proposal can be inspected before it changes anything. The proposal’s id comes back among the entry’s result items.
Stage 5: Apply the Proposal and Read the Skill Back
improve_skill(..., apply=True) is what makes the loop visible: the same lookup by name, before and after the proposal is applied, over the same dataset. The before text is the flawed instruction that only judges politeness; the after text is the drafted replacement, which the critic’s missing_instruction asked to compare the reviewer comment against the concrete bug risk. Nothing here re-ingests the folder — the skill node is edited in place, so the next agentic run loads the new text.
Run It
Recall
How
AGENTIC_COMPLETION and the other search types are chosen and scoped.Remember
The operation that stores the skills folder, and everything else, in memory.
Feedback System
Rating answers in a session, the other half of cognee’s feedback loop.
Tune How Strongly Ratings Steer an Answer
The sibling demo, where feedback moves retrieval ranking instead of a playbook.