fix(poker): guarantee hand logging — history was conditioning it away
Logging a stated hand was unreliable and got worse mid-session: same model, same
hand, clean history logged 4/4 but the real session's history logged 0/4. Root
cause: memory.recent() rebuilt past turns as "hand -> narration" with the tool
calls stripped (they live in tool_events), so the model's own context became
few-shot examples training it, mid-conversation, to STOP calling tools. Even a
maximal "LOG FIRST, no exceptions" prompt scored 0/5 — it's structural, not wording.
Two-part fix (both, per the system-of-record frame):
- A (guarantee): chat._ensure_hand_logged — on a HAND turn that's Brian's OWN hand,
if the model didn't log it, force record_hand (tool_choice). Guarded to hero hands
(looks_like_hero_hand) so an observed hand is never force-logged as his. Adds
tool_choice passthrough to llm.chat_call; surfaces msg_type on TurnContext.
- B (heal forward): mind._history_with_tools makes each assistant turn's tool calls
visible in reconstructed history ("record_hand -> Hand #62"), so the demonstrated
pattern stops being "hand -> narrate". Recovers natural logging as logs accumulate.
Verified: force guard returns record_hand on the polluted context; full respond_stream
logs Hand #63 end-to-end on a clean session. 7 guard tests; suite 219 green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -147,6 +147,15 @@ def classify(user_msg: str, roster_handles=()) -> str:
|
||||
return "CHAT"
|
||||
|
||||
|
||||
def looks_like_hero_hand(user_msg: str) -> bool:
|
||||
"""True when the message is Brian's OWN hand (first-person + real card content) —
|
||||
the guard for force-logging. Deliberately conservative: an observed hand (a villain
|
||||
the actor, no I/me/my) returns False so we never force-log someone else's hand as his."""
|
||||
msg = (user_msg or "").strip()
|
||||
low = msg.lower()
|
||||
return bool(_FIRST_PERSON.search(low)) and _looks_like_hand(low, msg)
|
||||
|
||||
|
||||
# --- always-on base (poker) ----------------------------------------------
|
||||
|
||||
BASE = """You are copiloting Brian's LIVE cash game — at the table with him, a session open. \
|
||||
|
||||
Reference in New Issue
Block a user