6 views
-/https://github.com/berriai/litellm/issues/31071
GitHub · issue

#31071 [Bug]: Custom code guardrail modify(images=...) is silently dropped on the request path

  • State: open
  • Author: @majinxinmjx
  • Labels: bug, llm translation

### Check for existing issues

- [x] I have searched the existing issues and checked that my issue is not a duplicate.

### What happened?

A bug happened! The custom_code guardrail exposes modify(texts=..., images=..., tool_calls=...) as the way a guardrail rewrites a request. On the request path (input_type="request"), the returned texts and tool_calls are written back to the outgoing messages, but the returned images are never applied. There is no error and no warning; the modification is just lost. A guardrail that returns modify(images=[]) to strip images, or modify(images=[...]) to rewrite them, has no effect, and the original image content is forwarded to the upstream model unchanged.

This is easy to miss because the guardrail itself runs successfully and any accompanying texts change does take effect, so the only way to discover it is by capturing the actual upstream request.

Repro

Configure a custom_code guardrail as a pre-call hook whose body is roughly:

def apply_guardrail(inputs, request_data, input_type): if input_type != "request": return allow() if not (inputs.get("images") or []): return allow() return modify(ima…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (1 events)
#0 of 0 · 31d18h18m56s ago — entered · #import:https:::github.com:berriai:litellm post #2636
The right item spans persistence semantics, query behavior, and UI validation with migration and backward-compatibility risk; the left is a localized request-rewrite propagation fix with focused tests.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search