Repository navigation
test(integration): fence internal params out of provider bodies and denylist stream_chunk_size - #42529
Closed
devin-ai-integration[bot] wants to merge 2 commits into
Closed
test(integration): fence internal params out of provider bodies and denylist stream_chunk_size#42529devin-ai-integration[bot] wants to merge 2 commits into
devin-ai-integration[bot] wants to merge 2 commits into
Conversation
…enylist stream_chunk_size
… denylist does not break converse streaming Adding stream_chunk_size to all_litellm_params made get_non_default_completion_params strip it from optional_params, so converse_handler always popped None. Forward it through get_litellm_params' FORWARDED_KWARGS_KEYS and read it from litellm_params instead
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
4 of 6 tasks
Contributor
Author
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
Contributor
|
Main already keeps stream_chunk_size out of provider request bodies and keeps Bedrock streaming working since #42664, so closing this. Reopen if something is missing |
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.
TLDR
Problem this solves:
stream_chunk_sizeleaked into OpenAI, Azure, Anthropic and Bedrock Converse request bodiesHow it solves it:
stream_chunk_sizetoall_litellm_paramsso it is stripped from provider bodiesstream_chunk_sizeto Bedrock Converse throughlitellm_paramsinstead ofoptional_paramsUser Flow
Before: a developer who sets
stream_chunk_sizeon a streaming call gets a 400 back from the provider because the key ends up in the request bodylitellm.completion(model="openai/gpt-5", messages=[...], stream=True, stream_chunk_size=1024)stream_chunk_sizeparameter (same for Anthropic and Azure)additionalModelRequestFieldsand the request fails the same wayAfter: the same call succeeds and the provider body only carries the fields the provider knows
litellm.completion(model="openai/gpt-5", messages=[...], stream=True, stream_chunk_size=1024)stream_chunk_sizein the body and streams back normallyRelevant issues
Related to #17357 (Bedrock Converse
stream_chunk_sizeplumbing)Affected release
Linear ticket
Resolves LIT-8316 for PR 1
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
The change is a request-body fence, so the proof is a mutation run against the scripted upstream in
tests/integration/_support/upstream.py, which returns 400 whenever an internal field appears in a body. Run from the repo root withLITELLM_LOCAL_MODEL_COST_MAP=True uv run --no-sync pytest. Full log at /home/ubuntu/leak1_proof.txt on the author boxBefore (e0c2cbf, denylist entry removed)
Wire fence
sed -i '/^ "stream_chunk_size",$/d' litellm/types/utils.pypytest tests/integration/providers/test_internal_params_wire.py -q16 failed, 8 passed, 15 warnings in 4.43s, every failure readsinternal fields reached the provider body [stream_chunk_size]for openai, azure, anthropic and bedrock_converse x nonstream/stream x sync/asyncBedrock Converse plumbing
FORWARDED_KWARGS_KEYSin litellm/litellm_core_utils/get_litellm_params.py toAWS_CREDENTIAL_KWARGS_KEYSpytest tests/unit/llms/chat/test_converse_handler.py tests/test_litellm/litellm_core_utils/test_get_litellm_params.py -k stream_chunk_size -q2 failed, 1 passed, 55 deselected(test_completion_plumbs_stream_chunk_size_through_converse,test_get_litellm_params_forwards_stream_chunk_size_only_when_passed)After (d6a4fb9)
Wire fence
git checkout litellm/types/utils.pypytest tests/integration/providers/test_internal_params_wire.py -q24 passed, 15 warnings in 4.90sBedrock Converse plumbing
pytest tests/unit/llms/chat/test_converse_handler.py -k stream_chunk_size -q->2 passed, 14 deselectedpytest tests/test_litellm/litellm_core_utils/test_get_litellm_params.py -k stream_chunk_size -q->1 passedpytest tests/unit/llms/bedrock/chat/invoke_transformations/test_base_invoke_transformation.py tests/test_litellm/llms/bedrock/chat/test_invoke_handler.py -q -k stream_chunk_size->6 passed, 36 deselectedmake check->check: PASS(Python lint, test-tree lint and dashboard API-type sync ran; e2e and dashboard lint skipped as out of scope)Type
🐛 Bug Fix
✅ Test
Caveats (if any)
Low
get_litellm_params.pyforwardsstream_chunk_sizeintolitellm_paramsconverse_handler.pyreads it fromlitellm_paramsinstead of poppingoptional_paramsstream_chunk_sizeand drops it beforemake_call/make_sync_calllitellm_paramspassed into the custom stream wrapper hooks (base plus seven overrides), left for a later PR in this stackextra_bodykeys as{"extra_body": {...}}in the bodyruff format --checkflags pre-existing lines in upstream.py and test_get_litellm_params.pyFinal Attestation
Link to Devin session: https://app.devin.ai/sessions/748b43f48ad746409070956e132a8fd9
Open in Devin Desktop: https://app.devin.ai/desktop/session/748b43f48ad746409070956e132a8fd9?variant=devin
Requested by: @shreshth-berri