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:666ghj BettaFish Polling Interval Tuning

From Leeroopedia
Knowledge Sources
Domains Optimization, Multi_Agent
Last Updated 2026-10-08 21:30 GMT

Overview

Poll file counts at a tuned interval to detect agent completion without overwhelming the filesystem, using a file count baseline comparison strategy.

Description

The ReportEngine uses a `FileCountBaseline` mechanism to detect when all sub-agents have completed their work. It establishes a baseline file count at initialization, then periodically polls the output directory. When the file count stops increasing for a sustained period (indicating all agents have finished writing), the report generation pipeline proceeds. The polling interval is tuned to balance responsiveness (detecting completion quickly) against filesystem overhead (too-frequent polling wastes I/O).

Usage

Use this heuristic when synchronizing multi-agent completion via filesystem signals. Apply when agents write output files and the orchestrator needs to know when all are done.

The Insight (Rule of Thumb)

  • Action: Initialize `FileCountBaseline` at pipeline start, then poll output directory at a fixed interval until file count stabilizes.
  • Value: Polling interval should be 2-5 seconds for most workloads. Completion is detected when file count matches expected count or stabilizes.
  • Trade-off: Shorter interval = faster detection but more I/O. Longer interval = less I/O but slower detection.
  • Compatibility: Works with any file-based multi-agent system. Requires agents to write output files.

Reasoning

In the BettaFish architecture, multiple agents (Insight, Media, Query) run in parallel and write reports to disk. The ReportEngine must wait for all to finish before composing the final document. Polling file counts is a simple, robust synchronization mechanism that doesn't require inter-process communication. The baseline comparison ensures that pre-existing files don't cause false completion signals.

Code Evidence

FileCountBaseline initialization from `ReportEngine/agent.py:204,222-224`:

self.file_baseline = FileCountBaseline()
# ...
self._initialize_file_baseline()
# Ensures output directories exist
os.makedirs(self.config.OUTPUT_DIR, exist_ok=True)

SocketIO-based real-time updates from `app.py:37`:

socketio = SocketIO(app, cors_allowed_origins="*")

Completion status tracking from `ReportEngine/agent.py:742`:

completion_status['warningMessage'] = self._CONTENT_SPARSE_WARNING_TEXT

Related Pages

Page Connections

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