feat: she can suggest + switch modes (set_mode tool + mode awareness)

"She suggests, you confirm" — instead of brittle keyword→mode mapping, she's given
awareness of her modes + the ability to switch, and her judgment decides when to
offer (the model reads "should I drive to Cleveland?" vs "should I fold the river"
far better than a lexicon could).

- tools: set_mode(mode) — switches the session's mode; in _BASE (all modes).
- mind: a per-turn mode-menu note listing her modes + "offer a switch when the work
  clearly shifts; on his yes, call set_mode; don't nag."
- Sticky mode stays manual otherwise; Poker still auto-engages on session start.
- test: set_mode switches + rejects unknown. Suite 97 green, ruff clean.

Note: server-side switch takes effect next turn; the UI badge syncs on next mode
load (cosmetic lag).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-24 16:32:42 +00:00
parent 17ab95dc98
commit 8a3c9b2701
4 changed files with 49 additions and 1 deletions
+18
View File
@@ -74,6 +74,20 @@ def _inner_life_note() -> Message | None:
return {"role": "system", "content": "\n\n".join(parts)}
def _mode_menu_note(current: modes.Mode | None) -> str:
"""Tell her the modes she can switch to + when to offer it. She judges the fit
(the model reads context far better than a keyword would)."""
menu = ", ".join(f"{m.label} ({k})" for k, m in modes.MODES.items())
cur = current.label if current else "Talk"
return (
f"Your modes: {menu}. You're in {cur} right now. If Brian is clearly doing a "
"different kind of work than your current mode — weighing a real decision while "
"you're in Talk, digging into engineering, reviewing poker away from the table — "
"briefly OFFER to switch (one short line). If he says yes, call set_mode with the "
"mode key. Don't offer every turn or nag; only when it genuinely fits and serves him."
)
def _now_note() -> Message:
"""Current wall-clock time + how long since Brian last said anything."""
line = f"The current date and time is {clock.stamp()}."
@@ -109,6 +123,10 @@ def build_messages(session_id: str, user_msg: str,
if 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
# when — better than a keyword guess). One line, on his yes she calls set_mode.
messages.append({"role": "system", "content": _mode_menu_note(mode)})
# Live ritual state (e.g. Alligator Blood ON) — dynamic, rides with the card.
state_note = _mode_state_note(mode)
if state_note: