Skip to main content

Module activity_watcher

Module activity_watcher 

Source
Expand description

Empty-title recovery: a running agent with conversation and no usable session title gets one, written straight to its block’s term:ambient_summary, which the pane header and the Swarm row read.

The title is otherwise computed only when a human submits a message (useAgentActivitySummary.ts). An agent driven by jekts or tool work, one reattached mid-turn, or one whose title call failed or abstained could sit on an empty title for as long as it ran. This sweep is the second route.

It replaces what this module used to do: a “what is being worked on” summary every 20 s for every running agent, published as an agent:summary event that nothing subscribed to, so every call was spent and its output went nowhere. Now an agent that already has a title costs nothing here. docs/specs/SPEC_AMBIENT_SWARM_SUMMARY_HARDENING_2026_10_02.md sections 2.1 (defects 2 and 5), 5.6 and 5.7.

Each call goes through crate::ambient::tasks::generate_recovered_title, so the Ambient Model Call gateway admits, cancels and accounts for it under its own purpose tag, distinct from the pane’s own title request.

Cost controls:

  • only agents whose controller is running (STATUS_RUNNING) and that have no usable title;
  • only agents whose output is in a shape the digest can read (digest::reads_output_format); another provider’s file holds no conversation it can find;
  • only when the block’s output has grown since the last completed attempt;
  • at most MAX_ATTEMPTS completed attempts per block while the title stays empty, counted again from zero once a title exists, so an agent whose activity never shows what the work is (the model abstains) stops costing;
  • no conversation in the digest means no call at all (digest returns None for activity with no user or assistant text);
  • one call in flight per block, waiting in the background class’s queue (ambient::limits) across all blocks;
  • per-block bookkeeping is pruned each tick against the registration list.

Structs§

Attempts 🔒
Per-block state the sweep keeps between ticks.

Constants§

MAX_ATTEMPTS 🔒
Completed attempts per block while its title stays empty. Bounded, as the lys design bounds its retries (spec section 3, research point 2).
SWEEP_INTERVAL_SECS 🔒
How often to sweep registered agents.
WORD_TARGET 🔒
Word budget for a recovered title: within the range the pane’s own request uses (5 to 12, by pane width), so a recovered title looks like any other.

Functions§

run_agent_summary_loop
Run the recovery sweep. Never returns.
skip_reason 🔒
Why a block is not attempted this tick, or None to attempt it. Pure, so the cost rules are testable without a model, a store or a clock.