fix(models): correct cache, usage, streaming, and image outputs - #1653
Merged
Conversation
Include eval_type in model memoization, aggregate ModelScope usage across choices, preserve per-choice stream finish reasons, emit data URIs with elapsed timing for image outputs, and honor LiteLLM reasoning/base URL settings. Add regression coverage for each behavior.
git-jxj
marked this pull request as ready for review
August 27, 2026 10:13
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
This PR fixes six independent model-layer correctness issues:
eval_type.finish_reasonvalues.data:URI prefix required by downstream consumers.reasoning_historyand the configured base URL.Each behavior is covered by deterministic tests with mocked model or SDK dependencies.
Root Cause
The model cache key did not include
eval_type, so otherwise identical task and judge configurations could collide across backends.ModelScope usage and OpenAI-compatible stream metadata were assigned from a single choice instead of being aggregated or indexed per choice.
Image model adapters serialized raw base64 content and assigned
time.time()directly toModelOutput.time, while downstream APIs expect a data URI and elapsed seconds.The LiteLLM request builder did not forward the same reasoning-history and base-URL settings used by the OpenAI-compatible path.
Changes
eval_typein the model memoization key and document the cache contract.finish_reasonby choice index.reasoning_historyandbase_urlconfiguration.Reproduction
On the unmodified base:
The regression suite reports 11 failures against the old source. After this change, each configuration produces the intended backend, metadata, image payload, and timing value.
Validation
Targeted regression tests:
Result:
Model-layer regression suite:
Result:
CI smoke test:
Result:
All current Ruff and repository pre-commit checks passed.
Scope
These changes do not alter prompts, generation parameters, cache lifetime, retry behavior, image encoding content, or non-LiteLLM request routing. The branch is rebased onto the current
mainand contains one commit.