fix(main-loop): configure sidechats to actively drive main chat across all fleet agents
This commit is contained in:
+32
-8
@@ -63,11 +63,11 @@ FOLLOWUPS_FILE = os.path.join(BASE, "followups.json")
|
||||
DEFAULT_AGENTS = ["muse", "pip", "646", "opm", "dev"]
|
||||
# Prompting sidechat per agent — mirrors box-ctl.py NOTIFY_SIDECHATS.
|
||||
DEFAULT_PROMPT_SIDECHAT = {
|
||||
"646": "646 tasks",
|
||||
"opm": "main-loop brain",
|
||||
"pip": "pip tasks",
|
||||
"muse": "muse tasks",
|
||||
"dev": "onboarding-dev",
|
||||
"646": "main",
|
||||
"opm": "main",
|
||||
"pip": "main",
|
||||
"muse": "main",
|
||||
"dev": "main",
|
||||
}
|
||||
DEFAULT_SENDER = "opm" # neutral sender, mirrors `box notify`
|
||||
READ_LIMIT = 30
|
||||
@@ -321,8 +321,19 @@ def send_prompt(sender, agent, sidechat, digest):
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Try fast direct gateway send
|
||||
if target_uuid and re.fullmatch(r"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}", target_uuid.lower()):
|
||||
# Fast direct gateway send for main chat or resolved UUID
|
||||
is_main = (sidechat == "main" or target_uuid == "main")
|
||||
if is_main:
|
||||
try:
|
||||
import muse_hybrid
|
||||
send_node = agent if agent in DEFAULT_AGENTS else sender
|
||||
res, err = muse_hybrid.send_message(send_node, digest, thread_id=None, wait=25)
|
||||
if res and not err:
|
||||
return True, "sent (gateway main)", None, False
|
||||
log("Gateway send main fallback for %s: %s" % (agent, err or res))
|
||||
except Exception as e:
|
||||
log("Gateway send main exception for %s: %s" % (agent, e))
|
||||
elif target_uuid and re.fullmatch(r"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}", target_uuid.lower()):
|
||||
try:
|
||||
import muse_hybrid
|
||||
send_node = agent if agent in DEFAULT_AGENTS else sender
|
||||
@@ -587,13 +598,26 @@ def do_check(only_agent=None):
|
||||
results[agent] = {"ok": True, "new": 0}
|
||||
continue
|
||||
|
||||
sidechat = cfg["prompt_sidechat"].get(agent)
|
||||
is_main = (sidechat == "main")
|
||||
if is_main:
|
||||
# Side chats drive the main chat
|
||||
if not sc_activity and not subagent_alerts:
|
||||
results[agent] = {"ok": True, "new": 0}
|
||||
continue
|
||||
parts = []
|
||||
if sc_activity:
|
||||
parts.append(compose_dual_digest(agent, [], sc_activity))
|
||||
if subagent_alerts:
|
||||
parts.extend(subagent_alerts)
|
||||
digest = "\n\n".join(parts)[:DIGEST_MAX * 2]
|
||||
else:
|
||||
parts = []
|
||||
if len(main_new) > 0 or len(sc_activity) > 0:
|
||||
parts.append(compose_dual_digest(agent, main_new, sc_activity))
|
||||
if subagent_alerts:
|
||||
parts.extend(subagent_alerts)
|
||||
digest = "\n\n".join(parts)[:DIGEST_MAX * 2]
|
||||
sidechat = cfg["prompt_sidechat"].get(agent)
|
||||
if not sidechat:
|
||||
log("%s: no prompting sidechat configured, skipping" % agent)
|
||||
results[agent] = {"ok": False, "error": "no prompting sidechat"}
|
||||
|
||||
Reference in New Issue
Block a user