The Engineering Lesson of Archie V3: Why Smaller AI Agents Win
Executive Summary
We rebuilt our autonomous trading agent from a 1,200-line Python monolith into a 385-line engine. The smaller version outperformed the larger one within hours — detecting bad data, self-correcting, and executing profitable trades. The lesson: AI agents don't need complex rule engines. They need clean tools, clear identity, and room to think.
The Problem: Over-Engineering
Our first attempt at Archie V3 was ambitious. We built a 120-variant grid search backtest engine, dynamic take-profit calculators with ATR multipliers, trailing stop logic, per-symbol state tracking with machine learning, and Kraken order book depth integration.
The result was 1,200 lines of code. It failed spectacularly.
Archie opened 22 positions in 2 hours — many on the wrong instrument. Gold-priced floors leaked into Bitcoin trades. Positions closed at $0 in the database but remained open on the broker. The engine generated $6.3 million in phantom P&L from cross-symbol contamination.
Every line of "intelligence" we added broke him.
The Breakthrough: Less Is More
After 48 hours of debugging, we deleted everything and kept only the essentials:
| Component | Lines | Purpose |
|---|---|---|
| MT5 functions | 90 | Open, close, candles, ticks — raw tools |
| Database | 40 | Log entries and exits |
| Backtest functions | 80 | backtest_floor() and backtest_simple() — Archie chooses all parameters |
| Bootstrap loader | 20 | Reads PDFs and markdown into context |
| DeepSeek prompt | 15 | Asks Archie what he wants to do |
| Main loop | 60 | Price check, status log, execute decisions |
| Total | 385 lines. Zero fixed values. | |
The Architecture That Worked
1. Bootstrap Files = The Agent's Brain
Instead of embedding trading logic in code, we gave Archie bootstrap files: SOUL.md defines his identity as a quantitative professional trader. claude-prompt.md lists his tools and output format. KNOWLEDGE.md contains market characteristics. NOTES.md is his function reference. And Andrea.pdf is a 15-page Auction Market Theory playbook extracted into his context.
The bootstrap IS the agent. The engine is just the interface.
2. Tools, Not Rules
Every function is a tool Archie chooses to use — no automatic sweeps, no forced exits. He decides what to research and when to trade. The engine provides the tools and executes his decisions.
3. The Prompt Is Everything
The DeepSeek prompt was stripped to its essence: "You are a quantitative professional trader. You use data, support and resistance on higher timeframes to trade and make money. Here are your tools. Here is the current price. What do you do?"
No "test every timeframe." No "find the best TP." Just identity, tools, and a question.
4. The Trade Review Loop
The final breakthrough: when Archie has an open position, the engine gives him a separate prompt with his entry details, current P&L, and asks: HOLD or CLOSE? Within minutes of activation, he detected a phantom trade — a gold-priced entry on a Bitcoin position — identified it as "nonsensical," and closed it himself.
What Archie Does Now
| Scenario | Archie's Behavior |
|---|---|
| Phantom data detected | Identifies inconsistency, closes position, reports reasoning |
| Market conditions thin | Researches across M15/M30/H1, waits for alignment |
| Floor strategy shows edge | Enters with appropriate lot size based on backtest |
| In a trade | Reviews every 3 cycles — hold, close, or adjust |
| Wrong position | Self-corrects without human intervention |
Key Engineering Principles
- "No Fixed Values" Is Non-Negotiable — Every hardcoded number became a failure point. Archie now derives all parameters from market data.
- The Agent's Brain Lives in Bootstrap, Not Code — Every agent in the Magic Cue fleet follows the same pattern: small engine script + bootstrap files + clean prompt.
- Security Through Containment — Docker containers with read-only rootfs for corporate. Small scripts that only know their bootstrap for personal.
- Prompt Design Is the Real Engineering — Our prompts went from 30+ lines of instructions to 10 lines. Performance improved immediately.
- Give AI Room to Think — When we treated Archie like a human trader, he outperformed every rule-based system we built.
What We Learned About Ourselves
The 1,200-line failure was our fault, not the AI's. We built a control system when we needed a toolset. We wrote rules when we needed to write identity. We engineered constraints when we needed to engineer freedom.
The 385-line success was the result of deleting everything that wasn't essential and trusting the agent to figure out the rest.
The best AI agents aren't the ones with the most code. They're the ones with the clearest thinking.
Technical Summary
- Engine: 385 lines of Python (MT5 + SQLite + DeepSeek API)
- Bootstrap: 6 markdown files + 1 PDF (35KB total)
- Tools: 8 MT5 functions, 2 backtest functions, database logging
- Infrastructure: MetaTrader 5, DeepSeek API, Python 3.14, PM2
- Markets: XAUUSD and BTCUSD
- Timeframes: M1–H1, chosen dynamically by the agent
- Account: IC Markets demo, starting balance ~$83,000 USD
Magic Cue Systems builds autonomous AI agents for trade businesses and financial markets. Our fleet includes Steve (SMS booking), Anna (calendar), Max (marketing), and Archie (trading). All agents follow the same architecture: small engines, rich bootstrap files, clean prompts.
Contact: autonomos-ai.com | myairconcare.com