Skip to main content

Crucible — Player-Coach

An adversarial quality loop for LLM-based trading decisions.

Player-Coach Demo

▶ Live dashboard · ▶ Watch the demo · PyPI


A PlayerAgent proposes trading actions; a CoachAgent evaluates every proposal mechanically against a formal constraint schema and rejects with a specific critique if any constraint is violated. The Player revises and resubmits for up to three rounds. The result is a structured artifact — every proposal, rejection, revision, and approval recorded, validated, and queryable.


Installation

# Core infrastructure
pip install player-coach-core

# With LLM agents
pip install player-coach-core[llm]

# With Streamlit dashboard
pip install player-coach-core[dashboard]

Requires ANTHROPIC_API_KEY for LLM agents.


Dashboard

A five-page Streamlit app for running and reviewing player-coach exchanges.

Live demo: https://crucible-player-coach.streamlit.app

streamlit run dashboard/app.py

Trade Review — Run a live exchange. Player and Coach characters animate with streaming speech bubbles. Round cards show proposals, verdicts, violations, and critique.

Constraints — Configure the Coach's constraint schema. Load presets, adjust sliders, export JSON, or push directly to the Trade Review page.

History — Browse past exchanges from SQLite. Filter by outcome. Select any row to inspect rounds and replay with animation.

Settings — BYOK API key entry and validation. Key lives in session memory only, never stored.

Backtest — Compare two constraint presets over historical data side by side. Approval rate, average rounds, days aborted, total return, and max drawdown with winner highlighted per metric.


API key and database

API key: The dashboard uses a bring-your-own-key model. Enter your Anthropic API key in the Settings page. The key is stored in session memory only — it is never written to disk, logged, or shared between users. Each browser session is fully isolated.

Database: All exchanges are written to a shared SQLite database on the Streamlit Cloud instance. The History page shows exchanges from all users of the live demo. For private use, run the dashboard locally:

git clone https://github.com/MaverickHQ/crucible-player-coach
pip install player-coach-core[dashboard]
streamlit run dashboard/app.py

Constraint schema

{
  "max_position_pct": 0.15,
  "max_single_trade_pct": 0.05,
  "max_leverage": 1.5,
  "max_drawdown_pct": 0.10,
  "max_daily_loss_pct": 0.02,
  "consistency_rule_pct": 0.50,
  "trading_cutoff_time": "16:20",
  "allowed_symbols": ["AMZN", "MSFT", "TSLA", "BTC-USD"],
  "max_open_positions": 3,
  "min_risk_reward": 1.5,
  "max_rounds": 3,
  "abort_on_violations": ["max_leverage", "max_drawdown_pct"]
}

Five presets in examples/constraints/: conservative, moderate, aggressive, strict, futures_compatible.


Running locally

from player_coach.agents.player import PlayerAgent
from player_coach.agents.coach import CoachAgent
from player_coach.artifacts.writer import ArtifactWriter
from player_coach.constraints.schema import ConstraintSchema
from player_coach.loop.coach_loop import CoachLoop
import json
from pathlib import Path

constraints = ConstraintSchema.from_dict(
    json.loads(Path("examples/constraints/moderate.json").read_text())
)

loop = CoachLoop(
    player=PlayerAgent(),
    coach=CoachAgent(),
    artifact_writer=ArtifactWriter("artifacts"),
)

artifact = loop.run(
    world_state={
        "symbol": "AMZN", "price": 185.0,
        "sma5": 183.0, "sma10": 180.0,
        "volume": 45_000_000, "position": "flat",
        "volatility_regime": "medium", "session": "NY_open",
    },
    constraints=constraints,
)

print(f"Outcome: {artifact['outcome']}")
print(f"Rounds:  {artifact['rounds_taken']}")

Essays

Each essay is paired with a working implementation.

# Title Link
8 The Adversarial Quality Loop Read →
9 Building the Player-Coach Loop Read →
10 Closing the Evidence Loop Coming soon
11 The Quality of Reasoning Coming soon

Part of the Executable World Models series on harveygill.substack.com.


Demo

Player-Coach Demo

▶ Full demo video


Architecture

Component Role
PlayerAgent Proposes 1–3 actions given world state. Claude Haiku, max_tokens=1024.
CoachAgent Evaluates proposals against constraint schema. max_tokens=1024.
CoachLoop Orchestrates exchange. Up to 3 rounds. Writes artifact to disk and SQLite.
circuit_breakers MLL, daily loss limit, consistency rule, trading cutoff — pure functions.
ConstraintDeriver Derives constraint schema from ewm-core evidence policy.
BacktestRunner Replays CoachLoop over historical trading days via yfinance.
DatabaseStore SQLite persistence for exchanges, rounds, strategies, portfolio snapshots.

Circuit breakers

Four hard stops checked before every round, in priority order:

  1. MLL breached — peak drawdown exceeded, account terminated
  2. Daily loss limit — today's loss too large, skip today
  3. Consistency rule — today's gain exceeds fraction of cumulative, skip today
  4. Trading cutoff — market hours ended, skip today

Repo What
crucible-ewm Observable agent trajectories, evidence policy, ewm-core
beyond-tokens Constrained LLM planning on AWS Bedrock

Project status

v1.1.0 — complete. Backend, dashboard, tests, and PyPI package all shipped.

Backlog: AWS AgentCore deployment — PlayerAgent and CoachAgent as separate Lambda functions, Step Functions orchestration, artifacts to S3.

Release files for player-coach-core 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for player-coach-core 2.0.1
File Interpreter ABI Platform
player_coach_core-2.0.1-py3-none-any.whl Python 3 none any Details

Release files / player_coach_core-2.0.1-py3-none-any.whl

Download URL player_coach_core-2.0.1-py3-none-any.whl
Size 67.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8e5d6ab9fe3dd74aa2b99c3dfca9250ec49f12a6299ab8f64fbf87e66ad9c2b4
BLAKE2b-256 checksum
How to use checksums
54747e5aa296f510a89f196eca0442e8307ddcc7ac55d1acdb5ac27476f0d2d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release history Release notifications | RSS feed

This release

2.0.1 This release

1 release file

2.0.0

1 release file

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page