pub(crate) async fn generate_subagent_name(
mstore: &Store,
subagent_watcher: &Arc<SubagentWatcher>,
agent_id: &str,
class: Class,
) -> Option<Generated>Expand description
Generate (or return the already-cached) concise Haiku display name for a
subagent. Called on-demand the first time a client expands that
subagent’s row in the Swarm view — see ("subagent", "GenerateName") in
server::service::misc. Subagents have no Block/meta of their own, so
this borrows the parent block’s CLI path + auth env, and reads the
subagent’s own initial task prompt directly off its JSONL (available
immediately even for a still-running subagent, unlike a transcript
summary which needs output to summarize).
Returns None when there’s nothing to name (unknown subagent, no task
prompt on the first JSONL line, parent block unresolvable, or the call
was superseded/capped/failed) — callers should treat that as “leave the
row showing its slug/id fallback,” not an error. A cache hit (name
already generated) returns the cached name with tokens: None — there’s
no new spend to report.