feat(bedrock): skip dummy user continue for assistant prefix prefill - #25419
Conversation
When modify_params is true, Bedrock Converse setup no longer prepends or appends the default user message if the boundary assistant turn has prefix: true, so OpenAI-style assistant prefill reaches the API unchanged. Made-with: Cursor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR fixes Confidence Score: 5/5This PR is safe to merge — it makes a targeted, well-tested fix to the Bedrock message preprocessing path. The change is a two-line guard added to each of two symmetric code paths, both properly covered by new mock-only unit tests. No regressions are introduced to the default (non-prefix) behavior, and no custom rules are violated. No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/litellm_core_utils/prompt_templates/factory.py | Added prefix guard to both leading and trailing assistant-message injection paths in _initial_message_setup; logic is correct and minimal. |
| tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py | Adds two new mock-only unit tests verifying that trailing and leading prefix: true assistant messages do not trigger dummy-user injection; tests are correct and do not weaken existing coverage. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[_initial_message_setup] --> B{messages empty?}
B -->|yes| C[Inject continue message]
B -->|no| D{first msg is assistant?}
D -->|no| F{last msg is assistant?}
D -->|yes| E{prefix == true?}
E -->|yes| F
E -->|no| G[Prepend user continue message]
G --> F
F -->|no| Z[Return messages]
F -->|yes| H{prefix == true?}
H -->|yes| Z
H -->|no| I[Append user continue message]
I --> Z
Reviews (1): Last reviewed commit: "feat(bedrock): skip dummy user continue ..." | Re-trigger Greptile
40d8a25
into
litellm_internal_staging_04_11_2026
…erriAI#25419) When modify_params is true, Bedrock Converse setup no longer prepends or appends the default user message if the boundary assistant turn has prefix: true, so OpenAI-style assistant prefill reaches the API unchanged. Made-with: Cursor
Summary
Bedrock Converse message setup used to append (or prepend) the default user continue message (
Please continue.) whenevermodify_paramswas true and an assistant message sat at the start or end of the transcript. That breaks OpenAI-style assistant prefill (prefix: true), where the partial assistant turn must remain last.Fixes #17990
Fixes #24158
Fixes LIT-2310
Change
BedrockConverseMessagesProcessor._initial_message_setup, skip injecting the dummy user turn when the boundary assistant message hasprefix: true.Tests
test_bedrock_converse_trailing_prefix_assistant_skips_user_continuetest_bedrock_converse_leading_prefix_assistant_skips_user_continue