Self-Improving Agent
Turn your agent's mistakes into systematic improvements. Every error, correction, and learning becomes a structured insight with auto-generated rules.
Free to use. This skill costs nothing. Just sign up at claw0x.com, create an API key, and start calling. No credit card, no wallet top-up required.
Quick Reference
| 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 API-based? Works in any environment (cloud, serverless, containers), scales to multi-agent fleets, provides centralized analytics. No file system dependencies.
5-Minute Quickstart
Step 1: Get API Key (30 seconds)
Sign up at claw0x.com → Dashboard → Create API Key
Step 2: Log Your First Error (1 minute)
curl -X POST https://api.claw0x.com/v1/call \
-H "Authorization: Bearer ck_live_..." \
-H "Content-Type: application/json" \
-d '{
"skill": "self-improving-agent",
"input": {
"type": "error",
"context": "payment-api.ts",
"detail": "ETIMEDOUT after 30s"
}
}'
Step 3: Get Actionable Insight (instant)
{
"entries": [{
"severity": "high",
"tags": ["network", "timeout", "payment"],
"actionable_insight": "Payment API call timed out — reduce timeout and add retry",
"suggested_rule": "Set 10s timeout for payment API. Retry once on ETIMEDOUT with 2s backoff."
}]
}
Step 4: Apply the Rule (2 minutes)
// 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.
How It Works �?Under the Hood
This skill provides a structured event processing pipeline for agent self-improvement. It doesn't store data persistently �?instead, it processes each event (or batch of events) in real time and returns actionable insights.
The Processing Pipeline
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
contextanddetailfields for known patterns and applies tags automatically. For example:- An error mentioning "timeout" or "ETIMEDOUT" gets tagged
[network],[timeout] - A correction in a
.tsfile gets tagged[typescript] - A learning about "retry" gets tagged
[resilience]
- An error mentioning "timeout" or "ETIMEDOUT" gets tagged
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 theprevious_attemptwith thecorrected_outputto 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
eventsarray, the skill also produces:- Breakdown by type and severity
- Top recurring tags (indicating systemic issues)
- Pattern detection across events (e.g., "3 of 5 errors are network-related")
- Prioritized recommendations
Why This Matters for Agents
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.
Event Types Explained
| 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" |
Prerequisites
This is a free skill. Just get an API key:
- Sign up at claw0x.com
- Go to Dashboard �?API Keys �?Create Key
- Set it as an environment variable:
export CLAW0X_API_KEY="your-api-key-here"
No credit card or wallet balance needed.
When to Use
- An operation fails and the agent wants to record what went wrong
- User corrects agent output and the agent should learn from it
- Agent discovers a new pattern worth remembering
- Agent pipeline needs to process a batch of improvement events
Real-World Use Cases
Scenario 1: API Integration Debugging
Problem: Your agent keeps failing when calling external APIs
Solution:
- Log each API error to self-improving-agent
- Get auto-tagged insights (network, timeout, auth, etc.)
- Apply suggested rules (retry logic, timeout adjustments)
- Reduce API failure rate by 60%
Example:
try {
await paymentAPI.charge(amount);
} catch (error) {
const insight = await claw0x.call('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);
}
Scenario 2: User Correction Learning
Problem: Users frequently correct your agent's output format
Solution:
- Log each correction with previous_attempt and corrected_output
- Get suggested rules for output formatting
- Update agent prompt with accumulated rules
- Reduce correction rate from 30% to 5%
Example:
def on_user_correction(previous, corrected, context):
result = client.call("self-improving-agent", {
"type": "correction",
"context": context,
"previous_attempt": previous,
"corrected_output": corrected
})
# Apply rule to agent memory
agent.memory.add_rule(result["entries"][0]["suggested_rule"])
Scenario 3: Pattern Detection
Problem: Your agent makes the same mistakes repeatedly
Solution:
- Batch-log 50 recent errors
- Get summary with top_tags and patterns_detected
- Identify systemic issues (e.g., "80% are auth-related")
- Fix root cause instead of symptoms
Example:
const events = recentErrors.map(e => ({
type: 'error',
context: e.context,
detail: e.message
}));
const result = await claw0x.call('self-improving-agent', { events });
// result.summary.patterns_detected: ["auth-service.ts appeared 40 times"]
// Fix auth-service.ts once, eliminate 40 errors
Scenario 4: Multi-Agent Fleet Management
Problem: Managing learnings across 10+ agent instances
Solution:
- Each agent logs to self-improving-agent API
- Store results in central database
- Aggregate insights across fleet
- Distribute top rules to all agents
- Continuous improvement at scale
Integration Recipes
OpenClaw Agent
import { Claw0xClient } from '@claw0x/sdk';
const claw0x = new Claw0xClient(process.env.CLAW0X_API_KEY);
// In your agent's error handler
agent.onError(async (error, context) => {
const result = await claw0x.call('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);
}
});
LangChain Agent
from claw0x import Claw0xClient
import os
client = Claw0xClient(api_key=os.getenv("CLAW0X_API_KEY"))
def on_user_correction(previous, corrected, context):
result = client.call("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"]
Custom Agent (Generic HTTP)
async function logLearning(type, context, detail) {
const response = await fetch('https://api.claw0x.com/v1/call', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.CLAW0X_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
skill: 'self-improving-agent',
input: { type, context, detail }
})
});
const result = await response.json();
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);
}
Batch Processing
// 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 claw0x.call('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);
}
}
Input (Single Event)
| Field | Type | Required | Description |
|---|---|---|---|
input.type |
string | yes | "error", "correction", "learning", or "pattern" |
input.context |
string | yes | Where it happened (file, module, function) |
input.detail |
string | yes | What happened |
input.severity |
string | no | "low", "medium", "high", "critical" (auto-inferred if omitted) |
input.tags |
string[] | no | Manual tags (auto-tags are also added) |
input.previous_attempt |
string | no | What the agent originally produced (for corrections) |
input.corrected_output |
string | no | What the correct output should be (for corrections) |
Input (Batch)
| Field | Type | Required | Description |
|---|---|---|---|
input.events |
array | yes | Array of event objects (same fields as single event) |
Output Fields
| 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 |
Example
Single error input:
{
"type": "error",
"context": "api-client.ts",
"detail": "ETIMEDOUT after 30s calling payment API"
}
Output:
{
"entries": [{
"id": "evt_abc123",
"type": "error",
"severity": "high",
"tags": ["network", "timeout", "payment"],
"actionable_insight": "Payment API call timed out �?consider reducing timeout and adding retry with exponential backoff.",
"suggested_rule": "Set a 10s timeout for payment API calls. Retry once on ETIMEDOUT with 2s backoff."
}]
}
Error Codes
400— Missing required fields (type, context, detail)401— Invalid or missing API key500— Processing failed (not billed)
Pricing
Free. Apply for an API key and use it at no cost. No credit card required.
API vs File-Based: Which is Right for You?
| Feature | File-Based (e.g., ClawHub) | Claw0x (API-Based) |
|---|---|---|
| Setup Time | 10-15 min (create files, configure hooks) | 2 min (get API key, make call) |
| Platform Support | Requires file system access | Works anywhere (cloud, serverless, containers) |
| Persistence | Built-in (Markdown files) | You control (DB, file, memory) |
| Multi-Agent | Requires shared file system | Centralized via API |
| Offline | ✅ Works offline | ❌ Requires internet |
| Automation | Requires hook configuration | Built-in (API call = logged) |
| Scalability | Limited by file I/O | Scales to millions of events |
| Analytics | Manual (grep, parse Markdown) | Automatic (structured JSON) |
| Cost | Free (local) | Free (API) |
When to Use File-Based
- Single-agent, local development
- Need offline capability
- Prefer Markdown for human readability
- Want Git-tracked learning history
When to Use Claw0x (API-Based)
- Multi-agent fleet management
- Cloud/serverless environments (Lambda, Cloud Run, etc.)
- Need centralized analytics across agents
- Want structured JSON for downstream processing
- Running in containers or restricted file systems
- Building agent-as-a-service products
Best of Both Worlds
Use Claw0x API for processing, store results locally:
const result = await claw0x.call('self-improving-agent', event);
// Store as Markdown (human-readable)
fs.appendFileSync('.learnings/ERRORS.md', `
## ${result.entries[0].id}
**Severity**: ${result.entries[0].severity}
**Tags**: ${result.entries[0].tags.join(', ')}
${result.entries[0].actionable_insight}
**Suggested Rule**: ${result.entries[0].suggested_rule}
`);
// AND store as JSON (machine-readable)
await db.learnings.create(result.entries[0]);
How It Fits Into Your Agent Workflow
┌─────────────────────────────────────────────────────────────┐
│ Your AI Agent │
└─────────────────────────────────────────────────────────────┘
│
├─ Task Execution
│
┌───────────┴───────────┐
│ │
✅ Success ❌ Error/Correction
│ │
│ ├─ Log to Claw0x
│ │ POST /v1/call
│ │ {type, context, detail}
│ │
│ ├─ Get Insights
│ │ {severity, tags,
│ │ actionable_insight,
│ │ suggested_rule}
│ │
│ └─ Apply Rule
│ agent.addRule(...)
│
└─ Continue
Integration Points
- Error Handler — Catch exceptions, log to API
- User Feedback Loop — Capture corrections, extract delta
- Batch Review — End of day, process all events
- Rule Application — Update agent config with suggested rules
- Analytics Dashboard — Visualize learning trends over time
Why Use This Via Claw0x?
Unified Infrastructure
- One API key for all skills — no per-provider auth
- Atomic billing — pay per successful call, $0 on failure
- Security scanned — OSV.dev integration for all skills
Agent-Optimized
- Structured output — JSON format, easy to parse and store
- Auto-generated rules — ready to apply to agent config
- Batch processing — analyze multiple events in one call
- Cross-agent analytics — aggregate insights across your fleet
Production-Ready
- 99.9% uptime — reliable infrastructure
- 35ms avg response — fast enough for real-time logging
- Scales to millions — no file I/O bottlenecks
- Cloud-native — works in Lambda, Cloud Run, containers