pub(crate) async fn generate_definition_activity_summary(
mstore: &Store,
filestore: &FileStore,
broker: &Arc<Broker>,
definition_id: &str,
block_id: &str,
provider_id: &str,
) -> Option<Generated>Expand description
Generate (and persist) a short activity summary for a definition whose
AgentPicker row has no structured output.state.json conversation
snapshot to preview — legacy rows predating snapshot persistence, per
has_snapshot in agent_handlers::session::listrecentsessions. Built
from the instance’s raw terminal capture (the "output" filestore file,
written unconditionally by the CLI pipeline, independent of the newer
structured snapshot), reusing read_recent_activity_digest — the same
extraction generate_recovered_title above uses.
One-shot per definition, not per-turn: generation is always the
constant 1, mirroring generate_subagent_name’s cache-once posture —
the caller only invokes this when agent_activity_summary_get found
nothing persisted yet, so there is no “newer turn” to supersede an
in-flight call here (unlike the session:activity_summary RPC, which
regenerates every turn for a LIVE conversation).
CLI path resolution (reagent P1, PR #2786): the row shape this feature
actually targets is a CLOSED pane — DeleteBlock
(sagas::delete_block::run) removes the Block row entirely on pane
close while the instance row and raw filestore output survive. For such
rows there is no live block to read cmd/cmd:env meta from at all, so
this prefers the block record when it still exists (richer: carries the
per-block auth env the CLI needs) and falls back to
resolve_provider_cli_path_readonly + an EMPTY auth env otherwise —
best-effort: a provider that needs per-block injected credentials (no
ambient/global login available) fails the Haiku call cleanly (None,
same as any other unresolvable case here), not a wrong result.
Fire-and-forget by design: the caller (listrecentsessions) spawns this
in the background and does not await it inline. The row that triggered
generation still shows its existing fallback text on THIS response; on
success this broadcasts agents:changed, which MyAgentsList.tsx
already refetches on, picking up the now-persisted summary on the next
load. Returns None (nothing persisted, nothing broadcast) when there’s
no raw output to summarize, the CLI path isn’t resolvable, this call was
superseded/capped, or the CLI failed — the caller treats all of these as
“still nothing to show,” not an error.