Franklin icon indicating copy to clipboard operation
Franklin copied to clipboard

Gateway truncates vision payloads at ~1 MB — request for parity with upstream provider limits

Open KillerQueen-Z opened this issue 6 months ago • 0 comments

Summary

The BlockRun gateway appears to truncate vision (image) payloads at approximately 1–1.5 MB of base64-encoded body, even though the upstream providers (Anthropic, OpenAI, Google) accept significantly larger images. This creates a poor user experience for legitimate use cases (high-resolution screenshots, AI-generated images, document scans) and forces every client to implement aggressive client-side compression as a workaround.

Reproduction

  1. Send a vision request to /v1/messages (or equivalent) with a single image around 1.5–2 MB (e.g., 1024×1024 PNG, AI-generated)
  2. Observe the model's response includes language like "image data was truncated" or "I can only see metadata"
  3. The same image sent direct to Anthropic's API works correctly

Concrete cases observed

  • 1.4 MB / 1024×1024 PNG (AI-generated pear image) → truncated
  • 1.87 MB / 1024×1024 PNG (Azure ImageGen output) → truncated, model reads only filename + metadata
  • < 800 KB images → consistently work

Why this matters

The Franklin VS Code extension just shipped paste/drop image support. We currently work around the gateway limit with client-side resize-to-1280px + JPEG q85 compression, which:

  • Loses quality unnecessarily for legitimate high-resolution use cases
  • Adds compute overhead in the webview before every send
  • Differs from Anthropic / OpenAI / Google native behavior, surprising users
  • Forces the same workaround on every client (CLI, future Web UI, third-party agents using BlockRun gateway)

Recommended limits (matches upstream)

Limit Recommended Source
Per image 5 MB Anthropic native limit
Per request total 25 MB Allows ~5 images at max
Max dimensions 8000 × 8000 Anthropic native limit
Max images per request 5 (configurable) Reasonable default for agents

Reverse proxy:

  • client_max_body_size: 30 MB (5 MB headroom over per-request)
  • Request timeout: 60s

Abuse prevention (better than byte caps)

  • Token-based pricing already in place — image_tokens ≈ (width × height) / 750 is itself an economic constraint (e.g., a 4K image = ~22k tokens = several cents per call)
  • Existing per-wallet USDC rate limits already protect against bulk abuse
  • Hard reject on dimensions > 8000 px is sufficient to stop pathological inputs

Impact

Once this is fixed, Franklin can:

  • Bump VS Code extension's client-side normalization from 1280px → 1568px (Anthropic's recommended sweet spot)
  • Match Claude Code / Cursor / Codex user experience for image input
  • Remove the resize-on-paste latency entirely for typical screenshots

Environment

  • BlockRun gateway: production endpoint
  • Tested with: anthropic/claude-sonnet-4.6, google/gemini-2.5-flash
  • Both showed truncation behavior, suggesting it's gateway-side, not provider-side

KillerQueen-Z avatar May 09 '26 21:05 KillerQueen-Z