Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Heuristic:1jehuang Jcode Debounced Status Fanout

From Leeroopedia
Knowledge Sources
Domains Multi_Agent_Systems, Optimization
Last Updated 2026-10-18 00:00 GMT

Overview

Swarm status updates are fanned out to coordinator views via debounced event delivery, preventing flooding when many workers update simultaneously.

Description

The Debounced_Status_Fanout heuristic ensures that when swarm worker status changes occur, the fanout_session_event function delivers updates to the coordinator's swarm view without flooding. Workers frequently report status (started, stopped, progress), and without debouncing the coordinator's TUI would be overwhelmed with redraw requests. The fanout uses bounded event history (MAX_EVENT_HISTORY) to avoid unbounded memory growth.

Usage

Use this heuristic when multiple swarm workers are running concurrently and reporting status. It prevents the coordinator's TUI from being overwhelmed with rapid status updates. Apply when designing any multi-agent fanout system where many workers can update simultaneously.

The Insight (Rule of Thumb)

  • Action: Use fanout_session_event with bounded event history (MAX_EVENT_HISTORY).
  • Value: Status updates are fanned out to session views but bounded to prevent memory growth.
  • Trade-off: Some status updates may be coalesced or dropped if they arrive faster than the debounce window.
  • Compatibility: Works with the SwarmMember registry and ServerEvent::TurnStopped event types.

Reasoning

In a swarm with N concurrent workers, each worker may report multiple status updates per second. Without debouncing, the coordinator receives N×updates/sec, causing excessive TUI redraws and potential event queue backpressure. Bounding the event history prevents unbounded memory growth in long-running swarms while still delivering meaningful status changes to the coordinator.

Code Evidence

Fanout usage from crates/jcode-app-core/src/server/swarm.rs:1,127:

use super::state::{MAX_EVENT_HISTORY, fanout_session_event};

// Workers usually have no attached client; the status update below
// is what the coordinator's swarm view shows.
fanout_session_event(
    swarm_members,
    &descendant,
    ServerEvent::TurnStopped {

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment