How to Architect a Self-Improving Agent With Hermes and Claude Code
For AI agent builders and developers · Based on Lewis Jackson Self-Improving Trading Agent Framework
// TL;DR
AI agent builders can use the Lewis Jackson Self-Improving Trading Agent Framework as a reference architecture for closing a real feedback loop instead of shipping static bots. The system pairs a oneshot Claude Code prompt with the Hermes self-learning brain, a structured trade ledger, and Railway hosting to run the scientific method continuously: observe outcome, score toward-goal or away-from-goal, hypothesize, change one variable, promote the winner. Use it when you want to study or replicate a disciplined self-improvement loop, understand single-variable attribution, and see how read-only gating protects live actions before an agent gains write access.
Why is single-variable iteration the core architectural decision?
Most self-improving agent attempts fail because they optimize many parameters at once and lose attribution. The Lewis Jackson framework enforces one variable per cycle deliberately. If you change several things and performance improves, you cannot know which change caused it, so the gain doesn't compound reliably. By constraining Hermes to a single variable per iteration, every result is traceable, promotable, and durable. As a builder, this is the pattern worth stealing: clean learning signal beats fast but untraceable optimization.
How does the scientific-method loop map to agent design?
The loop is explicit: Hermes assembles outcomes, analyzes whether they moved toward or away from a well-defined goal, forms a hypothesis about why, forms a second hypothesis about what to change, applies exactly one change, observes, and promotes the winning version to the new baseline. This maps cleanly onto an agent architecture with a scoring function (score weights), a persistent state (the Hermes-readable ledger), a hypothesis generator, and a controlled mutation step. The goal's polarity — toward-goal versus away-from-goal — is the reward signal that orients everything.
What role does the goal definition play in the architecture?
The well-defined goal is the backbone. It includes both a success definition (target return, Sharpe floor) and a failure definition (max drawdown, minimum return floor). Without both, the loop has no direction. The framework even sanity-checks goals against starting capital and flags impossible targets, which is a useful guardrail pattern: validate that your objective is reachable before spending compute chasing it. For any self-improving agent you build, encode success and failure as measurable thresholds, not vibes.
Why gate the first cycle as read-only?
Read-only gating is a safety pattern every builder should adopt. The first Hermes cycle observes, scores, and writes a markdown analysis but touches nothing live. The human reviews it to confirm the agent correctly understood the strategy and goals, then explicitly grants write access by editing the Hermes trading strategy YAML. This separates 'the agent understands its task' from 'the agent may act on production,' preventing a misconfigured loop from managing real capital. It's a clean human-in-the-loop checkpoint before autonomy.
How does the oneshot prompt improve reproducibility?
The oneshot prompt collapses environment detection, strategy onboarding, scaffolding, cloud deployment, and Hermes installation into one copy-paste fed to Claude Code. From an engineering standpoint, this is reproducible provisioning: the same prompt yields the same guided phases, reducing configuration drift. Critically, the prompt itself is versioned and iterated on community feedback in the 01 Systems resource, so newer versions supersede older ones. Treat setup prompts as living, versioned artifacts rather than static scripts baked into a video.
How do I handle multiple agents without corrupting signals?
If you run a secondary agent alongside Hermes — for example Cornelius — offset their review cadences. The framework defaults Hermes to a weekly cycle with a 3-day offset from any secondary agent specifically to prevent simultaneous conflicting parameter updates. Concurrent writes to shared strategy state would corrupt the single-variable discipline. As a builder, treat cadence offsetting and write isolation as first-class concerns in any multi-agent self-improvement system.
What's the next step for a builder?
Study the loop end to end by running it once: define measurable success and failure thresholds, pull the latest oneshot prompt from 01 Systems, run it through Claude Code, and inspect how Hermes scaffolds the ledger, gates read-only, and mutates one variable per cycle. Then abstract the pattern — scoring function, persistent ledger, single-variable mutation, read-only gating — into your own agent projects.
// FREQUENTLY ASKED QUESTIONS
Can I adapt this loop to non-trading agents?
The underlying pattern generalizes well: a scoring function tied to a measurable goal, a persistent ledger of outcomes, single-variable mutation, read-only gating before write access, and cadence offsetting for multiple agents. Trading is the domain here, but the scientific-method loop and attribution discipline apply to any agent that should improve from its own outcomes.
How does Hermes maintain state between cycles?
Hermes reads from a structured trade ledger generated during Phase 3 scaffolding, which converts historical trades into a parseable format. It owns portfolio mechanics and score weights, and each cycle it writes updated strategy iterations. The strategy document is the persistent source of truth; winning versions replace the baseline, so state evolves with proven improvements.
Why use Railway rather than my own infrastructure?
Railway provides simple 24/7 cloud hosting with CLI integration, satisfying the reliability requirement that execution never depends on a local machine. Its CLI pushes strategy updates automatically without manual redeployment. You can substitute your own infrastructure, but you must preserve the same guarantee: continuous execution and automated update deployment independent of any developer's machine.