Skip to content

feat(bedrock): skip dummy user continue for assistant prefix prefill - #25419

Merged
krrish-berri-2 merged 1 commit into
litellm_internal_staging_04_11_2026from
litellm_bedrock-prefix-skip-dummy-user
Apr 11, 2026
Merged

feat(bedrock): skip dummy user continue for assistant prefix prefill#25419
krrish-berri-2 merged 1 commit into
litellm_internal_staging_04_11_2026from
litellm_bedrock-prefix-skip-dummy-user

Conversation

@Sameerlite

@Sameerlite Sameerlite commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Bedrock Converse message setup used to append (or prepend) the default user continue message (Please continue.) whenever modify_params was 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

  • In BedrockConverseMessagesProcessor._initial_message_setup, skip injecting the dummy user turn when the boundary assistant message has prefix: true.
  • Covers both leading and trailing assistant turns.

Tests

  • test_bedrock_converse_trailing_prefix_assistant_skips_user_continue
  • test_bedrock_converse_leading_prefix_assistant_skips_user_continue
# LiteLLM settings
litellm_settings:
  set_verbose: false
  drop_params: false
  modify_params: true
image

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
@vercel

vercel Bot commented Apr 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Apr 9, 2026 11:23am

Request Review

@codspeed-hq

codspeed-hq Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 16 untouched benchmarks


Comparing litellm_bedrock-prefix-skip-dummy-user (86c1b88) with main (97f722f)

Open in CodSpeed

@greptile-apps

greptile-apps Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes BedrockConverseMessagesProcessor._initial_message_setup to skip injecting a dummy "Please continue." user turn when the boundary assistant message carries prefix: true (OpenAI-style assistant prefill). Both the leading and trailing assistant cases are covered, and two new focused unit tests confirm the expected behavior.

Confidence Score: 5/5

This 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.

Vulnerabilities

No security concerns identified.

Important Files Changed

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
Loading

Reviews (1): Last reviewed commit: "feat(bedrock): skip dummy user continue ..." | Re-trigger Greptile

@krrish-berri-2
krrish-berri-2 changed the base branch from main to litellm_internal_staging_04_11_2026 April 11, 2026 16:04
@krrish-berri-2
krrish-berri-2 merged commit 40d8a25 into litellm_internal_staging_04_11_2026 Apr 11, 2026
101 of 107 checks passed
@krrish-berri-2
krrish-berri-2 deleted the litellm_bedrock-prefix-skip-dummy-user branch April 11, 2026 16:04
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 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
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.

[Bug]: Bedrock rejects requests without tools= parameter, even for non-tool-use completions [Bug]: modify_params = True breaks prefix in Bedrock

2 participants