Skip to content

Commit 0d1a636

Browse files
committed
fix: wire harness config, real generalization gap, honest run status/trace (#28)
Address P0 blockers from #28: thread harness config through proposal generation/tools/prompts/stopping policy with clear errors on unsupported knobs; compute generalization gap from search vs holdout sharpe instead of a within-search formula that always returned ~0; isolate/seed reproducible_benchmark.py arms and read holdout_sharpe; stop collapsing all hypothesize events to llm_call and marking usage as zero when actually unknown; separate passed_quality_gate, budget_exhausted, no_valid_candidate, and execution_failed outcomes; persist a run manifest (data hash, config hash, seeds, candidates, fallback path, failures); reconcile README/results claims with an evidence table.
1 parent 7c18c30 commit 0d1a636

13 files changed

Lines changed: 950 additions & 170 deletions

HARNESS_EVOLUTION_RESULTS.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
1-
# Harness Evolution Results (2026-08-28)
1+
# Harness Evolution Results (2026-08-28) — UNVERIFIED LEGACY, see README Evidence Table
2+
3+
> **This document predates the generalization-gap fix and harness-config-threading work
4+
> on `fix/harness-p0-issue-28`.** The "Gap" column below was computed as
5+
> `max(avg_sharpe - best_sharpe, 0)` across in-sample search results only — it never
6+
> compared to held-out/out-of-sample performance, so it is not a real generalization
7+
> gap and should not be cited as one. It also predates the epoch harness configs
8+
> actually being threaded through `run_agent` at all (Epochs 4-6's "grid_adaptation"
9+
> and "ensemble" settings had no effect on execution when this report was produced).
10+
> Treat every number in this file as **unverified legacy** per the README's Evidence
11+
> Table, not as measured historical results. To regenerate a trustworthy version of
12+
> this report, run `python3 scripts/harness_evolution_6_epochs.py` on the current
13+
> branch and cite the resulting `results.json` + `experiments/run_manifests/*.json`.
214
315
## Executive Summary
416

517
This is an archived development report for a six-epoch manual progression and experimental optimizer comparisons. The GA/DE comparison uses a mock fitness function, and the recorded claim-accuracy values are placeholders rather than measured forecast accuracy.
618

7-
**Result: +37.4% Sharpe improvement** (0.452 → 0.621)
19+
**Result: +37.4% Sharpe improvement** (0.452 → 0.621) — in-sample search Sharpe only; no holdout comparison was performed for this report.
820

921
---
1022

README.md

Lines changed: 53 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -102,70 +102,26 @@ Most trading agent frameworks are static parameter-tuning tools. **AgentQuant is
102102

103103
---
104104

105-
## Live Results (2026-08-28)
106-
107-
### 6-Epoch Harness Evolution
108-
109-
Starting from a baseline grid-search agent, we evolved the harness through 6 progressive improvements:
110-
111-
| Epoch | Harness | Sharpe | Improvement | What Changed |
112-
|-------|---------|--------|-------------|--------------|
113-
| 1 | **v1_base** | 0.452 || Baseline (grid search only) |
114-
| 2 | **v2_tool_aware** | 0.523 | +15.7% | ✅ Tools & web search enabled |
115-
| 3 | **v3_prompt_tuned** | 0.541 | +19.7% | ✅ LLM prompt refined |
116-
| 4 | **v4_grid_evolved** | 0.572 | +26.5% | ✅ Parameter grid adapted to winners |
117-
| 5 | **v5_multi_agent** | 0.589 | +30.3% | ✅ Ensemble voting added |
118-
| 6 | **v6_research**| 0.621 | **+37.4%** | ✅ Research agent adds new proposal behavior |
119-
120-
**Key validations:**
121-
-**Generalization gap reduced 61%** (0.124 → 0.048) — improvements are real, not artifacts
122-
-**Tool efficiency increased 8x** (0 → 8 calls/epoch)
123-
- ℹ️ **Claim accuracy is not reported** — the current harness records claims but does not yet evaluate numerical Sharpe forecasts against realized outcomes
124-
125-
### Algorithm Comparison
126-
127-
Compared manual evolution against experimental evolutionary optimizers on the same mock fitness function. These figures are a development benchmark, not backtest results.
128-
129-
```
130-
Manual Evolution (Hand-crafted) ⭐ 0.621 (+37.4%) Domain knowledge wins
131-
Genetic Algorithm (20×5) → 0.594 (+35.6%) Only 2.7% behind, faster
132-
Differential Evolution (20×5) → 0.571 (+28.3%) Struggles with discrete decisions
133-
Random Baseline (Control) → 0.465 (+12.9%) All beat random 5-33x
134-
```
135-
136-
**Development observation:** In this mock-fitness benchmark, the hand-crafted configuration scored higher than the experimental optimizers. This is not evidence of live or historical trading performance.
137-
138-
### Evolution Visualization
139-
140-
<div style="text-align: center; margin: 30px 0; padding: 20px; background: #0a0e27; border: 2px solid #00d9ff; border-radius: 8px;">
141-
<strong style="color: #00ff88;">🎬 WATCH THE 6-EPOCH EVOLUTION UNFOLD</strong><br>
142-
<a href="https://claude.ai/code/artifact/a297e886-911e-4f06-bdf4-bbbb3890888b" target="_blank" style="display: inline-block; margin-top: 10px; padding: 12px 24px; background: #00d9ff; color: #0a0e27; text-decoration: none; border-radius: 4px; font-weight: bold; font-size: 16px;">
143-
⚡ Launch Dark-Themed Interactive Dashboard
144-
</a>
145-
<p style="margin-top: 10px; font-size: 12px; color: #888;">Live animated visualization with epoch progression & algorithm benchmarks</p>
146-
</div>
147-
148-
The evolution journey across 6 epochs:
149-
150-
```
151-
v1_base (0.452)
152-
↓ +15.7%
153-
v2_tool_aware (0.523)
154-
↓ +4.0%
155-
v3_prompt_tuned (0.541)
156-
↓ +6.8%
157-
v4_grid_evolved (0.572)
158-
↓ +3.0%
159-
v5_multi_agent (0.589)
160-
↓ +5.4%
161-
v6_research ⭐ (0.621) [+37.4% total]
162-
```
163-
164-
**Key Results:**
165-
- 📈 **Sharpe Improvement:** +37.4% (0.452 → 0.621)
166-
- 🎯 **Generalization Gap:** -61% (0.124 → 0.048)
167-
- 🔧 **Tool Integration:** 8x increase in tool calls per epoch
168-
- ℹ️ **Claim validation:** recorded for analysis; numerical forecast accuracy is not yet reported
105+
## Evidence Table
106+
107+
Numbers in this repo come from three tiers of evidence that must not be conflated.
108+
Regenerate this table with `scripts/harness_evolution_6_epochs.py` (fixture/measured
109+
historical rows) and `scripts/reproducible_benchmark.py` (fixture/demo rows); each
110+
run writes a manifest under `experiments/run_manifests/` and a results JSON that
111+
this table should link back to.
112+
113+
| Tier | What it means | Example | Source (command / file) |
114+
|------|---------------|---------|--------------------------|
115+
| **Fixture / demo** | Deterministic synthetic price paths, offline, no API keys. Useful for testing wiring (config threading, holdout mechanics), not for judging strategy quality. | `reproducible_benchmark.py` 1-vs-3-iteration holdout Sharpe comparison | `python3 scripts/reproducible_benchmark.py --output results/reproducible_benchmark.json` |
116+
| **Measured historical experiment** | Real OHLCV history (yfinance), an actual `run_agent`/epoch execution, with in-sample search Sharpe reported separately from held-out Sharpe. Still a single historical window, not a claim about future/live performance. | 6-epoch harness evolution runs, each producing a `HarnessConfig` hash + run manifest | `python3 scripts/harness_evolution_6_epochs.py --strategy momentum --output results.json` |
117+
| **Unverified legacy** | Numbers that appeared in earlier revisions of this README/results docs without an attached command, manifest, or seed. Treat as anecdotal until reproduced; do not cite as validation. | Prior "Live Results" table (removed) | none — this is exactly the gap this section replaces |
118+
119+
**What the code actually measures today, and what it doesn't:**
120+
- ✅ Search-set Sharpe and holdout-set Sharpe are reported separately (`agent_graph.holdout_eval_node`); the generalization gap is `search_sharpe - holdout_sharpe` on the *same* winning proposal, and is reported as `unavailable` (not 0.0) when no holdout evaluation ran.
121+
- ✅ Run outcome is one of `passed_quality_gate`, `budget_exhausted`, `no_valid_candidate`, or `execution_failed` — "we ran out of iterations and kept the best guess" is never reported as having passed the quality gate.
122+
- ✅ GA/DE optimizer comparisons (see `docs/EVOLUTIONARY_HARNESS_OPTIMIZATION.md`) use a **mock fitness function**, not real backtests — treat any GA/DE numbers as algorithm-search behavior, not trading performance.
123+
- ❌ There is no calibrated numerical Sharpe-forecast-accuracy metric yet; falsifiable claims are recorded as text, not scored against realized outcomes.
124+
- ❌ "Tool calls per epoch" is a raw count, not an efficiency ratio; a change in tool-call count alone is not evidence of an efficiency improvement and should not be reported as one (the previous "8x efficiency" framing has been removed for this reason).
169125

170126
### UI & Dashboards
171127

@@ -215,11 +171,11 @@ graph TD
215171
```
216172

217173
**Implemented Features:**
218-
-**Tool Orchestration** — Claude reasons over market context, web search, and research
219-
- **Multi-Agent Ensemble**Tool-based, grid search, and random proposals voted together
220-
-**Walk-Forward Validation**Train/validation/test splits prevent overfitting
174+
-**Tool Orchestration** — Claude reasons over market context, web search, and research; a resolved, versioned harness config gates tool admission (disabling tools yields zero tool-orchestrator calls) and prompt content
175+
- 🧪 **Multi-Agent Ensemble**Planned (epochs 5-6 in the harness sequence); the runtime currently rejects a harness config that requests ensemble voting (`use_ensemble=True`) with an explicit `UnsupportedHarnessKnobError` rather than silently ignoring it, since it is not wired through yet
176+
-**Walk-Forward Validation**A trailing holdout window is carved out before the search loop runs and is scored exactly once (`holdout_eval_node`), separate from in-sample search Sharpe
221177
-**Memory Persistence** — Learns which strategies work in which market regimes
222-
-**Falsifiable Claims**Tracks prediction accuracy (86% validated)
178+
-**Falsifiable Claims**Proposals record a written, falsifiable claim and confidence score; numerical Sharpe-forecast accuracy against realized outcomes is not yet computed or reported (no accuracy percentage should be cited until that scoring exists)
223179

224180
---
225181

@@ -263,22 +219,26 @@ graph TD
263219
The system itself evolves across epochs:
264220

265221
```
266-
Epoch 1: Start with grid search
267-
↓ (Analyze results: tools could help)
268-
Epoch 2: Enable tools + Claude reasoning
269-
↓ (Analyze results: need to refine prompt)
270-
Epoch 3: Tune prompt based on v2 learnings
271-
↓ (Analyze results: focus on winning parameters)
272-
Epoch 4: Adapt grid to high-performers
273-
↓ (Analyze results: ensemble improves robustness)
274-
Epoch 5: Add multi-agent voting
275-
↓ (Analyze results: need novel ideas)
276-
Epoch 6: Deploy research agent
277-
278-
RESEARCH HARNESS: 0.621 Sharpe, 61% gap reduction
222+
Epoch 1: Grid search only (use_tools=False) -- implemented
223+
Epoch 2: Enable tools + Claude reasoning (use_tools=True) -- implemented
224+
Epoch 3: Tune prompt based on v2 learnings (prompt_template changed) -- implemented
225+
Epoch 4: Adapt grid to high-performers (grid_adaptation_strategy) -- NOT wired: runtime raises
226+
Epoch 5: Add multi-agent voting (use_ensemble=True) -- NOT wired: runtime raises
227+
Epoch 6: Deploy research agent (prompt_template + ensemble) -- prompt change only
279228
```
280229

281-
Each epoch's config is saved. The latest research harness is `v6_research.json`.
230+
Epochs 1-3 change agent behavior through the resolved harness config (tool admission and
231+
prompt content). Epochs 4-6 as originally specified also requested grid adaptation and
232+
ensemble voting; those knobs are not implemented in the runtime yet, so
233+
`resolve_effective_config` raises `UnsupportedHarnessKnobError` for them rather than
234+
silently no-opping. Run `scripts/harness_evolution_6_epochs.py` to see this: it catches
235+
the error, records it in the epoch checkpoint's `config_error` field, and re-runs that
236+
epoch with only the supported knobs so the comparison table still has a number for every
237+
epoch -- but the epoch-over-epoch Sharpe delta for epochs 4-6 should not be read as
238+
evidence that grid adaptation or ensemble voting help, since neither actually ran.
239+
240+
Each epoch's config (requested and effective, with a content hash) is saved in the
241+
run's output JSON and in `experiments/run_manifests/<run_id>.json`.
282242

283243
---
284244

@@ -386,9 +346,12 @@ Interactively run the agent on chosen date ranges and assets.
386346
- `HARNESS_EVOLUTION_RESULTS.md` — Full analysis + findings
387347

388348
### Evolved Harnesses
389-
- `.harness/v6_research.json`**Latest research harness** (Sharpe 0.621)
390-
- `.harness/v_ga_optimal.json` — GA-optimized (Sharpe 0.594)
391-
- `.harness/v_de_optimal.json` — DE-optimized (Sharpe 0.571)
349+
Sharpe figures for saved harness configs are tied to a specific historical run and
350+
seed; see the Evidence Table above and the run manifest referenced by each result
351+
file before citing a number from here.
352+
- `.harness/v6_research.json` — Latest research harness config (requested + effective settings)
353+
- `.harness/v_ga_optimal.json` — GA-optimized on the mock fitness function (not a backtest result)
354+
- `.harness/v_de_optimal.json` — DE-optimized on the mock fitness function (not a backtest result)
392355

393356
### Documentation
394357
- `docs/TOOL_INTEGRATION_GUIDE.md` — Tool orchestration system
@@ -400,7 +363,7 @@ Interactively run the agent on chosen date ranges and assets.
400363
### Tests
401364
```bash
402365
pytest tests/
403-
# 63 tests covering:
366+
# 82 tests covering (count as of this branch; re-run `pytest tests/ -q` to reconfirm):
404367
# - Agent loop correctness
405368
# - Backtest metrics (hand-verified against numpy)
406369
# - Regime detection
@@ -489,7 +452,10 @@ MIT — Use freely, modify as needed, mention if you find bugs.
489452
🔄 **Beta roadmap** — Research agent, multi-objective optimization
490453
⚠️ **Not yet production** — Backtest results don't guarantee live returns
491454

492-
**Latest:** 6-epoch evolution complete (+37.4% Sharpe, 61% gap reduction). v6_research harness ready for testing.
455+
**Latest:** Harness config threading, run-status separation (`passed_quality_gate` / `budget_exhausted` /
456+
`no_valid_candidate` / `execution_failed`), and a real search-vs-holdout generalization gap are implemented
457+
and covered by tests (see Evidence Table above). Epoch-over-epoch Sharpe deltas from a specific historical
458+
run are reported in that run's manifest/results JSON, not as a standing README claim.
493459

494460
---
495461

0 commit comments

Comments
 (0)