Repository navigation
fix: enforce configurable per-model image input limits - #3562
Merged
wsp1911 merged 2 commits intoOct 27, 2026
Merged
Conversation
Contributor
Author
|
@wgqqqqq 您好,这个问题对于使用外部api来说很少见,但是对于使用自部署的模型来说相当致命,希望能review一下这个pr,限制给多模态模型的传入图片张数 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A vision model that accepts at most three images can reject a request after four
view_imageresults, then reject ordinary "Continue" messages because those pixels remain in history. Add an optional per-modelmax_images_per_requestsetting and enforce it on the complete outgoing request.Type and Areas
Bug fix. Configuration contracts, AI adapters, shared native runtime, Web UI model settings and attachment intake. Additional Rust changes mostly initialize the new optional field or preserve it through legacy model edits.
Motivation / Impact
With a configured limit of 3, a restored conversation containing four tool images sends only three images on plain continuation. Explicit user submissions above the selected route's limit are rejected before changing conversation state. Limits are model-specific; no provider-wide three-image restriction or agent-loop counter is introduced.
Verification
cargo test --offline --locked -p openbitfun-config-contracts --lib— 139 passed, including legacy JSON, runtime conversion, fingerprint stability, zero validation and custom-body compatibility.cargo test --offline --locked -p openbitfun-ai-adapters --lib client::image_budget::tests— 13 passed, including mixed user/tool inputs, parallel and multi-image results, four provider wire formats, all send entry points and actual loopback HTTP requests with limits changing from 5 to 3.cargo test --offline --locked -p openbitfun-core --no-default-features --features agent-runtime,git --lib -- configured_image_limit input_image_count registry_reports_image_budget_validation_path image_inputs_keep_pixels_for_native_models_and_tool_paths_for_text_models image_elision_advances_in_batches_and_never_reverts new_images_keep_earlier_sent_messages_unchanged_between_elision_batches provider_rejections_stop_after_one_request_for_http_and_stream_errorscargo test --offline --locked -p openbitfun-app-server --lib model_mutation_preserves_and_replaces_write_only_values— passed.cargo test --offline --locked -p openbitfun-cli --bin openbitfun model_selection::tests— passed.pnpm --dir src/web-ui exec vitest run src/flow_chat/constants/chatInputConfig.test.ts src/flow_chat/components/ChatInputImageIntake.test.ts src/infrastructure/config/components/modelEditorRequestSettings.test.ts src/flow_chat/utils/externalFileIntake.test.ts src/infrastructure/config/components/ModelSettingsDialog.presentation.test.ts src/app/scenes/settings/pages/ai/ModelSettingsPage.presentation.test.ts src/flow_chat/components/ModelSelectorProviderLevels.test.tsx src/app/scenes/settings/pages/ai/ModelSettingsPage.loading.test.tsx src/flow_chat/utils/modelImageBudget.test.tspnpm run check:web, finalpnpm --dir src/web-ui exec tsc --noEmit,pnpm run i18n:audit,node scripts/format-changed-rust.mjs --checkandgit diff --cached --check— passed.Reviewer Notes
AI-assisted. Testing level: focused automated validation with synthetic credentials, temporary session state and loopback HTTP fixtures; model-setting entry/save/reset is covered by DOM tests. Native GUI appearance, live self-hosted providers, SSH workspaces, Remote Connect, Peer Device Mode and Detached Dispatch transports were not exercised. The limit is enforced by the upgraded executing host; older hosts ignore the optional setting and must be upgraded. It does not infer unknown provider limits from an error response.
Checklist