Skip to content

Conversation

@uc4w6c
Copy link
Contributor

@uc4w6c uc4w6c commented Nov 28, 2025

Title

fix: respect guardrail mock_response during during_call to return blocked output

Relevant issues

Fixes #15092

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🐛 Bug Fix
✅ Test

Changes

Example configuration:

  - guardrail_name: "bedrock-guard"
    litellm_params:
      guardrail: bedrock
      mode: "during_call"
      guardrailIdentifier: xxxxx
      guardrailVersion: "DRAFT"
      aws_region_name: us-east-1
      disable_exception_on_block: true

Example curl test:

curl -i  -X POST http://localhost:4001/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-1234" \
-d '{
    "model": "gpt-4o",
    "messages": [
        {
            "role": "user",
            "content": "My name is Yuta. Say my name."
        }
    ], "guardrails": ["bedrock-guard"]
}'
HTTP/1.1 200 OK
date: Fri, 28 Nov 2025 05:17:54 GMT
server: uvicorn
content-length: 316
content-type: application/json
x-litellm-call-id: 0b9dc18c-87f0-4aeb-bf62-87f19c41668c
x-litellm-version: 1.80.0
x-litellm-response-cost-original: 0.00016250000000000002
x-litellm-response-cost-discount-amount: 0.0
x-litellm-key-spend: 0.0
x-litellm-applied-guardrails: bedrock-guard

{"id":"chatcmpl-6ffa39bd-c3f4-4932-a555-b6e6a63fed06","created":1764307087,"model":"bedrock-guardrail","object":"chat.completion","choices":[{"finish_reason":"stop","index":0,"message":{"content":"The name cannot be returned.","role":"assistant"}}],"usage":{"completion_tokens":0,"prompt_tokens":0,"total_tokens":0}

@vercel
Copy link

vercel bot commented Nov 28, 2025

@uc4w6c is attempting to deploy a commit to the CLERKIEAI Team on Vercel.

A member of the Team first needs to authorize it.

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 Guardrail with during_call doesn't correctly use Guardrail output

1 participant