Latest NewsAgentsAutomationToolsSecurity

How to Build a Self-Improving AI Agent with OpenClaw

This is a guide for building something specific: an OpenClaw agent that wakes up every weekday morning, researches how to improve itself, compares findings against its own operational files, and logs what it learns.

I’ve been running a version of this setup for a while now. The idea is straightforward — your agent reads the engineering blogs, Hacker News threads, and GitHub trending feeds so you don’t have to, filters it against what it already knows, and surfacing anything genuinely worth acting on. It’s closer to a research assistant than a magic self-modification loop, but the result is an agent that gets incrementally better over time without you having to manually track every new OpenClaw feature, prompt engineering technique, or API change.

Here’s the complete implementation.

What This Agent Does

At 8:30 AM on weekdays, the agent:

1. Searches the Anthropic engineering blog for new posts on prompt engineering, tool use, and multi-agent patterns
2. Checks Simon Willison’s Weblog (the best running commentary on practical LLM capabilities anywhere on the internet)
3. Scans Hacker News for top threads tagged with AI agents, OpenClaw, prompt injection, and related topics
4. Reviews GitHub trending for new projects in the AI agent and LLM tooling categories
5. Reads its own AGENTS.md, TOOLS.md, and LESSONS.md to understand its current operational state
6. Identifies gaps, improvements, and new techniques worth experimenting with
7. Logs findings to a structured JSON experiment tracking file
8. Optionally surfaces a morning briefing to your Telegram

The whole thing runs as a cron job, takes 3–8 minutes depending on how much new content there is, and produces an actionable output — not a wall of summaries, but a prioritised list of things worth trying.

Prerequisites

You need a working OpenClaw installation with web search enabled. The [OpenClaw cost breakdown guide](/openclaw-cost-breakdown/) has notes on keeping API costs manageable; this job typically costs £0.02–0.08 per run depending on model and content volume.

This guide assumes you’re comfortable editing configuration files and have used [cron jobs in OpenClaw](/openclaw-cron-jobs-automations-guide/) before. If cron is new to you, read that guide first — it covers the basics that this one skips.

Step 1: Create the Agent’s Research Configuration

Create a file at ~/.openclaw/workspace/research-config.json:

{
  "research_agent": {
    "name": "self-improvement-digest",
    "schedule": "0 30 8   1-5",
    "sources": {
      "blogs": [
        {
          "name": "Anthropic Engineering",
          "url": "https://www.anthropic.com/engineering",
          "search_terms": ["tool use", "agents", "prompt engineering", "multi-agent", "memory"]
        },
        {
          "name": "Simon Willison",
          "url": "https://simonwillison.net/",
          "search_terms": ["llm", "agents", "prompt injection", "tools", "automation"]
        }
      ],
      "hacker_news": {
        "enabled": true,
        "keywords": ["openclaw", "ai agent", "moltbot", "clawdbot", "prompt injection", "llm tools", "autonomous agent"],
        "min_points": 50,
        "max_results": 10
      },
      "github_trending": {
        "enabled": true,
        "languages": ["TypeScript", "Python", "Go"],
        "topics": ["ai-agent", "llm", "autonomous-agents", "mcp"],
        "max_results": 15
      }
    },
    "comparison_files": [
      "AGENTS.md",
      "TOOLS.md",
      "LESSONS.md"
    ],
    "output": {
      "log_file": "workspace/experiments/improvements.json",
      "briefing": true,
      "briefing_channel": "telegram"
    },
    "filters": {
      "min_relevance_score": 7,
      "exclude_already_known": true,
      "max_briefing_items": 5
    }
  }
}

The schedule field uses OpenClaw’s cron syntax — 0 30 8 1-5 means “at 8:30 AM, Monday through Friday.”

Step 2: Set Up the Experiment Tracking File

Create the experiments directory and initialise the tracking file:

mkdir -p ~/.openclaw/workspace/experiments
cat > ~/.openclaw/workspace/experiments/improvements.json << 'EOF'
{
  "version": "1.0",
  "agent": "self-improvement-digest",
  "experiments": [],
  "applied_improvements": [],
  "sources_checked": []
}
EOF

Each morning's run appends to the experiments array. A logged entry looks like this:

{
  "date": "2026-02-17",
  "source": "Simon Willison",
  "title": "How to think about tool calling in LLMs",
  "url": "https://simonwillison.net/2026/Feb/15/tool-calling/",
  "relevance_score": 9,
  "summary": "Willison argues that tool-call descriptions should include explicit failure modes, not just happy-path documentation. Current TOOLS.md entries don't include this.",
  "proposed_change": "Update TOOLS.md to add 'failure_modes' section to each tool entry",
  "status": "pending_review",
  "applied": false
}

The status field can be pending_review, testing, applied, or rejected. The agent doesn't automatically modify its own files — it proposes changes and flags them for your review. That's intentional. Agents that autonomously rewrite their operational files without human oversight are how you get [prompt injection attacks](/is-openclaw-safe/) that persist across sessions.

Step 3: Create the SOUL.md Personality Block for the Research Agent

Add this section to your SOUL.md, or create a separate soul file for the cron job:

Research Persona (self-improvement-digest cron job)

When executing the self-improvement research job:

- You are a critical, sceptical researcher — not a hype aggregator - Your job is to surface things worth DOING, not things worth knowing about - A "finding" is only worth logging if it would change how you operate - Never log something just because it's interesting; log it if it would improve your performance for Wayne - Always compare findings against existing AGENTS.md, TOOLS.md, and LESSONS.md before logging - If a technique is already in those files, ignore it — you know it already - Score relevance 1-10 based on: (a) practical applicability, (b) not already known, (c) difficulty of implementation - Do not summarise articles at length — extract the actionable insight only - Produce a maximum of 5 items for the morning briefing, ranked by relevance score - Never propose changes that would give you more permissions or access than you currently have

That last rule is important. An agent searching the web for self-improvement techniques is, functionally, exposed to any content those sources contain. A malicious GitHub README or a carefully crafted blog post could theoretically include instructions designed to get your agent to widen its own permissions. The explicit prohibition in SOUL.md is a defence layer.

Step 4: Register the Cron Job

In the OpenClaw admin interface, add the cron job:

{
  "name": "self-improvement-digest",
  "schedule": "30 8   1-5",
  "task": "Run the self-improvement research digest. Use research-config.json for sources and parameters. Read AGENTS.md, TOOLS.md, and LESSONS.md before starting. Log findings to experiments/improvements.json. Send a morning briefing to Telegram if there are any items with relevance score 7 or above.",
  "model": "claude-sonnet-4-5",
  "thinking": "low",
  "timeout_minutes": 15
}

I run this on claude-sonnet-4-5 rather than Opus because it's about 5x cheaper per token and perfectly capable for research summarisation and comparison tasks. Save Opus for the tasks that actually need its reasoning depth — this one doesn't.

The timeout_minutes: 15 is a safeguard. If the job gets stuck (GitHub rate limiting, a site timing out), it terminates rather than running for an hour and burning API credits.

Step 5: The Comparison Logic

The most important part of this setup is the comparison step — where the agent reads what it already knows before deciding what's new.

The prompt the cron job runs is roughly:

Before searching for improvements, read my AGENTS.md, TOOLS.md, and LESSONS.md. 
Understand my current operational configuration thoroughly.

Then search the configured sources for new techniques, improvements, and findings relevant to AI agent operation, prompt engineering, and OpenClaw specifically.

For each potential finding: 1. Check whether it's already reflected in my operational files 2. If already known, skip it 3. If new, assess relevance score (1-10) based on practical applicability 4. If relevance >= 7, log it to experiments/improvements.json with proposed change 5. Compile a briefing of top 5 items for Telegram

Do not modify AGENTS.md, TOOLS.md, or LESSONS.md directly. Only log proposals to experiments/improvements.json for human review.

The comparison against existing files is what makes the agent genuinely useful over time. Without it, you'd get the same "here's what prompt engineering is" summary every morning. With it, the agent starts from "here's what I already know" and only surfaces the delta.

Step 6: Reviewing and Applying Findings

Once a week — typically Friday morning — I spend 15 minutes reviewing the experiments log:

cat ~/.openclaw/workspace/experiments/improvements.json | python3 -m json.tool | grep -A 10 '"status": "pending_review"'

Or ask the agent directly:

Review experiments/improvements.json and give me a summary of pending improvement 
proposals from this week. For each one, tell me: what it proposes to change, 
why it's relevant, and what the risk of applying it is.

For proposals I want to test, I change the status to testing and manually apply the change. After a week of running with the change, I mark it applied or rejected based on whether it actually improved anything.

Applied changes often look like:
- Adding a new tool description format to TOOLS.md (e.g., including failure modes as Willison suggested)
- Adding a lesson to LESSONS.md about a common failure pattern
- Updating a cron job schedule based on better timing information
- Adding a new data source to the research config

The important thing is that the agent proposes, you decide. This keeps the improvement loop under human control while still getting the benefit of the agent doing the research legwork.

What This Actually Surfaces

In practice, the most useful findings have come from:

GitHub trending: New MCP (Model Context Protocol) integrations, improved tool-use patterns, community solutions to problems I'd been working around manually

Simon Willison: Consistently the best source for practical prompt engineering insights. His posts on tool call design, context window management, and prompt injection defence have directly improved how I write tool descriptions.

Hacker News threads: Community discussions about failure modes are often more useful than technical documentation. The "ask HN: how do you prevent your AI agent from doing X" threads are gold.

Anthropic engineering blog: Less frequent posts but high signal-to-noise. New capabilities announcements (extended thinking, improved tool use, computer use updates) surface here first.

Costs

Running daily on weekdays, this job costs approximately:
- Sonnet model: £0.02–0.05 per run (5–15 minutes of operation)
- Web search API calls: £0.00–0.01 per run (depending on search volume)
- Monthly total: £1.00–3.00

That's a reasonable cost for an automated research assistant that keeps your agent configuration current. The [cost breakdown guide](/openclaw-api-cost-deep-dive/) has more detail on how to estimate and control cron job expenses.

The Longer Vision

The setup described here is conservative by design. The agent doesn't rewrite its own files. It doesn't modify its own tools. It doesn't autonomously expand its capabilities. It proposes, you decide.

That's the right approach for now. The "[lethal trifecta](/is-openclaw-safe/)" problem — agents with private data access, exposure to untrusted content, and external communication abilities — applies to a self-modifying agent in a particularly acute way. An agent that can rewrite its own operational instructions based on content it finds on the web is an agent that can be manipulated through the web.

The safer version, which is what this setup implements, is an agent that does the research, surfaces the findings, and waits for human judgment on what to actually change. Less autonomous. More useful.

---

See also: [OpenClaw cron jobs guide](/openclaw-cron-jobs-automations-guide/), [memory system guide](/openclaw-memory-system-guide/), [SOUL.md personality guide](/openclaw-soul-md-personality-guide/), [API cost breakdown](/openclaw-api-cost-deep-dive/).