Session Example: Redundant Polling Anti-Pattern (Extreme Case)
Context
Cron job running as VisualAgent backend service. Task: monitor /sdcard/VisualAgent/commands/ for new .json command files, execute them, save results to /sdcard/VisualAgent/results/.
What Happened
First check (iteration 1):
su -c "ls -la /sdcard/VisualAgent/commands/"returned:myfile.dat(13 bytes, not JSON)test.txt(5 bytes, not JSON)- No
.jsonfiles present
.processed_filescheck (iteration 1): Listed 7 already-processed files:test_screenshot.json,test_tap.json,va_cmd.json,va_tap.json,va_swipe.json,va_input.json,va_app.json
Subsequent behavior: The agent ran the exact same
lscommand 130+ times across iterations 2-133, each time getting the same result (no JSON files, same two non-JSON files).Outcome: Hit the max tool-calling iteration limit. Final response was forced to summarize findings without completing any actual work.
Root Cause
The agent was waiting for new command files to appear, but:
- No new files were being dropped into the directory
- The two existing files were not JSON and not valid commands
- The agent kept polling instead of recognizing the "steady state" and responding
[SILENT]
Correct Behavior
After the first check confirms:
- Directory exists ✓
- No
.jsonfiles present ✓ .processed_filesshows all historical commands were handled ✓
→ Respond [SILENT] immediately. No further checks needed.
The Steady State Signal
When ALL of these are true, the service is in "steady state":
- Commands directory exists and is readable
- No unprocessed
.jsonfiles (after checking bothlsand cross-referencing.processed_files) - Results directory exists
- Historical processed files are recorded (in
.processed_filesorprocessed/directory)
The existence of processed-file tracking (.processed_files with entries, or files in processed/) is evidence that the service infrastructure is operational. No health check is needed.
Anti-Pattern Checklist
- [ ] Ran the same command more than 3 times with identical arguments
- [ ] Got the same result each time
- [ ] Did not change strategy after repeated identical results
- [ ] Did not respond
[SILENT]when directory was clearly empty - [ ] Hit iteration limit without producing meaningful output
If any box is checked, you fell into the redundant polling trap.
Recovery
If you realize you're in a polling loop:
- Stop immediately — do not run the command again
- Assess: has anything changed since the last check?
- If no → respond
[SILENT] - If yes but you can't process it → explain the blocker
- Never retry the exact same command more than twice
Cross-References
references/cron-polling-anti-patterns.md— General polling guidancereferences/cron-empty-directory-silent-pattern.md— When to respond[SILENT]references/tool-loop-guardrail.md— What happens when you retry too many times