|
Hi! We want to use guardrail detection actions to track user behavior in our Strands Agents–based chat app. Note that we are self-hosting the LiteLLM proxy. In our case, we define the guardrailConfig on the request itself (example below) rather than in the config.yaml of the LiteLLM proxy. When we access Bedrock directly, we were able to confirm the guardrail is applied (e.g., by changing detection mode to block and verifying the input was blocked), but we still were not able to get the trace in the response. Here is a working example using LiteLLM (https://docs.litellm.ai/docs/providers/bedrock#usage---bedrock-guardrails): Our attempt using Strands Agents with LiteLLM: Is it possible to achieve guardrail detection and especially getting the trace using Strands Agents together with LiteLLM? |
Replies: 2 comments
|
Hi @naorlevi1, thanks for the detailed writeup, and sorry for the very late response; it shouldn't have taken this long. Two separate things are going on here. Passing For your detection-mode tracking use case there are two paths that work today. The first is going to Bedrock directly. |
|
Separately, on making this better going forward: #1925 is an open ask for first-class observability when guardrails trigger. If that's your use case too, give it a 👍 so we know more people want it. The LiteLLM-specific piece (passing provider response fields like the trace through) isn't tracked anywhere yet, so if the hook approach doesn't cut it, open a feature request and we'll take it from there. |
Hi @naorlevi1, thanks for the detailed writeup, and sorry for the very late response; it shouldn't have taken this long.
Two separate things are going on here. Passing
guardrailConfiginsideparamsdoes work for enforcement: everything inparamsis forwarded as-is to thelitellm.completioncall, which matches your working raw LiteLLM example. But the trace is a different story. The Strands LiteLLM provider only reads message content, tool calls, the finish reason, and token usage from LiteLLM responses, so any guardrail trace data that comes back is dropped before it reaches you. There's currently no way to get the trace out throughLiteLLMModel. So what you're seeing is expected, not a c…