thiagowfx's avatar

Β¬ just serendipity πŸ€ (not just serendipity)

pi: auto-retry stalled requests

β€’ 208 words β€’ 1 min β€’ updated

Previously.

Problem statement: sometimes a prompt in pi just hangs, as if the network dropped. It never recovers on its own β€” I have to hit Esc and re-prompt.

It’s 2026, this symptom should be self-recoverable.

Pi already has agent-level retry on transient errors (retry.enabled defaults to true). The catch is when it fires: a stalled connection isn’t an error until the HTTP idle timeout trips, and that defaults to five minutes:

httpIdleTimeoutMs | number | 300000 | HTTP header/body idle timeout in milliseconds […] Set to 0 to disable.

So pi would have eventually recovered. I was just quitting long before the five-minute clock ran out. Who has patience to wait for 5 minutes?!

:∴ Lower the idle timeout to O(seconds) instead:

json
{
  "httpIdleTimeoutMs": 30000,
  "retry": {
    "enabled": true,
    "maxRetries": 5,
    "baseDelayMs": 2000
  }
}

Dropped into ~/.pi/agent/settings.json, documented in docs/settings.md. Now a stall errors out after 30s and pi retries automatically with exponential backoff (2s, 4s, 8s…), up to five attempts. There’s no need for Esc nor re-prompting.

The idle timer resets on every byte received, so long thinking or a slow stream won’t trip it β€” only a genuinely dead connection will. Restart pi for the change to take effect.


πŸ€– Drafted with /bloggify.