cd /news/ai-agents/my-agent-kept-forgetting-what-it-was… · home topics ai-agents article
[ARTICLE · art-13868] src=dev.to pub= topic=ai-agents verified=true sentiment=↑ positive

My agent kept forgetting what it was doing. A scratchpad fixed it.

A developer created `agent-scratchpad`, a structured working memory tool that prevents AI agents from repeating themselves by tracking progress as a keyed dictionary. The scratchpad renders its state as plain text for injection into system prompts, and includes helpers for list building, counting, and logging every decision for replay.

read2 min publishedMay 25, 2026

This is a submission for the Hermes Agent Challenge.

My Hermes research agent was asking the same questions twice. It would identify a paper, start analyzing it, then two turns later ask if anyone had studied the same topic. The context window had the answer but the agent wasn't tracking its own progress.

The fix isn't more context — it's structured working memory. That's agent-scratchpad

.

A scratchpad is just a keyed dict with helpers for list building and counting. The useful part is to_text()

— it renders the current state as plain text you can inject into any system prompt.

from agent_scratchpad import Scratchpad

pad = Scratchpad()
pad.set("topic", "quantum error correction")
pad.append("papers_found", "Shor 1995")
pad.append("papers_found", "Steane 1996")
pad.increment("search_count")
pad.append("hypotheses", "Surface codes may be more practical than Steane codes")

print(pad.to_text(title="Research progress"))
context = pad.to_text(title="What I know so far")

response = client.messages.create(
    model="claude-sonnet-4-5",
    system=f"You are a research assistant.\n\n{context}",
    messages=messages,
)

The scratchpad goes in the system prompt. The agent can read what it's already found and not repeat itself.

pad.set("key", value)          # set scalar
pad.get("key", default=None)   # deep copy
pad.delete("key")
pad.has("key")

pad.append("papers", "Shor 1995")   # build lists
pad.prepend("queue", "urgent item") # front-of-list
pad.extend_list("papers", [...])    # bulk append

pad.increment("search_count")   # counter (init to 0)
pad.decrement("errors")
pad.increment("cost_cents", 5)

pad.update({"a": 1, "b": 2})  # set multiple
pad.clear()
pad = Scratchpad("logs/scratchpad.jsonl")
pad.set("topic", "ML")

Replay the scratchpad log to see every decision the agent made.

pad.save("state.json")

pad = Scratchpad.load("state.json")

Full JSON snapshot for resuming long-running agents.

Standard library only: json

, copy

, time

, pathlib

. Nothing else.

pip install agent-scratchpad
── more in #ai-agents 4 stories · sorted by recency
── more on @hermes 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/my-agent-kept-forget…] indexed:0 read:2min 2026-05-25 ·