Add main-loop enable/disable per-agent toggle

- self_main_loop.py: 'enabled' map in config (default all True);
  do_check skips disabled agents (marks disabled:true in results);
  new enable/disable actions with optional --agent.
- box-ctl.py: main-loop enable|disable [--agent <name>] actions,
  USAGE updated.

Check skips disabled agents so the loop can be toggled per
Chromebox without stopping the systemd timer.

Session: sidechat/chromebox-ops
This commit is contained in:
operator-main
2026-10-04 18:52:54 +00:00
parent e93e9b6122
commit 0822960810
2 changed files with 70 additions and 13 deletions
+30 -11
View File
@@ -650,18 +650,25 @@ def act_notify(agent, message, sidechat=None, allow_main_chat=False):
out(True, agent=agent, target=target, sent=True)
def act_main_loop(sub):
def act_main_loop(sub, agent=None):
"""Run the main-chat self-monitor loop (self_main_loop.py).
check: one loop iteration -> JSON {ok, prompted, errors, new_total, agents}
status: watermark / last run / prompt-sidechat config, no chat reads.
check: one loop iteration -> JSON {ok, prompted, errors, new_total, agents}
status: watermark / last run / prompt-sidechat config, no chat reads.
enable: enable the loop (per-agent or all); check skips disabled agents.
disable: disable the loop (per-agent or all).
"""
if sub not in ("check", "status"):
fail("BAD_NAME", "usage: main-loop check|status")
audit("main-loop-" + sub)
if sub not in ("check", "status", "enable", "disable"):
fail("BAD_NAME", "usage: main-loop check|status|enable|disable [--agent <name>]")
if agent is not None and agent not in VALID_AGENTS:
fail("BAD_NAME", f"agent must be one of {sorted(VALID_AGENTS)}")
audit("main-loop-" + sub + (f"-{agent}" if agent else ""))
script = BIN / "self_main_loop.py"
cmd = [sys.executable, str(script), sub]
if agent:
cmd += ["--agent", agent]
try:
r = subprocess.run([sys.executable, str(script), sub],
r = subprocess.run(cmd,
capture_output=True, text=True, timeout=600)
except subprocess.TimeoutExpired:
fail("LOOP_TIMEOUT", "self_main_loop.py timed out")
@@ -1171,7 +1178,8 @@ fleet:
relay-health
cdp-latency
identity-audit VM identity audit drift check
main-loop check|status main-chat self-monitor: prompt sidechat on new main msgs
main-loop check|status|enable|disable [--agent <name>]
main-chat self-monitor; enable/disable per agent or all
timer actions:
timer-list
@@ -1415,9 +1423,20 @@ def main(argv):
fail("BAD_ARGS", "usage: chrome-errors")
act_chrome_errors()
elif action == "main-loop":
if len(rest) != 1 or rest[0] not in ("check", "status"):
fail("BAD_NAME", "usage: main-loop check|status")
act_main_loop(rest[0])
if not rest or rest[0] not in ("check", "status", "enable", "disable"):
fail("BAD_NAME", "usage: main-loop check|status|enable|disable [--agent <name>]")
sub = rest[0]
agent = None
args = rest[1:]
if "--agent" in args:
i = args.index("--agent")
if i + 1 >= len(args):
fail("BAD_ARGS", "usage: main-loop %s [--agent <name>]" % sub)
agent = args[i + 1]
args = args[:i] + args[i + 2:]
if args:
fail("BAD_ARGS", "usage: main-loop %s [--agent <name>]" % sub)
act_main_loop(sub, agent)
elif action == "dm-log":
limit = 50
if rest: