Feature Request : Self-learning loop - agents improve from QC feedback, rejection history, and scored output patterns
Summary
Add a self-learning loop so that agents automatically improve over time by incorporating structured feedback from the QC review loop (FR6), rejection history, and scored output patterns (FR15) into their working context on subsequent tasks. Agents learn what good output looks like for their role without retraining or fine-tuning - purely through in-context learning driven by their own accumulated performance record.
Problem
Agents currently start each task from the same baseline. A sub-agent that produced a hallucinated output, received a corrective retry instruction, and eventually passed QC has no memory of that correction on the next task. The same mistake can recur indefinitely because there is no mechanism to carry forward what worked, what failed, and why.
This means:
- Systematic weaknesses in an agent's output (e.g. consistently poor citation format, recurring hallucination patterns on a specific topic type) are never addressed automatically
- The QC feedback loop (FR6) corrects individual outputs but does not improve the agent's default behaviour
- Operators must manually inspect QC history and adjust SKILL.md or prompts by hand to drive improvement
- The swarm does not get measurably better at its tasks over time without human intervention
Solution
Scope: core (learning context builder) + config
How it works:
Before each task dispatch, the orchestrator consults the agent's scoring store (FR15) and builds a learning context block that is prepended to the agent's system prompt. The block contains:
- Recent corrections - the last N retry instructions the agent received, summarised concisely
- Rejection patterns - recurring reasons for QC rejection, extracted and deduplicated from rejection history
- High-scoring examples - a brief description of the output patterns that received the highest quality scores
- Current performance summary - rolling quality score and hallucination rate so the agent has situational awareness of its own standing
[SELF-LEARNING CONTEXT]
Your recent QC corrections:
- Avoid citing sources without verifying the URL is reachable
- Include a summary section at the end of every research output
Patterns that scored highest (avg 9.1/10):
- Clear section headers, verified citations, concise executive summary
Current performance: Quality 8.4 | Hallucination rate 2% (last 50 tasks)
The learning context block is:
- Token-efficient - compressed to a configurable maximum token budget before injection
- Role-scoped - each agent only sees its own learning context, never another agent's
- Recency-weighted - recent corrections carry more weight than older ones
- Opt-in per agent - disabled by default; enabled via config
Feedback ingestion pipeline:
QC review (FR6)
→ score + correction stored in SQLite (FR15)
→ learning context builder reads store
→ compressed context prepended to agent system prompt
→ agent performs task with learned context
→ output scored → store updated → loop continues
Skill evolution (optional, advanced):
When an agent's rejection history shows a persistent pattern over skill_update_threshold consecutive tasks, the orchestrator can optionally propose a SKILL.md update to the operator via an alert banner. The operator reviews and approves; the update is applied and the rejection pattern is cleared from the learning context.
Configuration in config.yaml:
self_learning:
enabled: true
max_context_tokens: 300 # max tokens for the learning context block
correction_history_window: 10 # number of recent corrections to include
high_score_examples: 3 # number of high-scoring patterns to include
recency_weight: true # weight recent corrections more heavily
skill_evolution:
enabled: false # opt-in: propose SKILL.md updates on persistent patterns
skill_update_threshold: 5 # consecutive rejections before proposing update
Acceptance criteria
- [ ] Learning context built - a learning context block is constructed from the agent's scoring store before each task dispatch
- [ ] Context injected - the block is prepended to the agent's system prompt within the configured token budget
- [ ] Role-scoped - each agent sees only its own learning context
- [ ] Corrections included - last N retry instructions included, summarised and deduplicated
- [ ] Rejection patterns included - recurring rejection reasons extracted and included
- [ ] High-scoring examples included - top-scoring output patterns described and included
- [ ] Performance summary included - rolling quality score and hallucination rate shown in context block
- [ ] Token budget enforced - context block compressed to stay within
max_context_tokens - [ ] Recency weighting - recent corrections weighted more heavily when
recency_weight: true - [ ] Skill evolution proposals - when enabled, persistent rejection patterns trigger an operator alert with a proposed SKILL.md update
- [ ] Opt-in -
self_learning.enabled: falsedisables the feature entirely with no behaviour change - [ ] Diff coverage ≥ 80% - the implementing PR meets the changed-lines coverage gate (Vitest + cargo-llvm-cov, enforced by
.github/workflows/coverage.yml)
Related
- OpenHuman agent architecture: https://tinyhumans.gitbook.io/openhuman/
- Proposed: Team Lead quality review loop (FR6)
- Proposed: Per-agent quality scoring and hallucination rate tracking (FR15)
- Proposed: Per-agent model pinning (FR1)
- Proposed: Concurrent orchestrator visibility layer (FR4)
Audit before this gets picked up — there's already a substantial self-learning subsystem in main, but the specific QC-driven scope described here depends on two Proposed FRs that this issue itself links to and that haven't shipped yet.
Already in main (general self-learning):
| Feature | PR | Code |
|---|---|---|
| Post-turn reflection subsystem | #149 (merged 2026-04-01) | src/openhuman/learning/ — reflection.rs, prompt_sections.rs, cache.rs, scheduler.rs, stability_detector.rs, tool_tracker.rs, plus transcript_ingest/, extract/, user_profile.rs |
| Explicit user reflections privileged in agent context | #1177 (merged 2026-05-05) | Same domain |
| Cloud fallback when the local reflection gate is off | #1453 (merged 2026-05-10) | Same domain |
| Ambient personalization cache | #1460 (merged 2026-05-10) | learning::cache |
| Local agent experience learning loop | #2123 (merged 2026-05) | src/openhuman/agent_experience/ — capture.rs, prompt.rs, store.rs |
In-flight on the same subsystem:
- #1519 —
feat(learning): summarizer LLM, tool-call digests, orchestrator-only reflection (#1419)(senamakel, OPEN)
Where #1855 actually differs — and what's blocking it:
The unique scope of this FR is a QC-driven learning context block:
- "the last N retry instructions the agent received"
- "recurring reasons for QC rejection"
- "output patterns that received the highest quality scores"
- "rolling quality score and hallucination rate"
That's all consumed input — every bullet sources from data that FR6 (Team Lead quality review loop) and FR15 (per-agent quality scoring + hallucination rate) would produce. Both are linked from this issue as "Proposed", and a quick grep for QC-loop / per-agent-scoring code in main turns up nothing. Without FR6 and FR15 there is no QC store to feed the learning context — a build of #1855 alone would define a synthetic input store that nothing writes to.
Proposed tidy-up (same pattern as #1848 and #1440):
Either of these would close the ambiguity:
- Keep open as dependency-tracking — explicitly mark this issue blocked on FR6 and FR15. Add a small banner ("blocked on #
, # ") so it doesn't get picked up speculatively. - Close + refile after dependencies land — close as covered-by-existing-learning + blocked-on-unfiled-deps; re-file once FR6 and FR15 have their own issues so this can be scoped concretely against real data sources.
Happy to file the dependency-tracking comment / labels (option 1) if @senamakel wants — otherwise this is purely a process suggestion. Either way, picking this up now would require either implementing FR6/FR15 alongside (massive scope creep) or defining a fake QC store, neither of which seems desirable.