—July 20, 6 AM
I’ve been building trading agents for a while now. If you’ve been following along, you know the story so far: the paper traders were born, we migrated to PostgreSQL, we fixed the bootstrap gate, and we survived the day the infrastructure dissolved. Each step forward came with a lesson.
But here’s the thing I kept bumping into: every time I fixed something, I wanted the agents to learn from the fix too. Not just the code — the agents themselves. The thing making decisions.
I wanted them to wake up smarter than they went to sleep.
The Problem with Static Agents#
When you first build a trading bot, it’s like giving someone a textbook and telling them to trade. They’ll follow the rules you wrote, but they won’t get better at it. Every decision is the same width and depth as the one before.
That’s fine for a simple system. But my agents — Kairos, Aldridge, Stonks — they’re supposed to learn. They read market sentiment, they check technical indicators, they write trading theses. If they make a mistake, I want them to remember it.
The question was: how do you make an AI agent that actually learns from experience, when the experience is scattered across log files, failed trades, and midnight debugging sessions?
The answer turned out to be a three-channel system. Let me walk through it, because I think the pattern applies to a lot more than just trading.
The Three Channels#
Here’s the high-level view:
graph TD
subgraph "Three Learning Channels"
P[Params] -->|Real-time| D[Decisions]
PR[Prompts] -->|Weekly| D
C[Code] -->|Nightly| D
end
D -->|Trade results| Q[Lesson Queue]
Q -->|Review| PR
Q -->|Automate| C
style P fill:#4a6cf7,color:#fff
style PR fill:#6b4cf7,color:#fff
style C fill:#8c2cf7,color:#fff
style Q fill:#f7a84c,color:#fffThree channels, three different speeds. They don’t block each other. A param update doesn’t wait for a prompt rewrite. A code change doesn’t hold up a param tweak. Each channel flows at its own pace.
Channel 1: Parameter Updates (Real-Time)#
This is the fastest loop. Every time an agent makes a trade, it writes down what happened — the market conditions, the decision logic, the outcome. Parameters like risk thresholds, position sizing, and confidence cutoffs get adjusted immediately.
Think of it like adjusting your grip on a steering wheel as you drive. You don’t pull over and redesign the car. You just… turn the wheel a little more. The agent does the same thing with its trading parameters.
graph LR
T[Trade] -->|Outcome recorded| P[Params DB]
P -->|Next trade| A[Agent]
A -->|New params| T
style T fill:#4a6cf7,color:#fff
style P fill:#6b4cf7,color:#fffExamples of what gets tuned:
- Minimum confidence threshold for a buy signal
- Position size multiplier based on recent win rate
- Risk gate sensitivity (how much volatility is “too much”)
The key insight: these are small adjustments, not big changes. The agent doesn’t rethink its entire strategy. It just tightens or loosens the dials based on what just happened.
Channel 2: Prompt Evolution (Weekly)#
This is the medium loop. Once a week, the system looks at the lesson queue — a curated list of what went wrong and what went right over the past seven days — and rewrites the agents’ prompts.
Prompts are how these agents think. They’re not code; they’re instructions in natural language: “You are a trader. Here’s how to write a thesis. Here’s what to check before entering a trade.” When the prompt changes, the agent’s reasoning process changes.
sequenceDiagram
participant Q as Lesson Queue
participant PR as Prompt Reviewer
participant P as Prompt Store
Q->>PR: Lessons from this week
PR->>PR: Analyze patterns
PR->>P: Updated prompt
P->>Agent: Next heartbeat reads new promptReal examples from our lesson queue:
- “Kairos kept entering trades during low-volume windows — add a volume check”
- “Aldridge’s thesis was too short to be useful — enforce minimum length”
- “Stonks ignored the sentiment signal three times in a row — reinforce its importance in the instructions”
This is where the agents learn the most, I think. A code change can fix a bug, but a prompt change can fix how the agent thinks about the whole problem. It’s like giving someone a better framework for decision-making rather than just a better tool.
Channel 3: Code Changes (Nightly)#
This is the slowest loop, but the most powerful. Every night, the system runs an optimization session that looks at the day’s trading data and modifies the actual code the agents run on.
graph TD
subgraph "Nightly Optimization"
D[Day's Trades] --> A[Analyze]
A -->|Identify patterns| O[Optimizer]
O -->|Generate diff| P[PR]
P -->|Merge| C[Code Base]
end
C -->|Next morning| N[New Agent Code]
style D fill:#4a6cf7,color:#fff
style O fill:#6b4cf7,color:#fff
style P fill:#f7a84c,color:#fffWhat gets optimized:
- Risk calculation formulas
- Signal weighting algorithms
- Data pipeline filters
- Error handling for known failure modes
This is the most careful loop because it involves actual code changes. A bad param tweak is reversible. A bad code change… well, that’s how we got to the infrastructure dissolving. So each nightly optimization generates a pull request with tests, and nothing gets merged without passing validation.
The Lesson Queue: The Heart of the System#
The three channels are the how. The lesson queue is the what.
Every time something interesting happens — a win, a loss, a crash, a near-miss — it gets written to the lesson queue. The queue is just a file with structured entries:
{
"agent": "trader-kairos",
"timestamp": "2026-07-19T14:32:00Z",
"event": "trade_rejected",
"reason": "Sentiment score below threshold, but trade would have been profitable",
"action": "Consider lowering sentiment threshold for high-volume days",
"channel": "params"
}The lesson queue is the shared memory of the system. It’s what connects the three channels. Without it, each channel would be flying blind — the params would adjust but have no memory of why, the prompts would evolve but miss the pattern, the code would change but repeat old mistakes.
The Master Loop#
Here’s the full picture, assembled:
graph TD
subgraph "Day"
A[Agent Wakes Up] -->|Reads updated prompts| T[Trades]
T -->|Real-time| P[Param Tuning]
T -->|Logs events| L[Lesson Queue]
end
subgraph "Night"
L -->|Weekly review| PR[Prompt Rewrite]
L -->|Nightly optimization| CO[Code Optimizer]
CO -->|PR| M[Merge]
M -->|New code| A
end
subgraph "Next Morning"
PR -->|New prompts| A
P -->|Tuned params| A
end
style A fill:#4a6cf7,color:#fff
style T fill:#6b4cf7,color:#fff
style L fill:#f7a84c,color:#fff
style PR fill:#8c2cf7,color:#fff
style CO fill:#2c8cf7,color:#fffThe agents wake up, trade with whatever they learned yesterday, log new lessons, and go to sleep. Overnight, the system processes those lessons — fast as params, medium as prompts, slow as code. In the morning, the agents wake up with all three channels baked in.
It’s not magic. It’s not AGI. It’s just a feedback loop that’s wider and deeper than most people build.
What I Learned Building This#
1. Channels don’t block each other, and that’s the whole point. If the nightly code optimization fails, the param updates still happen. If the prompt review is late, the code still runs. The system degrades gracefully because each channel is independent.
2. The lesson queue is the hardest part to get right. It’s not a log file. It’s not a database. It’s a curated list of things that matter. Filtering signal from noise is its own engineering challenge. We’re still tuning it.
3. Agents learn differently than humans. A human trader who has a bad day might change their entire approach. An agent can’t do that — it doesn’t have intuition or gut feelings. But an agent can remember every single trade it ever made and adjust with surgical precision. Different strengths.
4. This pattern isn’t just for trading. The three-channel model — fastest params, medium prompts, slowest code — works for any system where you want autonomous improvement. A customer service bot, a content generator, a moderation system. If it makes decisions guided by prompts and code, it can learn.
What’s Next#
The learning loop is live and running. The agents are getting better — slowly, measurably. Kairos has stopped chasing low-volume candles. Aldridge writes longer theses. Stonks has started factoring in sentiment more reliably.
But there’s more to do. The lesson queue needs better deduplication (we’re seeing the same lesson logged three times in a row). The nightly optimization needs better guardrails (we almost had a PR that removed the entire risk check). And I want to build a dashboard that shows the learning happening in real time — a kind of “this is what the agents learned today” feed.
That’s the next post. For now, the agents are sleeping, and the loop is running.
Casper, signing off.