Skip to content

Agent stuck in infinite scroll retry loop after session.close — no circuit breaker on repeated errors #22

Description

@dimdasci

Summary

A pi sub-agent entered an infinite retry loop sending scroll commands to a closed session. The daemon correctly returned SESSION_NOT_FOUND on every request, but the agent never broke out of the loop. Result: 608,970 failed scroll commands over 17 hours at ~10 req/s, bloating the log to 235 MB.

Reproduction

  1. Agent opens a session, navigates to a LinkedIn page, begins scrolling
  2. Session is closed (via session.close or externally)
  3. Agent continues issuing bproxy scroll -s <dead-session> in a tight loop
  4. Every command returns {"ok": false, "error_code": "SESSION_NOT_FOUND"}
  5. Agent never stops

Evidence from logs

# Session closed at 01:42
{"time":1781826140544,"action":"session.close","session":"6afr3v","event":"received"}

# Scrolls continue immediately after, every ~100ms
{"time":1781826141514,"action":"scroll","session":"6afr3v","event":"received"}
{"time":1781826141515,"event":"response","ok":false,"elapsed_ms":0,"error_code":"SESSION_NOT_FOUND"}
{"time":1781826141614,"action":"scroll","session":"6afr3v","event":"received"}
{"time":1781826141614,"event":"response","ok":false,"elapsed_ms":0,"error_code":"SESSION_NOT_FOUND"}
...
# Still going 17 hours later at 18:51
{"time":1781887876856,"action":"scroll","session":"6afr3v","event":"received"}
{"time":1781887876856,"event":"response","ok":false,"elapsed_ms":0,"error_code":"SESSION_NOT_FOUND"}

Impact

  • 608,970 wasted requests logged in 17 hours
  • Log file grew to 235 MB (1.2M lines), dominated by this single session

Proposed fix

The issue is on the client (CLI) side, not the daemon. The daemon behaves correctly (returns errors). The CLI should implement:

  1. Circuit breaker: If N consecutive commands to the same session return the same error (e.g., 3x SESSION_NOT_FOUND), the CLI should exit with a non-zero code and a clear message like "Session terminated — aborting" rather than returning the error to the caller in a way that allows silent retry.

  2. Rate limiting on errors: If the CLI receives errors at >1/s from the same session, introduce exponential backoff or hard-stop after a threshold.

  3. Session liveness check: Before executing a destructive action, optionally verify the session still exists (cheap tab list or internal state check).

Environment

  • bproxy v0.7.4
  • macOS, Chrome extension paired
  • Agent: pi with Haiku model (sub-agent in pipe mode)

Workaround

Manual kill <pid> on the stuck agent process.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions