Install
openclaw skills install self-improving-agent-proLocal skill for capturing learnings, errors, corrections, and patterns to enable continuous agent improvement. Processes events locally in your OpenClaw agent without external API calls. Returns structured insights, suggested rules, and batch summaries. Provided by Claw0x.
openclaw skills install self-improving-agent-proLocal skill by Claw0x — Turn your agent's mistakes into systematic improvements. Every error, correction, and learning becomes a structured insight with auto-generated rules.
Runs locally in your OpenClaw agent. No external API calls, no API key required. Complete privacy — your learning data never leaves your machine.
| When This Happens | Log As | What You Get |
|---|---|---|
| API call fails | error | Retry rule with timeout adjustment |
| User corrects output | correction | Format/style rule based on delta |
| Discover new pattern | learning | Best practice for similar tasks |
| Same issue repeats | Batch log | Systemic fix recommendations |
| Command times out | error | Timeout + retry strategy |
| Wrong assumption | learning | Updated knowledge rule |
Why local processing? Complete privacy, zero latency, works offline, no API costs.
openclaw skill add self-improving-agent
const result = await agent.run('self-improving-agent', {
type: 'error',
context: 'payment-api.ts',
detail: 'ETIMEDOUT after 30s'
});
{
"entries": [{
"severity": "high",
"tags": ["network", "timeout", "payment"],
"actionable_insight": "Error detected in payment-api.ts: ETIMEDOUT after 30s. Consider adding error handling or input validation for this scenario.",
"suggested_rule": "WHEN operating in payment-api.ts THEN guard against: ETIMEDOUT after 30s"
}]
}
// Add to your agent config
agent.addRule("Set 10s timeout for payment API. Retry once on ETIMEDOUT.");
Done. Your agent just learned from its mistake — all processed locally.
This skill provides a structured event processing pipeline for agent self-improvement. It runs entirely locally in your OpenClaw agent — no external API calls, no data transmission.
Event classification — each incoming event is classified by type (error, correction, learning, pattern). If no severity is provided, it's auto-inferred based on the event type and content keywords.
Auto-tagging — the skill scans the context and detail fields for known patterns and applies tags automatically. For example:
[network], [timeout].ts file gets tagged [typescript][resilience]Insight generation — for each event, the skill generates an actionable_insight — a one-sentence summary of what the agent should do differently. For corrections, this compares the previous_attempt with the corrected_output to identify the delta.
Rule suggestion — each event produces a suggested_rule — a concrete, implementable rule the agent could add to its system prompt or configuration. Example: "When calling external APIs, set a 10s timeout and retry once on ETIMEDOUT."
Batch analysis (for multi-event submissions) — when you send an events array, the skill also produces:
Traditional software logs errors and a human reads them later. Autonomous agents need to process their own failures in real time and adapt. This skill provides the structured feedback loop:
Agent runs → Error occurs → Log to self-improving-agent → Get insight + rule → Agent updates behavior
The skill is stateless by design — it doesn't accumulate history across calls. If you need persistent memory, store the returned entries in your own database and feed historical context back in future calls.
| Type | When to Use | Example |
|---|---|---|
error | Something failed unexpectedly | API returned 500, file not found, parse error |
correction | User or supervisor fixed agent output | Agent used tabs, user said use spaces |
learning | Agent discovered something new | "This API requires auth header in a specific format" |
pattern | Recurring behavior worth codifying | "Users always ask for JSON output, not XML" |
None. This skill runs locally in your OpenClaw agent. No API key, no external dependencies, no configuration needed.
Just install and use:
openclaw skill add self-improving-agent
Problem: Your agent keeps failing when calling external APIs
Solution:
Example:
try {
await paymentAPI.charge(amount);
} catch (error) {
const insight = await agent.run('self-improving-agent', {
type: 'error',
context: 'payment-api.ts',
detail: error.message
});
// Apply: "Set 10s timeout. Retry once on ETIMEDOUT."
await agent.updateConfig(insight.entries[0].suggested_rule);
}
Problem: Users frequently correct your agent's output format
Solution:
Example:
async function onUserCorrection(previous, corrected, context) {
const result = await agent.run('self-improving-agent', {
type: 'correction',
context: context,
previous_attempt: previous,
corrected_output: corrected
});
// Apply rule to agent memory
agent.memory.addRule(result.entries[0].suggested_rule);
}
Problem: Your agent makes the same mistakes repeatedly
Solution:
Example:
const events = recentErrors.map(e => ({
type: 'error',
context: e.context,
detail: e.message
}));
const result = await agent.run('self-improving-agent', { events });
// result.summary.patterns_detected: ["auth-service.ts appeared 40 times"]
// Fix auth-service.ts once, eliminate 40 errors
Problem: Managing learnings across 10+ agent instances
Solution:
// In your agent's error handler
agent.onError(async (error, context) => {
const result = await agent.run('self-improving-agent', {
type: 'error',
context: context.file,
detail: error.message
});
// Apply suggested rule
if (result.entries[0].suggested_rule) {
await agent.addRule(result.entries[0].suggested_rule);
console.log('✓ Rule applied:', result.entries[0].suggested_rule);
}
});
# Install via OpenClaw skill system
# Then use in your LangChain agent
def on_user_correction(previous, corrected, context):
result = openclaw.run("self-improving-agent", {
"type": "correction",
"context": context,
"detail": "User corrected output",
"previous_attempt": previous,
"corrected_output": corrected
})
# Store in agent memory
agent.memory.add_rule(result["entries"][0]["suggested_rule"])
return result["entries"][0]["actionable_insight"]
async function logLearning(type, context, detail) {
const result = await agent.run('self-improving-agent', {
type,
context,
detail
});
return result.entries[0];
}
// Use in your agent
try {
await riskyOperation();
} catch (error) {
const insight = await logLearning('error', 'riskyOperation', error.message);
console.log('Insight:', insight.actionable_insight);
console.log('Rule:', insight.suggested_rule);
// Store for later review
await db.learnings.create(insight);
}
// Collect events throughout the day
const events = [];
agent.onError((error, ctx) => {
events.push({ type: 'error', context: ctx.file, detail: error.message });
});
agent.onCorrection((prev, corrected, ctx) => {
events.push({
type: 'correction',
context: ctx.file,
detail: 'User corrected output',
previous_attempt: prev,
corrected_output: corrected
});
});
// Process batch at end of day
async function dailyReview() {
const result = await agent.run('self-improving-agent', { events });
console.log('Summary:', result.summary);
// {
// by_severity: { high: 12, medium: 8, low: 5 },
// top_tags: [{ tag: 'network', count: 15 }, { tag: 'auth', count: 10 }],
// patterns_detected: ["payment-api.ts appeared 8 times"],
// recommendations: ["Multiple high-severity events — consider systematic review"]
// }
// Apply top rules
for (const entry of result.entries.filter(e => e.severity === 'critical')) {
await agent.addRule(entry.suggested_rule);
}
}
| Field | Type | Required | Description |
|---|---|---|---|
type | string | yes | "error", "correction", "learning", or "pattern" |
context | string | yes | Where it happened (file, module, function) |
detail | string | yes | What happened |
severity | string | no | "low", "medium", "high", "critical" (auto-inferred if omitted) |
tags | string[] | no | Manual tags (auto-tags are also added) |
previous_attempt | string | no | What the agent originally produced (for corrections) |
corrected_output | string | no | What the correct output should be (for corrections) |
| Field | Type | Required | Description |
|---|---|---|---|
events | array | yes | Array of event objects (same fields as single event) |
| Field | Type | Description |
|---|---|---|
entries | array | Processed events with id, severity, tags, actionable_insight, suggested_rule |
summary | object | Batch summary (null for single events): by_type, by_severity, top_tags, patterns_detected, recommendations |
Single error input:
await agent.run('self-improving-agent', {
type: 'error',
context: 'api-client.ts',
detail: 'ETIMEDOUT after 30s calling payment API'
});
Output:
{
"entries": [{
"id": "sia_abc123",
"type": "error",
"severity": "high",
"tags": ["network", "timeout", "payment"],
"actionable_insight": "Error detected in api-client.ts: ETIMEDOUT after 30s calling payment API. Consider adding error handling or input validation for this scenario.",
"suggested_rule": "WHEN operating in api-client.ts THEN guard against: ETIMEDOUT after 30s calling payment API"
}]
}
The skill throws standard JavaScript errors for invalid input:
| Feature | Cloud API (Claw0x Gateway) | Local Skill (This) |
|---|---|---|
| Setup Time | 2 min (get API key) | 30 sec (install skill) |
| Privacy | Data sent to cloud | Data stays local ✅ |
| Offline | ❌ Requires internet | ✅ Works offline |
| Latency | 50-200ms (network) | <1ms (local) ✅ |
| Cost | Free (but requires account) | Free (no account) ✅ |
| Multi-Agent | Centralized analytics | Manual aggregation |
| Persistence | You control | You control |
Note: Claw0x also offers a cloud version of this skill at claw0x.com/skills/self-improving-agent for users who need centralized analytics.
┌─────────────────────────────────────────────────────────────┐
│ Your AI Agent │
└─────────────────────────────────────────────────────────────┘
│
├─ Task Execution
│
┌───────────┴───────────┐
│ │
✅ Success ❌ Error/Correction
│ │
│ ├─ Log Locally
│ │ agent.run('self-improving-agent', ...)
│ │
│ ├─ Get Insights
│ │ {severity, tags,
│ │ actionable_insight,
│ │ suggested_rule}
│ │
│ └─ Apply Rule
│ agent.addRule(...)
│
└─ Continue
Claw0x is the native skills layer for AI agents — providing both local skills (like this one) and cloud APIs for agent capabilities.
Explore more skills:
Why Claw0x?