feat(prompting): Phase B step 2 — wire the sharded poker prompt into the pipeline

build_messages now shards poker_cash: injects poker_prompts.BASE + exactly ONE
fragment chosen by classify(user_msg, roster_handles), replacing the ~100-line
_CASH_CARD monolith. Roster handles are fetched fail-safe from the live session so
the READ-vs-HAND split is reliable. CASH.card set to "" (monolith kept only as the
distillation source, superseded). Other modes' single-card path unchanged.

Verified end-to-end: TAG-limp→READ, his-hand→HAND, table-broke→TABLE, tilt→MENTAL,
bare-stack→LOG, all with BASE always present. 5 injection/pipeline tests. Full
suite 196 green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-05 02:57:30 +00:00
parent 5380a00395
commit 338c44361f
3 changed files with 49 additions and 6 deletions
+16 -4
View File
@@ -17,8 +17,8 @@ from __future__ import annotations
from dataclasses import dataclass, field
from lyra import (
clock, config, llm, logbus, memory, modes, perceive, persona, scouting,
self_state, thoughts,
clock, config, llm, logbus, memory, modes, perceive, persona, poker, poker_prompts,
scouting, self_state, thoughts,
)
from lyra.llm import Backend, Message
@@ -153,8 +153,20 @@ def build_messages(session_id: str, user_msg: str,
if inner:
messages.append(inner)
# Mode card: how to behave *right now*. Talk mode has no card (persona is Talk).
if mode and mode.card:
# Mode framing: how to behave *right now*. Poker (poker_cash) is SHARDED — a lean
# always-on BASE plus ONE response-shape fragment chosen by classifying this message
# (replaces the old ~100-line monolithic card). Roster handles make the READ-vs-HAND
# split reliable; fetched fail-safe. Other modes use their single card.
if mode and mode.key == "poker_cash":
messages.append({"role": "system", "content": poker_prompts.BASE})
try:
handles = [r["name"] for r in poker.session_roster()]
except Exception:
handles = []
msg_type = poker_prompts.classify(user_msg, handles)
messages.append({"role": "system", "content": poker_prompts.fragment_for(msg_type)})
logbus.log("info", "poker turn classified", type=msg_type)
elif mode and mode.card:
messages.append({"role": "system", "content": mode.card})
# Mode awareness: she can offer to switch when the work clearly shifts (she decides
+4 -1
View File
@@ -240,7 +240,10 @@ TALK = Mode(
CASH = Mode(
key="poker_cash",
label="Poker",
card=_CASH_CARD,
# Poker mode is SHARDED at the pipeline (lyra.poker_prompts: BASE + a per-message
# fragment), so no monolithic card here. _CASH_CARD is kept below only as the source
# material the fragments were distilled from — superseded, safe to delete later.
card="",
tools=_CASH_TOOLS,
)