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:
@@ -52,6 +52,20 @@ def _think_about(args: dict, ctx: dict) -> str:
|
||||
"I'll come back to it on my own between our conversations.")
|
||||
|
||||
|
||||
def _set_mode(args: dict, ctx: dict) -> str:
|
||||
from lyra import modes
|
||||
key = (args.get("mode") or "").strip().lower()
|
||||
m = modes.MODES.get(key)
|
||||
if not m:
|
||||
return f"(unknown mode '{key}'; valid: {', '.join(modes.MODES)})"
|
||||
sid = ctx.get("session_id")
|
||||
if not sid:
|
||||
return "(no session to switch)"
|
||||
memory.set_session_mode(sid, key)
|
||||
logbus.log("info", "mode switch (tool)", session=sid, mode=key)
|
||||
return f"Switched to {m.label} mode."
|
||||
|
||||
|
||||
def _thought_response(args: dict, ctx: dict) -> str:
|
||||
try:
|
||||
tid = int(args.get("thread_id"))
|
||||
@@ -452,6 +466,12 @@ _S = {"type": "string"}
|
||||
_N = {"type": "number"}
|
||||
|
||||
TOOLS.update({
|
||||
"set_mode": {"handler": _set_mode, "spec": _f(
|
||||
"set_mode",
|
||||
"Switch your conversation mode when the work clearly shifts and Brian's agreed to it. "
|
||||
"Offer first ('want me in Decide for this?'), then call this on his yes.",
|
||||
{"mode": {**_S, "description": "Mode key: conversation | poker_cash | build | explore | study | decide"}},
|
||||
["mode"])},
|
||||
"thought_response": {"handler": _thought_response, "spec": _f(
|
||||
"thought_response",
|
||||
"When you've brought one of your own thoughts/threads to Brian and he responds to "
|
||||
|
||||
Reference in New Issue
Block a user