#9579·pi

Overflow image recovery uses a fixed 16 MiB budget that exceeds smaller provider request limits

Author: Ji-SirCreated Sep 14, 2026Updated Sep 17, 2026

What happened?

In pi 0.85.1, a provider with a 6 MiB request-body limit returns request_too_large. Overflow detection triggers compaction, but the retry remains oversized. capImagesToByteBudget() uses a fixed 16 MiB image budget, derived from the Anthropic 32 MiB limit, so it may drop no images for providers with smaller limits. The session remains unable to continue.

This appears to be the remaining provider-independent gap after #2734 and #5369. Prepared with AI assistance and reviewed against the observed error and current source.

Steps to reproduce

  1. Configure an OpenAI-compatible provider whose HTTP request limit is 6 MiB.
  2. Build a session whose retained text plus image data exceeds 6 MiB but whose images remain below 16 MiB.
  3. Send a turn and receive request_too_large.
  4. Pi compacts and retries, but the rebuilt request still exceeds 6 MiB.

The observed provider error reports Exceeded limit on max bytes to request body: 6291456.

Expected behavior

Overflow recovery should use a provider/model-aware request-byte budget, or progressively reduce the serialized payload until it is smaller than the failed request limit. A fixed 16 MiB image budget cannot guarantee recovery across providers.

Version

0.85.1