session-pure-polling-trap-100-iterations.md 3.92 KB

Session Reference: Pure Polling Trap — 100+ Iterations on Empty Directory

Session Context

  • Date: 2026-06-26
  • Trigger: Cron job tasked with monitoring /sdcard/VisualAgent/commands/ for JSON command files
  • Initial state: Directory existed but contained only 2 non-JSON files (myfile.dat, test.txt)
  • Historical state: .processed_files showed 7+ commands already handled; processed/ directory had 50+ files; results/ had 50+ result files
  • Daemon state: PID file existed but process was dead (stale PID)

The Trap

The agent executed the following pattern over 100 times:

su -c "find /sdcard/VisualAgent/commands/ -maxdepth 1 -type f | sort"

Each call returned the exact same output:

/sdcard/VisualAgent/commands/myfile.dat
/sdcard/VisualAgent/commands/test.txt

The agent then checked for recently modified files:

su -c "find /sdcard/VisualAgent/ -maxdepth 2 -type f -mmin -5 | sort"

This also returned empty every time.

Why It Happened

  1. No fallback plan: After the first 2-3 checks confirmed the directory was empty, the agent had no "stop" condition programmed into its workflow
  2. "Service" framing: The user said "You are a VisualAgent backend service" which primed the agent to "keep monitoring" rather than "check once and exit"
  3. No error signal: Each find call succeeded (exit code 0), so no tool-loop guardrail fired
  4. Silent success iteration exhaustion: The tool-loop guardrail only blocks after 5 identical failed calls. Since each call "succeeded" (returned valid output), the agent could run the same command indefinitely until the ~150 max iteration limit

Steady State Signals (Available from Check #1)

These signals were all present after the very first directory check:

  1. No .json files: find ... -name '*.json' returned empty
  2. Only non-JSON files: myfile.dat and test.txt (not command files)
  3. Operational history: processed/ had 50+ files, results/ had 50+ files, .processed_files had entries
  4. Daemon dead but infrastructure intact: PID stale, but directories and history prove the service works
  5. No recent activity: -mmin -5 returned empty (no new files in last 5 minutes)

Any ONE of these signals should have triggered an immediate [SILENT] response. All five were present.

The Correct Response

After the first check (or at most the third, per the Three-Check Rule):

[SILENT]

That's it. No explanation, no screenshot, no status report, no table.

Why the Agent Didn't Stop

The agent's mental model was "monitor continuously" rather than "check once per cron run." Each iteration was a new "check" in the agent's mind, as if something might have appeared in the milliseconds between calls. This is the polling illusion: the belief that checking more frequently increases the chance of finding something, when in reality the cron scheduler handles the "continuous" part by re-running the agent periodically.

Prevention

  1. Three-Check Rule: Never check the same directory more than 3 times in one session
  2. Steady state recognition: If the directory contents haven't changed after 3 checks, they won't change during this run
  3. Cron = single check: The cron job IS the monitoring loop; the agent's job is one check, not a loop
  4. No "service" framing: The agent is a cron job, not a persistent daemon. It checks once and exits.
  • session-redundant-polling-iteration-exhaustion.md — The "silent success" iteration exhaustion mechanism
  • session-redundant-polling-extreme-example.md — Another real session with the same pattern
  • session-cron-execute-code-blocked-then-polling-trap.md — When execute_code is blocked first, then polling trap follows
  • cron-empty-directory-silent-pattern.md — The correct [SILENT] response pattern
  • session-service-framing-verbose-report-cascade.md — How the "service" framing triggers unnecessary work