Skip to main content

Module tasks

Module tasks 

Source
Expand description

The background and one-shot ambient Haiku callers: pushed and per-definition activity summaries, subagent and workflow-batch names, and narration. Each is best-effort — every failure path returns None and the caller carries on without. They all go through call::admit / Slot::run, so admission, cancellation, concurrency caps and reply validation are the same for each.

The two pull RPCs (session:activity_summary, session:next_prompt_suggestion) use the same path from server::app_api::session.

Structs§

Generated 🔒
What a background call produced. None from a task means it did not run to completion (superseded, capped out, nothing to send, CLI failed), so a caller that tracks progress should try again later. Some means the CLI ran: text is None when the model had nothing usable to say (the reply failed validation, or was empty), which is a finished attempt, not a failure, and tokens is the spend either way.

Constants§

RECORD_HEAD_CHARS 🔒
How much of the continuation record the continued-session note reads: the running summary at its head, the latest exchange at its tail.
RECORD_TAIL_CHARS 🔒
TASK_HEAD_CHARS 🔒
How much of a subagent’s task prompt a name call reads. Task prompts run to many kilobytes; what the task is comes first, and the whole prompt only made the call slower and gave the model more to mistake for its own instructions.
TASK_TAIL_CHARS 🔒

Functions§

finish 🔒
generate_ambient_narration 🔒
Generate a short user-facing line narrating an autonomous action.
generate_continued_note 🔒
The note a pane shows once a fresh session continues its conversation from AgentMux’s record (backend::continued_note). Keyed on the block, so a newer spawn’s note supersedes an older one still in flight. Best-effort: every failure is None, and the pane says nothing.
generate_definition_activity_summary 🔒
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.
generate_dispatch_name 🔒
Generate the one Haiku display name for a Workflow-kind dispatch, eagerly, the first time its first member is observed live, or for an unnamed historical dispatch via SubagentWatcher::resolve_unnamed_backlog when the Swarm pane opens (never called for a Solo dispatch — a Solo dispatch’s name IS its one member’s display_name, already covered by generate_subagent_name; never called during cold-backfill replay — see the live gate on process_jsonl_change’s trigger_eager_naming call in crates/srv/src/backend/subagent_watcher/jsonl.rs).
generate_name_from_task_prompt 🔒
Admit purpose for entity, read info’s own task prompt off its JSONL, borrow its parent block’s CLI, and run build_prompt’s prompt through the name check.
generate_recovered_title 🔒
A session title recovered from the session’s recent activity, for an agent that has none — called by the background sweep in backend::reactive::activity_watcher, which writes an accepted result to term:ambient_summary itself. Goes through the same Ambient Model Call gateway (admission, cancellation-of-superseded, token accounting) under the distinct purpose::ACTIVITY_SUMMARY_PUSHED purpose, so it never contends with the pane’s own title request. The prompt is the pane’s own title prompt (build_session_title_prompt), given the activity instead of a message, not a “what is happening now” summary: the result is shown as the session’s title.
generate_subagent_name 🔒
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).
provider_fallback_target 🔒
The provider’s own CLI with an EMPTY auth env, for a block that no longer exists or names no CLI. None when the provider’s CLI isn’t installed.
resolve_provider_cli_path_readonly
Read-only CLI path lookup for provider_id — checks the versioned local-install dir, then falls back to system PATH. Deliberately never installs anything (unlike the resolvecli RPC handler / agent_open.rs’s launch-time resolution, which both trigger an npm install as a fallback): this is a best-effort BACKGROUND call, not a user-initiated launch — silently installing a CLI as a side effect of a picker preview summary would be a surprising, unwanted cost. Returns None (not an error) for an unknown provider or a CLI that isn’t already available either way; the caller treats that the same as any other unresolvable case.