fix(loop): eliminate main chat saturation from sidechat activity
- Exclude automated jobs ([JOB ...]) and heartbeat from sidechat activity digestion - Exclude recurring background job channels (box-*-health, canary, heartbeat) from monitored sidechats - Reset default prompt destinations to dedicated task sidechats (646 tasks, main-loop brain, pip tasks, muse tasks) - Prevent synthetic 'Incoming sidechat activity' prompts from polluting agent Main Chats
This commit is contained in:
+23
-7
@@ -63,11 +63,11 @@ FOLLOWUPS_FILE = os.path.join(BASE, "followups.json")
|
|||||||
DEFAULT_AGENTS = ["muse", "pip", "646", "opm", "dev"]
|
DEFAULT_AGENTS = ["muse", "pip", "646", "opm", "dev"]
|
||||||
# Prompting sidechat per agent — mirrors box-ctl.py NOTIFY_SIDECHATS.
|
# Prompting sidechat per agent — mirrors box-ctl.py NOTIFY_SIDECHATS.
|
||||||
DEFAULT_PROMPT_SIDECHAT = {
|
DEFAULT_PROMPT_SIDECHAT = {
|
||||||
"646": "main",
|
"646": "646 tasks",
|
||||||
"opm": "main",
|
"opm": "main-loop brain",
|
||||||
"pip": "main",
|
"pip": "pip tasks",
|
||||||
"muse": "main",
|
"muse": "muse tasks",
|
||||||
"dev": "main",
|
"dev": "dev-audit-channel",
|
||||||
}
|
}
|
||||||
DEFAULT_SENDER = "opm" # neutral sender, mirrors `box notify`
|
DEFAULT_SENDER = "opm" # neutral sender, mirrors `box notify`
|
||||||
READ_LIMIT = 30
|
READ_LIMIT = 30
|
||||||
@@ -138,6 +138,8 @@ def get_config(st):
|
|||||||
continue
|
continue
|
||||||
if a == "opm" and sc in ("heartbeat",):
|
if a == "opm" and sc in ("heartbeat",):
|
||||||
continue
|
continue
|
||||||
|
if sc == "main":
|
||||||
|
continue
|
||||||
prompt[a] = sc
|
prompt[a] = sc
|
||||||
enabled = dict(cfg.get("enabled") or {})
|
enabled = dict(cfg.get("enabled") or {})
|
||||||
# Default any unlisted agent to enabled.
|
# Default any unlisted agent to enabled.
|
||||||
@@ -245,7 +247,11 @@ def get_monitored_sidechats(agent):
|
|||||||
continue
|
continue
|
||||||
item_agent = item.get("agent")
|
item_agent = item.get("agent")
|
||||||
if name.endswith(f"@{agent}") or (item_agent == agent and "@" not in name):
|
if name.endswith(f"@{agent}") or (item_agent == agent and "@" not in name):
|
||||||
if name.startswith("pipe-") or name.startswith("test-"):
|
if name.startswith("pipe-") or name.startswith("test-") or name.startswith("onboarding-"):
|
||||||
|
continue
|
||||||
|
if "heartbeat" in name.lower():
|
||||||
|
continue
|
||||||
|
if any(name.startswith(p) for p in ("box-http-health", "box-service-health", "box-deep-health", "canary")):
|
||||||
continue
|
continue
|
||||||
monitored[uuid] = name
|
monitored[uuid] = name
|
||||||
return monitored
|
return monitored
|
||||||
@@ -413,7 +419,14 @@ def check_sidechats(agent, cfg, wm, threads_meta):
|
|||||||
} for m in msgs]
|
} for m in msgs]
|
||||||
|
|
||||||
new_msgs = new_messages(formatted, {"last_id": last_id})
|
new_msgs = new_messages(formatted, {"last_id": last_id})
|
||||||
incoming = [m for m in new_msgs if m.get("role") != "assistant"]
|
incoming = []
|
||||||
|
for m in new_msgs:
|
||||||
|
if m.get("role") == "assistant":
|
||||||
|
continue
|
||||||
|
text = m.get("text", "")
|
||||||
|
if "[JOB " in text or "Heartbeat check" in text or "[from:super]" in text:
|
||||||
|
continue
|
||||||
|
incoming.append(m)
|
||||||
|
|
||||||
if incoming:
|
if incoming:
|
||||||
new_activity.append({
|
new_activity.append({
|
||||||
@@ -617,6 +630,9 @@ def do_check(only_agent=None):
|
|||||||
parts.append(compose_dual_digest(agent, main_new, sc_activity))
|
parts.append(compose_dual_digest(agent, main_new, sc_activity))
|
||||||
if subagent_alerts:
|
if subagent_alerts:
|
||||||
parts.extend(subagent_alerts)
|
parts.extend(subagent_alerts)
|
||||||
|
if not parts:
|
||||||
|
results[agent] = {"ok": True, "new": 0}
|
||||||
|
continue
|
||||||
digest = "\n\n".join(parts)[:DIGEST_MAX * 2]
|
digest = "\n\n".join(parts)[:DIGEST_MAX * 2]
|
||||||
if not sidechat:
|
if not sidechat:
|
||||||
log("%s: no prompting sidechat configured, skipping" % agent)
|
log("%s: no prompting sidechat configured, skipping" % agent)
|
||||||
|
|||||||
Reference in New Issue
Block a user