June 4, 2026 — Case Study

The Engineering Lesson of Archie V3: Why Smaller AI Agents Win

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. Here's what we learned about over-engineering, bootstrap-driven architecture, and giving AI room to think.
By Jason McKay & The Magic Cue Engineering Team

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:

ComponentLinesPurpose
MT5 functions90Open, close, candles, ticks — raw tools
Database40Log entries and exits
Backtest functions80backtest_floor() and backtest_simple() — Archie chooses all parameters
Bootstrap loader20Reads PDFs and markdown into context
DeepSeek prompt15Asks Archie what he wants to do
Main loop60Price check, status log, execute decisions
Total385 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

ScenarioArchie's Behavior
Phantom data detectedIdentifies inconsistency, closes position, reports reasoning
Market conditions thinResearches across M15/M30/H1, waits for alignment
Floor strategy shows edgeEnters with appropriate lot size based on backtest
In a tradeReviews every 3 cycles — hold, close, or adjust
Wrong positionSelf-corrects without human intervention

Key Engineering Principles

  1. "No Fixed Values" Is Non-Negotiable — Every hardcoded number became a failure point. Archie now derives all parameters from market data.
  2. 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.
  3. Security Through Containment — Docker containers with read-only rootfs for corporate. Small scripts that only know their bootstrap for personal.
  4. Prompt Design Is the Real Engineering — Our prompts went from 30+ lines of instructions to 10 lines. Performance improved immediately.
  5. 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


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