hive-agent: re-send the turn-state header once a minute
The header on `$SWARM.agent-state.<agent>` went out only when a bus event changed it, and the core subject keeps nothing for a late subscriber. An idle agent therefore said nothing to a reader that attached after its last change: swarm-controller after a restart showed `effective: null` for that agent until its next turn, which can be hours. The publish loop now also wakes every 60 s and re-sends the current header through the same `publish` path (clearing the dedup state first). Transitions still go out as they happen. Same subject, same grant. An agent whose queue connection is down now logs `swarm agent state: publish skipped` once a minute even while idle, so the `hh-swarm-agent-state-publish-skipped` alert also fires for idle disconnected agents, not only busy ones. Refs #5034
This commit is contained in:
parent
d723fac0be
commit
19a045a401
8 changed files with 152 additions and 59 deletions
|
|
@ -7,13 +7,14 @@
|
|||
// coalesce: each event is just the latest value.
|
||||
//
|
||||
// **No seed on attach.** `agent_state_stream.rs`'s own module doc names
|
||||
// this limitation: the subject is published on transition only, so an
|
||||
// agent that has sat idle since before this hook mounted announces
|
||||
// nothing until its next change. `header` stays `null` until the first
|
||||
// event lands — callers should render no badges in that gap rather than
|
||||
// a stale or guessed one (there is no swarm-level endpoint today that
|
||||
// can seed turn_state/model/ctx/cost synchronously — `GET
|
||||
// /api/agents/status`'s snapshot carries only `status_text`/`running`).
|
||||
// this limitation: the subject is published on transition and re-sent
|
||||
// once a minute, so an agent that has sat idle since before this hook
|
||||
// mounted announces nothing for up to a minute. `header` stays `null`
|
||||
// until the first event lands — callers should render no badges in that
|
||||
// gap rather than a stale or guessed one (there is no swarm-level
|
||||
// endpoint today that can seed turn_state/model/ctx/cost synchronously —
|
||||
// `GET /api/agents/status`'s snapshot carries only
|
||||
// `status_text`/`running`).
|
||||
import { useEffect, useState } from "preact/hooks";
|
||||
|
||||
export type ConnectionState = "connecting" | "open" | "reconnecting" | "closed";
|
||||
|
|
|
|||
Loading…
Reference in a new issue