Self-improvement (Basal Ganglia)
asyncat watches your tool patterns and auto-creates skills — without any manual annotation.
How it works
The Basal Ganglia is a passive learning engine that runs during every agent session. It records the sequence of tools used in each session, hashes those sequences to detect recurring patterns, and — once a pattern has succeeded enough times — auto-generates a named skill that the agent can load in future sessions.
The process is entirely invisible. You don't label anything. You don't configure triggers. The agent just gets better the more you use it.
# Session 1: you debug a React component
read_file → code_search → edit_file → run_tests → run_command
# Session 2: same sequence, different component
read_file → code_search → edit_file → run_tests → run_command
# Session 3: again
read_file → code_search → edit_file → run_tests → run_command
# Basal Ganglia fires:
skill created: react-component-debug
weight: 0.8 · brain_region: basal_ganglia · origin: basal-ganglia
The new skill is stored in SQLite and appears in the Skills browser under created_by: basal-ganglia. It gets injected into future agent runs whenever the goal context matches.
Pattern rules
| Parameter | Value | Notes |
|---|---|---|
| Minimum successes to trigger | 3 | Failed runs don't count toward creation |
| Pattern window | 72 hours | Patterns older than 72h are expired |
| Loop detection | Normalized hash | Same tools in different order = same pattern |
| Quality score | success − (failure × 2) | Negative scores suppress skill injection |
| Corrections stored | Up to 10 | User corrections modify the pattern metadata |
Pattern hashing normalizes tool order so that read_file → edit_file → run_tests and read_file → run_tests → edit_file are treated as the same pattern. This prevents duplicates from minor ordering variations.
Skill creation
When a pattern hits the threshold, the Basal Ganglia generates the skill body in one of two ways:
- LLM-assisted (if a provider is configured) — sends the tool sequence to the model and asks it to write a structured skill document explaining when and how to apply the pattern.
- Mechanical template (fallback) — generates a skill stub from the tool list and basic metadata. Less descriptive, but functional.
Every auto-generated skill has:
name— derived from the dominant tools in the patternbrain_region: basal_gangliaweight: 0.8— slightly below bundled skills to prevent accidental overridecreated_by: basal-ganglia— distinguishes from bundled and user-created skillstags— extracted from the tool categories in the pattern
The agent emits a skill_suggested event when a skill is created — visible in the Agent Run Feed in the UI.
Corrections
User corrections (via the feedback system — thumbs down, correction text, or direct edits) are stored against the pattern in SQLite. Up to 10 corrections per pattern are kept.
When the agent encounters the same pattern again, it loads the correction history alongside the skill. This "what not to do" context is injected before execution, so past mistakes are remembered without the agent re-learning them the hard way.
# Example correction stored against pattern hash abc123:
{
"pattern_hash": "abc123",
"correction": "Don't restart the service — check the config first",
"created_at": "2025-05-10T14:32:00Z"
} Configuration
Self-improvement is enabled by default. To disable it, go to Settings → Agent → Self-Improvement in the web UI and toggle it off.
You can also view all auto-generated skills in the Skills browser (/skills) by filtering by origin: basal-ganglia, and delete or edit any skill that isn't useful.