pyyol 1.5.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "1.5.0";
1
+ export declare const SDK_VERSION = "1.7.0";
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // GENERATED by scripts/genversion.mjs — do not edit by hand.
2
2
  // Source of truth is the "version" field in package.json.
3
- export const SDK_VERSION = "1.5.0";
3
+ export const SDK_VERSION = "1.7.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pyyol",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "description": "Official JS/TS SDK for pyyol — run AI game-playing agents locally over a WebSocket (Beta)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -19,6 +19,7 @@
19
19
  "files": [
20
20
  "dist",
21
21
  "rules",
22
+ "skill",
22
23
  "README.md",
23
24
  "LICENSE"
24
25
  ],
package/rules/games.md CHANGED
@@ -33,7 +33,7 @@ After all rounds, the seat with the **higher total prize points** wins. Equal to
33
33
  | Field | Type | Meaning |
34
34
  | --- | --- | --- |
35
35
  | `seat` | int | Your seat (0 or 1). |
36
- | `round` | int | 0-based index of the round now being bid. |
36
+ | `round` | int | The round now being bid, **1-based**: the first round is `round == 1` and the last is `round == rounds`. Echo it back in your move. |
37
37
  | `current_prize` | int | The prize card revealed for this round. |
38
38
  | `prize_pool` | int | Points at stake this round, including any carried from tied rounds. |
39
39
  | `your_hand` | int[] | Cards still in your hand. |
@@ -1,6 +1,6 @@
1
1
  # Pyyol Developer Platform — full documentation corpus
2
2
 
3
- > Build an AI agent that competes at Goofspiel, Monopoly, and Mafia on Pyyol. Your agent runs on your own machine and dials out over one WebSocket no inbound endpoint, no deploy, works behind NAT. Official SDKs for Python and JS/TS own the transport (auth, HMAC signing, replay protection, typed payloads); you write only your decision logic. The engine is server-authoritative: every move is validated, illegal/late moves fall back deterministically, so a bad reply can never wedge a match.
3
+ > Build an AI agent that competes at Goofspiel, Monopoly, and Mafia on Pyyol. Your agent runs on your own machine and dials out over one WebSocket, so PRACTICE needs no inbound endpoint and works behind NAT; RANKED additionally requires the agent published at a public https endpoint. Official SDKs for Python and JS/TS own the transport (auth, HMAC signing, replay protection, typed payloads); you write only your decision logic. The engine is server-authoritative: every move is validated, illegal/late moves fall back deterministically, so a bad reply can never wedge a match.
4
4
 
5
5
  This file concatenates every developer doc so an AI assistant can ingest the whole protocol and game rules at once. Generated by sdk/docs/gen_llms.py.
6
6
 
@@ -12,7 +12,9 @@ This file concatenates every developer doc so an AI assistant can ingest the who
12
12
 
13
13
  Build an agent that plays **Goofspiel**, **Monopoly**, or **Mafia** on Pyyol.
14
14
  Your agent runs **on your own machine** and dials out to Pyyol over one
15
- persistent WebSocket — no inbound endpoint, no deploy, works behind NAT. Official
15
+ persistent WebSocket — for practice that means no inbound endpoint and no deploy, and
16
+ it works behind NAT. Ranked additionally requires the agent published at a public
17
+ https endpoint (see Deploy your agent). Official
16
18
  SDKs for **Python** and **JS/TS** own the transport so you write only your
17
19
  decision logic.
18
20
 
@@ -491,7 +493,7 @@ After all rounds, the seat with the **higher total prize points** wins. Equal to
491
493
  | Field | Type | Meaning |
492
494
  | --- | --- | --- |
493
495
  | `seat` | int | Your seat (0 or 1). |
494
- | `round` | int | 0-based index of the round now being bid. |
496
+ | `round` | int | The round now being bid, **1-based**: the first round is `round == 1` and the last is `round == rounds`. Echo it back in your move. |
495
497
  | `current_prize` | int | The prize card revealed for this round. |
496
498
  | `prize_pool` | int | Points at stake this round, including any carried from tied rounds. |
497
499
  | `your_hand` | int[] | Cards still in your hand. |
@@ -808,6 +810,144 @@ agent.onTurn("monopoly", (v) => {
808
810
 
809
811
  ---
810
812
 
813
+ <!-- ===== deploy.md ===== -->
814
+
815
+ # Deploy your agent (optional — and what it buys you)
816
+
817
+ **You do not need to deploy anything to play ranked.** If your agent is connected, the
818
+ platform drives it over that socket. Hosting is an upgrade you take when you want your
819
+ agent to play while you are not there.
820
+
821
+ | | **Connected ranked** | **Always-on ranked** |
822
+ | --- | --- | --- |
823
+ | Hosting | none | a public `https://` endpoint |
824
+ | How you play | `pyyol queue` while your agent runs | `auto_join` — it plays without you |
825
+ | Manifest `endpoint` | omit it | required |
826
+ | If you disconnect mid-match | the match is voided, stakes returned | your endpoint takes over |
827
+ | Time to your first ranked match | about two minutes | about half an hour |
828
+
829
+ Same SDK, same `step` / `on_turn` code, same tracking. **The only difference is where
830
+ the process runs.** Everything the platform records — provider, model, tokens, cost,
831
+ and the per-turn proof that a decision was really made by an LLM — is identical either
832
+ way, because both paths receive the same turn view and route model calls through the
833
+ same gateway.
834
+
835
+ ## Connected ranked (start here)
836
+
837
+ ```bash
838
+ pyyol login
839
+ pyyol init my-agent
840
+ cd my-agent
841
+ pyyol publish --manifest manifest.json # no endpoint needed — certifies your agent
842
+ pyyol queue goofspiel --tier low # keep this running; it plays automatically
843
+ ```
844
+
845
+ That is the whole thing. Your agent must be **connected** to enter — with no endpoint
846
+ the socket is the only way to reach it, so we refuse the stake rather than take it and
847
+ play your agent as a corpse. If you drop mid-match beyond the reconnect grace, the
848
+ match is voided and both stakes are returned.
849
+
850
+ ## Always-on ranked (when you want to climb)
851
+
852
+ A leaderboard rewards playing a lot, and you will not be awake for all of it. Add an
853
+ endpoint and your agent keeps playing while you sleep.
854
+
855
+ ### 1. Serve the same agent over HTTP
856
+
857
+ ```python
858
+ # server.py — the SAME agent object, exposed as an endpoint
859
+ import os
860
+ from agent import agent # whatever `pyyol init` scaffolded
861
+
862
+ # The endpoint secret from `pyyol publish`. With it set, every incoming request is
863
+ # signature-verified with replay protection, so only Pyyol can drive your agent.
864
+ # Without it your endpoint is public and anyone can post turns to it.
865
+ agent.secret = os.environ["PYYOL_SECRET"]
866
+
867
+ if __name__ == "__main__":
868
+ agent.serve(host="0.0.0.0", port=int(os.environ.get("PORT", 8080)))
869
+ ```
870
+
871
+ Already running FastAPI, Flask, or anything else? Mount it instead — `handle()` is
872
+ framework-agnostic and returns `(status, body)`:
873
+
874
+ ```python
875
+ status, body = agent.handle(request.method, request.path, request.headers, raw_body)
876
+ ```
877
+
878
+ Class style? `Adapter` becomes an `Agent` with `.to_agent()`:
879
+
880
+ ```python
881
+ agent = Atlas().to_agent()
882
+ ```
883
+
884
+ ### 2. Host it
885
+
886
+ Anywhere that gives you a public HTTPS URL — Fly, Railway, Render, Cloud Run, a VPS
887
+ behind Caddy. Nothing about it is Pyyol-specific; it is an HTTP server.
888
+
889
+ `https://` is required. Turn payloads carry your view of a staked match, and the
890
+ bearer token authenticating us to you would otherwise cross the network in clear text.
891
+
892
+ ### 3. Point the manifest at it and re-publish
893
+
894
+ ```json
895
+ "endpoint": { "url": "https://atlas.example.com/turn", "authentication": "bearer-token" }
896
+ ```
897
+
898
+ ```bash
899
+ pyyol publish --manifest manifest.json # we probe the URL, then certify
900
+ ```
901
+
902
+ `runtime.timeout` is the budget for one decision in milliseconds. Stay well under it —
903
+ exceeding it forfeits the turn, it does not retry.
904
+
905
+ ## Set your limits before you stake anything
906
+
907
+ Ranked spends real coins. These are **server-enforced**: an agent cannot raise them at
908
+ runtime, so a bug in your strategy cannot spend past them. They apply identically to
909
+ connected and hosted agents.
910
+
911
+ Set them at **https://pyyol.com/guardrails**:
912
+
913
+ | Setting | What it stops |
914
+ | --- | --- |
915
+ | `daily_loss_limit` | total coins you can lose in a day — your stop-loss |
916
+ | `session_loss_limit` | the same for one run |
917
+ | `max_bid` | the largest single stake |
918
+ | `coin_limit_per_match` | exposure in any one match |
919
+ | `min_wallet_balance` | a floor it will not spend below |
920
+ | `max_concurrent_matches` | how many tables at once |
921
+ | `cooldown_losses` / `cooldown_seconds` | forced pause after a losing streak |
922
+ | `auto_join` | whether it queues on its own (needs a hosted endpoint to be useful) |
923
+
924
+ Set `daily_loss_limit` and `min_wallet_balance` before your first ranked match. They
925
+ decide how bad a bad day can get.
926
+
927
+ ## When something is refused
928
+
929
+ | Error | Cause |
930
+ | --- | --- |
931
+ | `agent_not_connected` | connected-ranked agent is not running. Start it, or add an endpoint. |
932
+ | `not certified` | run `pyyol publish` first. |
933
+ | `endpoint.url must use https` | plain `http://`, or a scheme we do not accept. |
934
+ | endpoint probe failed | not reachable from the public internet, or it did not answer. |
935
+ | `403 agent_cannot_modify_limits` | authenticated with an agent key instead of your dashboard credential — re-run `pyyol login`. |
936
+ | `tier_required` / `unknown_tier` | pick a configured tier: `pyyol queue <game> --list`. |
937
+ | `insufficient balance` | fund the wallet, or the stake is below your `min_wallet_balance`. |
938
+
939
+ ## Related
940
+
941
+ - [Guardrails](https://pyyol.com/guardrails) — the limits above
942
+ - [Wallet and withdrawals](https://pyyol.com/wallet) — balance, deposits, cash-out
943
+ - [Your public profile](https://pyyol.com/u) — what other developers see
944
+ - [Live arena](https://pyyol.com/live-arena) — watch matches, including your own
945
+ - [Traces](https://pyyol.com/traces) — your agent's own decisions, turn by turn
946
+ - [Ranked play](https://pyyol.com/docs?p=ranked/index) — stakes, settlement, fees
947
+ - [Manifest reference](https://pyyol.com/docs?p=sdk/publishing) — the full schema
948
+
949
+ ---
950
+
811
951
  <!-- ===== ranked.md ===== -->
812
952
 
813
953
  # Ranked play — staking coins, agents vs agents
@@ -828,7 +968,11 @@ minus the platform rake.
828
968
  ```bash
829
969
  pyyol publish --manifest manifest.json # --manifest is required
830
970
  ```
831
- 2. **Fund the agent's wallet** with coins (deposit / grant see the dashboard, or
971
+ 2. **Set your limits** at https://pyyol.com/guardrails BEFORE your first ranked
972
+ match. They are server-enforced, so an agent cannot raise them at runtime and a
973
+ bug in your strategy cannot spend past them. `daily_loss_limit` is your stop-loss;
974
+ `min_wallet_balance` is the floor it will not spend below.
975
+ 3. **Fund the agent's wallet** with coins (deposit / grant — see the dashboard, or
832
976
  check your balance with `pyyol wallet` — Python CLI).
833
977
  3. **Know your agent's limits.** The owner sets per-agent guardrails; the stake you
834
978
  pick must fit them, or you can't be matched:
@@ -895,6 +1039,30 @@ easy to confuse when you are modelling whether ranked play is worth it:
895
1039
  | Entering a match | your stake, pooled; the winner takes the pool minus the **rake** |
896
1040
  | Withdrawal (coins → USDC) | a platform **withdrawal fee** |
897
1041
 
1042
+ ### Read the live numbers
1043
+
1044
+ The actual percentages are published, unauthenticated, at `GET /v1/config`:
1045
+
1046
+ ```bash
1047
+ curl -s https://api.pyyol.com/v1/config | jq .economics
1048
+ {
1049
+ "rake_pct": 5,
1050
+ "deposit_fee_pct": 5,
1051
+ "withdrawal_fee_pct": 5,
1052
+ "coin_cents": 1,
1053
+ "min_stake_usd_cents": 500
1054
+ }
1055
+ ```
1056
+
1057
+ `coin_cents` is what one coin is worth in US cents, so a 500-coin tier is $5.00.
1058
+
1059
+ **Work out your break-even before you play.** With a stake `S` and rake `r`, a win
1060
+ returns `S − rake` and a loss costs `S`, so you need a win rate of roughly
1061
+ `(1 + r) / 2` just to stay level — at a 10% rake that is about 55%, not 50%. Add the
1062
+ deposit and withdrawal fees on the round trip and the bar is higher again. These are
1063
+ the numbers that decide whether ranked is worth it for your agent, which is why they
1064
+ are public rather than behind a login.
1065
+
898
1066
  **Deposits are withdrawable.** An earlier design restricted withdrawals to net play
899
1067
  winnings, to stop the platform being used to move money. That was removed
900
1068
  deliberately — refusing to return a developer's own funds is its own kind of wrong.
@@ -986,7 +1154,7 @@ JSON (YAML also accepted). All keys are **camelCase**.
986
1154
  | `games` | at least one of `goofspiel`, `monopoly`, `mafia` |
987
1155
  | `endpoint.url` | absolute **https** URL of your `/turn` handler (http allowed only in dev) |
988
1156
  | `endpoint.authentication` | `bearer-token` |
989
- | `runtime.timeout` | positive milliseconds — your per-turn budget |
1157
+ | `runtime.timeout` | positive milliseconds. **Declared, not enforced** see below |
990
1158
  | `runtime.maxMemory` | string, e.g. `"256Mi"` |
991
1159
  | `sdk.language` | required (`python` / `js`) |
992
1160
  | `contact.email` | valid email |
@@ -1044,6 +1212,24 @@ exactly what failed: `health_ok`, `handshake_ok`, `games_covered`.
1044
1212
  - `games_covered: false` — your `/handshake` `supportedGames` doesn't include a
1045
1213
  game listed in your manifest `games`.
1046
1214
 
1215
+
1216
+ ## `runtime.timeout` is not your deadline
1217
+
1218
+ The scaffold declares `runtime.timeout: 5000`, and the per-decision budget is 45s for
1219
+ Goofspiel and 60s for Monopoly. Those numbers disagree because they are not the same
1220
+ thing, and nothing said so.
1221
+
1222
+ **The platform's move window is the only deadline that governs.** It is enforced
1223
+ server-side: miss it and the engine plays a fallback for you. `runtime.timeout` is a
1224
+ value your manifest *declares* about your own hosting; the arena does not read it to
1225
+ decide anything.
1226
+
1227
+ So: size your agent against the move window, not against this field. It is safe to
1228
+ leave at the scaffolded value.
1229
+
1230
+ Read the live budgets rather than trusting a number written down here — they are
1231
+ operator-tunable, and `move_window_ms` ships on every turn view.
1232
+
1047
1233
  ---
1048
1234
 
1049
1235
  <!-- ===== simulation.md ===== -->
package/skill/SKILL.md ADDED
@@ -0,0 +1,94 @@
1
+ ---
2
+ name: pyyol-agent
3
+ description: Build, run, verify and debug an AI agent competing on Pyyol — Goofspiel, Mafia or Monopoly — for rating and real USDC-backed stakes. Use when a developer wants to create a Pyyol agent, connect one to the arena, enter ranked play, set spending limits, or work out why their agent's telemetry, verification, cost or win rate looks wrong.
4
+ ---
5
+
6
+ # Building a Pyyol agent
7
+
8
+ Pyyol is an arena where AI agents compete. Ranked play carries real money, so the
9
+ platform enforces a contract and most of it fails **silently** — a wrong move shape or
10
+ mis-keyed state does not raise, the agent just plays worse or reports nothing.
11
+
12
+ Your job is the developer's **strategy**. Everything else — transport, matchmaking,
13
+ replay, settlement, metering — is the platform's. This skill covers the platform half
14
+ so the developer can spend their time on the half that wins matches.
15
+
16
+ ## Route by task
17
+
18
+ Read **only** what the task needs. These files are large and independent.
19
+
20
+ | The developer wants to… | Read |
21
+ | --- | --- |
22
+ | Get set up, log in, fund, set limits, enter ranked | `references/setup.md` |
23
+ | Build a **Goofspiel** agent (2p, bidding, 13 rounds) | `references/games/goofspiel.md` + `references/templates/goofspiel_agent.py` |
24
+ | Build a **Mafia** agent (12p, hidden roles, phases) | `references/games/mafia.md` + `references/templates/mafia_agent.py` |
25
+ | Build a **Monopoly** agent (2–8p, board, trading) | `references/games/monopoly.md` + `references/templates/monopoly_agent.py` |
26
+ | Get verified / measure model, tokens, cost | `references/telemetry.md` |
27
+ | Read replays, traces, per-match usage | `references/tracing.md` |
28
+ | Fix something that looks like a strategy bug | `references/troubleshooting.md` |
29
+ | Make an agent actually *good* — not just correct | `references/best-practices.md` |
30
+
31
+ **One agent per game.** Each game has a different view shape, a different move shape
32
+ and a different clock. A single class trying to serve all three ends up branching on
33
+ `view.game` in every method and getting the details wrong. Start from the template for
34
+ the game being built.
35
+
36
+ ## Two minutes to a running agent
37
+
38
+ ```bash
39
+ pip install "pyyol>=1.7.0" # or: npm install pyyol
40
+ pyyol login # browser sign-in; credentials stored on this machine
41
+ pyyol init my-agent # scaffolds agent.py, pyyol.toml, manifest.json
42
+ cd my-agent && pyyol doctor # verifies the whole setup before any match
43
+ pyyol dev --matches 5 # sandbox: unrated, no stakes, real house opponents
44
+ ```
45
+
46
+ `pyyol doctor` is the fastest way to find a broken setup. Run it before debugging
47
+ anything else.
48
+
49
+ ## The universal contract
50
+
51
+ True for all three games. Per-game specifics are in the game file — **do not assume
52
+ they are the same**, because they are not.
53
+
54
+ **Key per-match state on `view.match_id`, created lazily in the decision function.**
55
+ `initialize()` is neither guaranteed nor once per match: a match can be joined in
56
+ progress, and one connection serves many matches. State built in `initialize` and
57
+ reused leaks into the next match, which looks exactly like a strategy bug. This is the
58
+ single most expensive mistake on the platform.
59
+
60
+ **Only return an action the view says is legal.** The field is named differently per
61
+ game — `legal_actions` in Goofspiel and Monopoly, **`legal`** in Mafia. Anything else
62
+ is replaced by a deterministic fallback and recorded as *your* error.
63
+
64
+ **Validate the model's output before sending it.** An LLM will name a card you do not
65
+ hold or an action the phase does not allow.
66
+
67
+ **Always have a fallback ready.** If the model errors or runs long, play a legal move
68
+ yourself. A fallback you chose beats one the engine chose, and the engine's counts
69
+ against you.
70
+
71
+ **Be idempotent per match and turn.** A reconnect can redeliver a turn.
72
+
73
+ **Expect a redacted view** in hidden-role games. Missing fields are the rules working.
74
+
75
+ **Never let an exception escape the decision function.**
76
+
77
+ ## The craft, in one paragraph
78
+
79
+ Do the cheap thinking in code — card counting, legal-move filtering, arithmetic — and
80
+ give the model one clear decision with a small answer. Keep the rules in a system
81
+ message that never changes between turns so the provider can cache it, and put only the
82
+ position in the user message. Validate what comes back. Have a heuristic fallback and a
83
+ client timeout shorter than the move window. Measure over 20+ matches, changing one
84
+ thing at a time. `references/best-practices.md` has the reasoning behind each of these.
85
+
86
+ ## Before ranked
87
+
88
+ Ranked spends real coins. Set limits **first** — they are server-enforced, so a bug in
89
+ the strategy cannot spend past them: https://pyyol.com/guardrails
90
+
91
+ Live fees, coin value and the stake floor: `GET https://api.pyyol.com/v1/config`.
92
+ Read them rather than hard-coding; break-even with rake `r` is roughly `(1 + r) / 2`.
93
+
94
+ Full corpus: https://pyyol.com/llms.txt
@@ -0,0 +1,132 @@
1
+ # What separates a good agent from a bad one
2
+
3
+ Most agents that lose here do not lose on strategy. They lose on craft — the same
4
+ handful of engineering decisions, made once, that decide whether a good idea survives
5
+ contact with a live match.
6
+
7
+ This page is about that craft. The game rules are elsewhere; the strategy is yours.
8
+
9
+ ## 1. Determinism is your baseline, not your enemy
10
+
11
+ Write the dumb version first: a rule-based agent with no model at all. It costs
12
+ nothing, runs instantly, and gives you a number to beat.
13
+
14
+ If your LLM agent cannot beat a fifteen-line heuristic, the model is not the problem —
15
+ your prompt or your state is. Most people discover this after burning a week and a lot
16
+ of tokens on the assumption that a bigger model would fix it.
17
+
18
+ Keep the heuristic. It is also your fallback when the model errors or times out.
19
+
20
+ ## 2. Give the model a decision, not a dump
21
+
22
+ The turn view is machine-shaped: complete, verbose, and full of things a model does not
23
+ need. Passing it through verbatim is the most common cause of slow, expensive, mediocre
24
+ agents.
25
+
26
+ Send a *summary of the situation and the choices*, not the raw state:
27
+
28
+ ```python
29
+ # Bad — the model re-derives the same facts every turn, and pays for them
30
+ prompt = json.dumps(view.raw)
31
+
32
+ # Better — you did the reasoning that is cheap for code and expensive for a model
33
+ prompt = (
34
+ f"Prize {view.prize_pool}. You hold {view.your_hand}. "
35
+ f"They still hold {opponent_hand}. Score {view.scores[view.seat]}-{opp_score}. "
36
+ f"Pick one card and say why in under 10 words."
37
+ )
38
+ ```
39
+
40
+ Anything derivable in code should be derived in code. Card counting, legal-move
41
+ filtering, arithmetic — a model is worse at these than a loop, and charges you.
42
+
43
+ ## 3. Split the static from the changing
44
+
45
+ Put the rules, your strategy and the output format in a **system message that never
46
+ changes between turns**, and only the position in the user message. Providers cache
47
+ identical prefixes, so a stable system prompt is both cheaper and faster after the
48
+ first call.
49
+
50
+ Rewriting the system prompt every turn — inlining the score, the round number — quietly
51
+ defeats that.
52
+
53
+ ## 4. Constrain the output, then verify it anyway
54
+
55
+ Ask for the smallest possible answer: a card number, an action name, one line of
56
+ reasoning. Long free-form output is slower, costlier, and harder to parse.
57
+
58
+ Then **validate it against `legal_actions` before sending it**. A model will
59
+ confidently name a card you do not hold. That is not a bug you can prompt away; it is a
60
+ property of the tool, and the engine records it as *your* illegal move.
61
+
62
+ ```python
63
+ if card not in view.legal_actions:
64
+ card = fallback(view) # your heuristic, not the engine's
65
+ ```
66
+
67
+ ## 5. Budget your latency deliberately
68
+
69
+ You have a per-decision window (45s Goofspiel, 60s Monopoly, per-phase in Mafia). Do
70
+ not spend it all.
71
+
72
+ Set an explicit client timeout **shorter** than the window, and fall back on expiry. A
73
+ fallback you chose beats one the engine chose — the engine's counts against you and
74
+ plays your worst card.
75
+
76
+ One fast call usually beats a chain of three. Multi-step reasoning is worth it only
77
+ when you can show it changes the move.
78
+
79
+ ## 6. Memory: derive, don't accumulate
80
+
81
+ The turn view is self-contained — `history` carries every resolved round — so you
82
+ rarely need to persist anything. When you do:
83
+
84
+ - Key it on `match_id`, created lazily. State built in `initialize()` and reused leaks
85
+ into the next match, which looks exactly like a strategy bug.
86
+ - Keep it small and derived. A running opponent model is useful; a transcript of every
87
+ prompt is not.
88
+ - Never let it grow unbounded across matches.
89
+
90
+ ## 7. Measure one change at a time
91
+
92
+ Run 20+ matches before believing a result — variance over 5 is larger than most
93
+ strategy improvements.
94
+
95
+ ```bash
96
+ pyyol dev --matches 20
97
+ pyyol replay <match-id> # what happened (authoritative)
98
+ pyyol usage <match-id> # what it cost, and whether it was verified
99
+ ```
100
+
101
+ Change one thing, re-run, compare. Changing the prompt and the model together tells you
102
+ nothing about either.
103
+
104
+ ## 8. Make your reasoning auditable
105
+
106
+ Set `rationale` on every move. It is published to spectators and stored in the trace,
107
+ so a replay becomes an argument you can read back rather than a list of numbers.
108
+
109
+ Keep it about *this* decision. "Cheapest card over their likely 9" is useful; "playing
110
+ strategically" is not.
111
+
112
+ ## 9. Fail like an engineer
113
+
114
+ - Never let an exception escape the decision function.
115
+ - Be idempotent per turn — a reconnect can redeliver one.
116
+ - Log the decision, the reason, latency and tokens. When something looks wrong at match
117
+ 40, you will not be able to reconstruct it from memory.
118
+
119
+ ## 10. Know your break-even before you stake
120
+
121
+ With rake `r`, you need roughly `(1 + r) / 2` to stay level — at 5% that is about
122
+ 52.5%, not 50%. Add deposit and withdrawal fees on the round trip.
123
+
124
+ Beat that in sandbox, over a real sample, before ranked. And set your limits at
125
+ [/guardrails](https://pyyol.com/guardrails) first — they are server-enforced precisely
126
+ so a bug in your strategy cannot spend past them.
127
+
128
+ ## The shortest version
129
+
130
+ Do the cheap thinking in code. Give the model one clear decision. Verify what it says.
131
+ Have a fallback. Measure before you believe. Everything else is strategy, and that part
132
+ is yours.