agents get a kickoff inbox message on start/restart/rebuild

new Coordinator::kick_agent(name, reason) drops a system message
into the agent's inbox so the next turn picks it up with a 'you
were just (re)started, check /state/ for notes, --continue session
is intact' hint. wakes the turn loop without any harness-side
handling needed — it's just another inbox message with sender =
'system'.

wired from:
- dashboard /start /restart /rebuild handlers (via lifecycle_action's
  on-success tail)
- manager mcp_hyperhive_start / restart

dashboard: pending approvals + tombstones + questions now refresh on
a 5s heartbeat when nothing else is happening. previously refresh
only fired on async-form submit or on broker traffic addressed to
operator — manager-queued approvals went through neither, so the
operator had to reload to see them. 5s is the slow-path; 2s
remains for in-flight transients.
This commit is contained in:
müde 2026-05-15 20:19:36 +02:00
parent 8b10731aa4
commit 2413d664a1
4 changed files with 42 additions and 9 deletions

View file

@ -121,6 +121,28 @@ impl Coordinator {
self.transient.lock().unwrap().clone()
}
/// Drop a system message into the given agent's inbox. Wakes the
/// turn loop with a "you were just (re)started" hint — operator
/// caused the transition, agent picks up where it left off
/// (notes are in /state/, last turn is in --continue's session).
/// Best-effort; broker errors are logged but don't propagate.
pub fn kick_agent(&self, name: &str, reason: &str) {
let body = format!(
"{reason}\n\nYou were just (re)started by the operator. \
If you were mid-task, check `/state/` for your notes \
and pick up where you left off. claude's `--continue` \
session is intact, so prior context is still in your \
window."
);
if let Err(e) = self.broker.send(&hive_sh4re::Message {
from: hive_sh4re::SYSTEM_SENDER.to_owned(),
to: name.to_owned(),
body,
}) {
tracing::warn!(error = ?e, %name, "kick_agent: broker.send failed");
}
}
/// Push a `HelperEvent` into the manager's inbox. Encoded as JSON in
/// `Message::body`; sender = `SYSTEM_SENDER`. The manager harness
/// recognises the sender and parses the body. Best-effort: a serde or