Skip to content

fix(llm): compact on provider image limits - #127

Merged
MagMueller merged 1 commit into
mainfrom
fireworks-image-overflow
Jul 30, 2026
Merged

fix(llm): compact on provider image limits#127
MagMueller merged 1 commit into
mainfrom
fireworks-image-overflow

Conversation

@MagMueller

@MagMueller MagMueller commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Problem

Fireworks rejects Kimi conversations after more than 60 images with HTTP 400: Too many images were provided, we currently limit the number of images per conversation to 60.

BrowserCode currently classifies that as a fatal APIError, so its existing automatic media-stripping compaction never runs. Production saw this exact signature across multiple Kimi runs.

Fix

Classify the provider image-count rejection as context overflow. That routes it through the existing overflow recovery path: compact with media stripped, retry the interrupted turn, and preserve the stable compacted prefix instead of truncating every request to the newest 60 images.

This composes with #125, which ensures a recovered overflow does not emit a terminal error or exit nonzero.

Verification

  • packages/llm: bun test test/provider-error.test.ts (2 passed)
  • packages/llm: bun typecheck
  • packages/opencode: bun test test/session/message-v2.test.ts (36 passed)
  • packages/opencode: bun typecheck
  • repository pre-push filtered typecheck with Bun 1.3.14 (16 packages passed)
  • git diff --check

Release

Include this and merged #125 in stable v0.1.14; Cloud should update its exact bcode pin only after that release has published all binaries.


Summary by cubic

Classifies Fireworks/Kimi “Too many images … limit 60” errors as context overflow so we compact by stripping media and retry, instead of failing. This avoids 400s on long image threads and preserves the stable compacted prefix.

  • Bug Fixes
    • Add /too many images (?:were )?provided/i to overflow patterns in packages/llm.
    • Update tests in packages/llm and packages/opencode to cover the new classification.

Written for commit 2968a2a. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Re-trigger cubic

@MagMueller
MagMueller merged commit e26b6ee into main Jul 30, 2026
3 checks passed
@MagMueller
MagMueller deleted the fireworks-image-overflow branch July 30, 2026 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant