P0: Fix strategy config schema mismatch (backtesting broken) #25

Closed
opened 2026-04-09 07:11:41 +02:00 by shoko · 0 comments
Owner

Problem

The LLM outputs a nested params structure, but the backtest and simulation engines expect flat fields. This is a complete pipeline break - AI-parsed strategies will never trigger any trades.

Current Flow

LLM Output:     { type: "price_drop", params: { token: "PEPE", threshold_percent: 5 } }
Validator:      Expects params.threshold_percent
Engines:        Look for flat threshold -> Returns 0, conditions never trigger
Frontend:       Uses flat structure { token, threshold }

Schema Comparison

Component Token Field Threshold Field
LLM Output params.token params.threshold_percent
Validator params.token params.threshold_percent
Backtest/Simulate Engines token (flat) threshold (flat)
Frontend Types token threshold

Solution

Flatten LLM output to match what engines and frontend expect. This avoids having to update engines and frontend which are harder to change safely.

Target Schema

{
  "conditions": [
    {
      "type": "price_drop",
      "token": "PEPE",
      "chain": "bsc",
      "threshold": 5,
      "timeframe": "1h"
    }
  ],
  "actions": [...],
  "risk_management": {...}
}

Acceptance Criteria

  • LLM connector outputs flat structure
  • Validator validates flat structure
  • Backtest engine correctly reads conditions
  • Simulate engine correctly reads conditions
## Problem The LLM outputs a **nested `params`** structure, but the backtest and simulation engines expect **flat fields**. This is a complete pipeline break - AI-parsed strategies will never trigger any trades. ### Current Flow ``` LLM Output: { type: "price_drop", params: { token: "PEPE", threshold_percent: 5 } } Validator: Expects params.threshold_percent Engines: Look for flat threshold -> Returns 0, conditions never trigger Frontend: Uses flat structure { token, threshold } ``` ### Schema Comparison | Component | Token Field | Threshold Field | |-----------|-------------|-----------------| | LLM Output | `params.token` | `params.threshold_percent` | | Validator | `params.token` | `params.threshold_percent` | | Backtest/Simulate Engines | `token` (flat) | `threshold` (flat) | | Frontend Types | `token` | `threshold` | ## Solution Flatten LLM output to match what engines and frontend expect. This avoids having to update engines and frontend which are harder to change safely. ### Target Schema ```json { "conditions": [ { "type": "price_drop", "token": "PEPE", "chain": "bsc", "threshold": 5, "timeframe": "1h" } ], "actions": [...], "risk_management": {...} } ``` ## Acceptance Criteria - [ ] LLM connector outputs flat structure - [ ] Validator validates flat structure - [ ] Backtest engine correctly reads conditions - [ ] Simulate engine correctly reads conditions
shoko closed this issue 2026-04-09 09:32:50 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shoko/randebu#25