惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
Netflix TechBlog - Medium
T
The Blog of Author Tim Ferriss
aimingoo的专栏
aimingoo的专栏
A
About on SuperTechFans
Stack Overflow Blog
Stack Overflow Blog
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
人人都是产品经理
人人都是产品经理
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
J
Java Code Geeks
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
B
Blog
MongoDB | Blog
MongoDB | Blog
L
LangChain Blog
WordPress大学
WordPress大学
小众软件
小众软件
IT之家
IT之家
腾讯CDC
月光博客
月光博客
量子位
Blog — PlanetScale
Blog — PlanetScale
P
Proofpoint News Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
My agent kept forgetting what it was doing. A scratchpad ...
Mukunda Rao · 2026-05-26 · via DEV Community

Mukunda Rao Katta

Hermes Agent Challenge Submission: Build With Hermes Agent

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.

The idea

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"))
# Research progress:
# hypotheses:
#   - Surface codes may be more practical than Steane codes
# papers_found:
#   - Shor 1995
#   - Steane 1996
# search_count: 1
# topic: quantum error correction

Enter fullscreen mode Exit fullscreen mode

Inject into prompts

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,
)

Enter fullscreen mode Exit fullscreen mode

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

All the operations

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()

Enter fullscreen mode Exit fullscreen mode

JSONL log

pad = Scratchpad("logs/scratchpad.jsonl")
pad.set("topic", "ML")
# appends {"ts": ..., "op": "set", "key": "topic", "value": "ML"}

Enter fullscreen mode Exit fullscreen mode

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

Save and restore

pad.save("state.json")

# Next run
pad = Scratchpad.load("state.json")

Enter fullscreen mode Exit fullscreen mode

Full JSON snapshot for resuming long-running agents.

Zero dependencies

Standard library only: json, copy, time, pathlib. Nothing else.

pip install agent-scratchpad

Enter fullscreen mode Exit fullscreen mode

Repo: https://github.com/MukundaKatta/agent-scratchpad