Skip to content

fix(decisions): accept OpenAI input_json content parts on /v1/decisions - #52805

Merged
mateo-berri merged 11 commits into
BerriAI:mainfrom
zoveki:litellm_decisions_input_json
Nov 20, 2026
Merged

mateo-berri merged 11 commits into
BerriAI:mainfrom
zoveki:litellm_decisions_input_json

Conversation

@zoveki

@zoveki zoveki commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Handwritten 1-3 sentence description

/v1/decisions now accepts OpenAI's input_json content parts, so structured evidence like an order record can go straight to OpenAI instead of being stuffed into text first. Providers that can't take JSON input refuse it with a clear 400, or drop it when the deployment sets drop_params

Details

TLDR

Problem this solves:

  • /v1/decisions answers 400 on OpenAI's input_json content parts
  • The same body works when sent to OpenAI directly

How it solves it:

  • User messages accept input_json parts with object or array-of-objects data
  • OpenAI and Azure deployments forward the part unchanged
  • Other providers answer 400 naming input_json, or drop it under drop_params
  • A mixed model group sends JSON requests to deployments that take JSON
  • Under drop_params the others stay in unless the drop leaves no input
  • Secret redaction and text guardrails read the strings inside input_json data

User Flow

Before: the gateway answers 400 to a decisions request that OpenAI accepts

  1. The app sends POST https://litellm-domain/v1/decisions for an OpenAI decisions model with an input_text part and an input_json part
  2. The gateway answers 400 Input tag 'input_json' found using 'type' does not match any of the expected tags
  3. The app has to turn the JSON into text to get a decision

After: the same request gets OpenAI's decision

  1. The app sends the same request
  2. The gateway answers 200 with OpenAI's decision
  3. A deployment whose provider has no JSON input answers 400 naming input_json, or drops the part under drop_params

Relevant issues

Part of #49127, which asks for every OpenAI Decisions request feature. This PR covers only input_json

Linear ticket

Resolves LIT-10883

Pre-Submission checklist

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

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • Every automated review on my PR's latest commit has finished, and I have addressed or replied to each of its findings before requesting a maintainer review

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Decisions and the alternatives not taken
  1. data must be an object or an array of objects, because OpenAI answers 400 invalid_type for a string or an array of scalars. The alternative was any JSON value with OpenAI refusing it, which costs a round trip and gives a different error per provider
  2. An input_json part takes no prompt_cache_breakpoint, because OpenAI answers 400 unknown_parameter for it. Without drop_params the gateway answers 400, and with it the breakpoint is dropped, per litellm's convention for an unsupported param
  3. OpenAI's size limits (32 levels, 10,000 values, 256 KiB) are left to OpenAI. Copying them locally would pin a vendor limit that can change
  4. A provider without JSON input answers 400 naming input_json, or drops the part under drop_params. Rendering the JSON as text for those providers was not chosen, since it changes what the model sees without the caller asking
  5. Azure inherits OpenAI's support, because Azure's own validator lists input_json among the part types it takes. Its 400 for an input_xml part says "Supported values are: 'input_text', 'input_image', and 'input_json'". No Azure Decisions model answers a call yet, so there is no live Azure leg, and a unit test checks that Azure gets the part unchanged. Vercel AI Gateway does not inherit it, since nothing shows its decisions schema takes input_json, which matches how fix(decisions): forward OpenAI prompt cache fields #51457 treated the developer role. Forwarding it unverified is the alternative, and stays open for anyone who can test Vercel
  6. Developer and system messages stay text only, matching OpenAI's 400 for input_json there
  7. A malformed input_json (string or scalar data, or the part in a developer message) is refused even under drop_params, like an image in a developer message today. Dropping it like a malformed image URL is the alternative
  8. In a model group that mixes providers with and without JSON input, a request carrying input_json skips the deployments that would refuse it, unless that leaves none. This is how the router already treats audio and videos. Letting each pick refuse on its own was the alternative, and it made the same request answer 400 or 200 depending on which deployment was picked. Under drop_params a deployment without JSON input stays a candidate when the request has other input, and drops the part, the same as audio and videos, so one request can be decided with or without the evidence. Preferring the deployments that take JSON even then is the alternative not taken, since drop_params is how a caller says a dropped part is acceptable. A deployment is still skipped when the drop would leave it no input, counting the images and developer and system messages it also drops, since it would answer 400. An image counts as kept only when its data URL or base64 type is one the deployment takes, so an image URL counts as dropped on a deployment that takes only some image types, since the router cannot see a URL's type without fetching it. Fetching each image in the router was the alternative, which adds a download to every routing decision. So a request whose user message holds only input_json goes only to the deployments that take JSON
  9. Spend logs that keep only the latest turn (spend_logs_prompt_storage: latest_turn) show an input_json part as [json omitted], like [image omitted] for an image. Storing the JSON there is the alternative, which would copy caller records into spend logs
  10. Instructions as content parts and the Admin UI playground's request schema are out of scope here ([Feature]: Support all OpenAI Decisions request features on /v1/decisions (developer/system/tool items, input_json, prompt caching, image instructions, 400 questions) #49127)
  11. Text guardrails see data as one JSON string. hide_secrets redacts the secrets it finds in the string values and keys inside data in place, and leaves numbers and the structure as they are. When two keys in one object redact to the same text, the next one gets a number, as in [REDACTED] (2), so no value is overwritten. Sending the redacted JSON as text was the alternative, which would change the part type OpenAI gets
  12. LLM Shield checks the strings, numbers and keys inside data, since a phone or account number can be the personal detail itself. A number it masks comes back as the masked string, so that value changes from a number to a string, and the numbers it leaves alone keep their type. The same walk runs on input_json parts sent to /v1/responses. Skipping numbers was the alternative, which sent them to the provider unmasked
  13. Cisco AI Defense cannot rewrite input_json data in place, so a redact verdict on a request whose input carries it answers 400 in every mode, monitor included, whatever other fields the request has. Letting it through unredacted in monitor mode, as happens to other input Cisco cannot rewrite, was the alternative, but that sends the flagged data to the provider. Rewriting the input as Cisco's sanitized text was not chosen either, since it turns the JSON into text

Screenshots / Proof of Fix

Before is the merge base 436f6d5 and After is e74b5be, each on 2 uvicorn workers with its own Postgres on the shared QA box and no Redis. Calls went to real OpenAI (gpt-6-luna) and real Gemini (gemini-decision-1) with curl. The OpenAI SDK run is under Round 1

Last updated: 264f9f7, where the unit tests and make check pass. /live-pr-risk below repeats every round

Case Before After
Object data, OpenAI 400 200
Array data, OpenAI 400 200
Gemini, no drop_params 400 400 names input_json
Gemini, drop_params 400 200
Breakpoint on input_json 400 400, matches OpenAI

Headline case, object data sent to OpenAI

  1. Boot the proxy with the config below, LITELLM_MASTER_KEY, OPENAI_API_KEY and GEMINI_API_KEY set, and --num_workers 2
  2. Run cases.sh with PROXY_URL set to the proxy and LITELLM_MASTER_KEY exported. It prints each command before it runs it
  3. Compare with the same body sent straight to OpenAI
Request body and output at the base, at e74b5be and at fd71cae, and from OpenAI directly

Request body customer.json

{"model": "litellm-qa-decisions", "input": [{"role": "user", "content": [{"type": "input_text", "text": "Evaluate the ticket using the order evidence."}, {"type": "input_json", "data": {"ticket": {"body": "Please refund the duplicate charge."}, "order": {"charges": [49, 49]}}}]}], "questions": [{"type": "predicate", "name": "duplicate_charge", "instructions": "Does the ticket describe a duplicate charge supported by the order?"}]}

Before (base 436f6d5)

$ curl -s -w '\nHTTP %{http_code}\n' $PROXY_URL/v1/decisions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' -d @customer.json
{"error":{"message":"litellm.BadRequestError: Invalid Decisions request: 3 validation errors for OpenAIDecisionRequestBody\ninput.str\n  Input should be a valid string [type=string_type, input_value=({'role': 'user', 'conten...harges': [49, 49]}}})},), input_type=tuple]\n    For further information visit https://errors.pydantic.dev/2.13/v/string_type\ninput.json-or-python[json=list[function-after[_developer_and_system_are_text(), OpenAIDecisionInputMessage]],python=chain[is-instance[Sequence],function-wrap[sequence_validator()]]].0.content.str\n  Input should be a valid string [type=string_type, input_value=({'type': 'input_text', '...{'charges': [49, 49]}}}), input_type=tuple]\n    For further information visit https://errors.pydantic.dev/2.13/v/string_type\ninput.json-or-python[json=list[function-after[_developer_and_system_are_text(), OpenAIDecisionInputMessage]],python=chain[is-instance[Sequence],function-wrap[sequence_validator()]]].0.content.`json-or-python[json=list[tagged-union[...,...]],python=chain[is-instance[Sequence],function-wrap[sequence_validator()]]]`.1\n  Input tag 'input_json' found using 'type' does not match any of the expected tags: 'input_text', 'input_image' [type=union_tag_invalid, input_value={'type': 'input_json', 'd... {'charges': [49, 49]}}}, input_type=dict]\n    For further information visit https://errors.pydantic.dev/2.13/v/union_tag_invalid","type":"invalid_request_error","param":null,"code":"400"}}
HTTP 400

After (head e74b5be)

$ curl -s -w '\nHTTP %{http_code}\n' $PROXY_URL/v1/decisions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' -d @customer.json
{"model":"gpt-6-luna","answers":[{"type":"predicate","name":"duplicate_charge","probability":1.0}],"usage":{"input_tokens":189,"input_tokens_details":{"cached_tokens":0,"cache_write_tokens":0},"output_tokens":0,"output_tokens_details":{"reasoning_tokens":0},"total_tokens":189}}
HTTP 200

The same body sent straight to OpenAI gives the same answer

openai-direct.json, which is customer.json with OpenAI's model name
{"model": "gpt-6-luna", "input": [{"role": "user", "content": [{"type": "input_text", "text": "Evaluate the ticket using the order evidence."}, {"type": "input_json", "data": {"ticket": {"body": "Please refund the duplicate charge."}, "order": {"charges": [49, 49]}}}]}], "questions": [{"type": "predicate", "name": "duplicate_charge", "instructions": "Does the ticket describe a duplicate charge supported by the order?"}]}
$ curl -s -w '\nHTTP %{http_code}\n' https://api.openai.com/v1/decisions -H "Authorization: Bearer $OPENAI_API_KEY" -H 'Content-Type: application/json' -d @openai-direct.json
{"model":"gpt-6-luna","answers":[{"type":"predicate","name":"duplicate_charge","probability":1.0}],"usage":{"input_tokens":189,"input_tokens_details":{"cached_tokens":0,"cache_write_tokens":0},"output_tokens":0,"output_tokens_details":{"reasoning_tokens":0},"total_tokens":189}}
HTTP 200

At fd71cae

$ curl -s -D hdr.txt -w '\nHTTP %{http_code}\n' $PROXY_URL/v1/decisions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' -d @customer.json
{"model":"gpt-6-luna","answers":[{"type":"predicate","name":"duplicate_charge","probability":1.0}],"usage":{"input_tokens":189,"input_tokens_details":{"cached_tokens":0,"cache_write_tokens":0},"output_tokens":0,"output_tokens_details":{"reasoning_tokens":0},"total_tokens":189}}
HTTP 200
$ grep -i '^x-litellm-model-api-base' hdr.txt
x-litellm-model-api-base: https://api.openai.com
config.yaml and cases.sh
model_list:
  - model_name: litellm-qa-decisions
    litellm_params:
      model: openai/gpt-6-luna
      api_key: os.environ/OPENAI_API_KEY
  - model_name: litellm-qa-decisions-gemini
    litellm_params:
      model: gemini/gemini-decision-1
      api_key: os.environ/GEMINI_API_KEY
  - model_name: litellm-qa-decisions-gemini-drop
    litellm_params:
      model: gemini/gemini-decision-1
      api_key: os.environ/GEMINI_API_KEY
      drop_params: true
general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY
#!/bin/zsh
cd ${0:A:h}
for case in customer array gemini gemini-drop breakpoint; do
  print -r -- "#### $case"
  cmd="curl -s -w '\nHTTP %{http_code}\n' \$PROXY_URL/v1/decisions -H \"Authorization: Bearer \$LITELLM_MASTER_KEY\" -H 'Content-Type: application/json' -d @$case.json"
  printf '$ %s\n' "$cmd"
  eval "$cmd"
done
Array of objects as `data`

Request body array.json

{"model": "litellm-qa-decisions", "input": [{"role": "user", "content": [{"type": "input_text", "text": "Evaluate the ticket using the order evidence."}, {"type": "input_json", "data": [{"body": "Please refund the duplicate charge."}, {"charges": [49, 49]}]}]}], "questions": [{"type": "predicate", "name": "duplicate_charge", "instructions": "Does the ticket describe a duplicate charge supported by the order?"}]}

Before (base 436f6d5)

$ curl -s -w '\nHTTP %{http_code}\n' $PROXY_URL/v1/decisions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' -d @array.json
{"error":{"message":"litellm.BadRequestError: Invalid Decisions request: 3 validation errors for OpenAIDecisionRequestBody\ninput.str\n  Input should be a valid string [type=string_type, input_value=({'role': 'user', 'conten...harges': [49, 49]}]})},), input_type=tuple]\n    For further information visit https://errors.pydantic.dev/2.13/v/string_type\ninput.json-or-python[json=list[function-after[_developer_and_system_are_text(), OpenAIDecisionInputMessage]],python=chain[is-instance[Sequence],function-wrap[sequence_validator()]]].0.content.str\n  Input should be a valid string [type=string_type, input_value=({'type': 'input_text', '...{'charges': [49, 49]}]}), input_type=tuple]\n    For further information visit https://errors.pydantic.dev/2.13/v/string_type\ninput.json-or-python[json=list[function-after[_developer_and_system_are_text(), OpenAIDecisionInputMessage]],python=chain[is-instance[Sequence],function-wrap[sequence_validator()]]].0.content.`json-or-python[json=list[tagged-union[...,...]],python=chain[is-instance[Sequence],function-wrap[sequence_validator()]]]`.1\n  Input tag 'input_json' found using 'type' does not match any of the expected tags: 'input_text', 'input_image' [type=union_tag_invalid, input_value={'type': 'input_json', 'd... {'charges': [49, 49]}]}, input_type=dict]\n    For further information visit https://errors.pydantic.dev/2.13/v/union_tag_invalid","type":"invalid_request_error","param":null,"code":"400"}}
HTTP 400

After (head e74b5be)

$ curl -s -w '\nHTTP %{http_code}\n' $PROXY_URL/v1/decisions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' -d @array.json
{"model":"gpt-6-luna","answers":[{"type":"predicate","name":"duplicate_charge","probability":0.99}],"usage":{"input_tokens":185,"input_tokens_details":{"cached_tokens":0,"cache_write_tokens":0},"output_tokens":0,"output_tokens_details":{"reasoning_tokens":0},"total_tokens":185}}
HTTP 200
Gemini deployment without drop_params

Request body gemini.json

{"model":"litellm-qa-decisions-gemini","input":[{"role":"user","content":[{"type":"input_text","text":"Evaluate the ticket using the order evidence."},{"type":"input_json","data":{"ticket":{"body":"Please refund the duplicate charge."},"order":{"charges":[49,49]}}}]}],"questions":[{"type":"predicate","name":"duplicate_charge","instructions":"Does the ticket describe a duplicate charge supported by the order?"}]}

Before (base 436f6d5)

$ curl -s -w '\nHTTP %{http_code}\n' $PROXY_URL/v1/decisions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' -d @gemini.json
{"error":{"message":"litellm.BadRequestError: Invalid Decisions request: 3 validation errors for OpenAIDecisionRequestBody\ninput.str\n  Input should be a valid string [type=string_type, input_value=({'role': 'user', 'conten...harges': [49, 49]}}})},), input_type=tuple]\n    For further information visit https://errors.pydantic.dev/2.13/v/string_type\ninput.json-or-python[json=list[function-after[_developer_and_system_are_text(), OpenAIDecisionInputMessage]],python=chain[is-instance[Sequence],function-wrap[sequence_validator()]]].0.content.str\n  Input should be a valid string [type=string_type, input_value=({'type': 'input_text', '...{'charges': [49, 49]}}}), input_type=tuple]\n    For further information visit https://errors.pydantic.dev/2.13/v/string_type\ninput.json-or-python[json=list[function-after[_developer_and_system_are_text(), OpenAIDecisionInputMessage]],python=chain[is-instance[Sequence],function-wrap[sequence_validator()]]].0.content.`json-or-python[json=list[tagged-union[...,...]],python=chain[is-instance[Sequence],function-wrap[sequence_validator()]]]`.1\n  Input tag 'input_json' found using 'type' does not match any of the expected tags: 'input_text', 'input_image' [type=union_tag_invalid, input_value={'type': 'input_json', 'd... {'charges': [49, 49]}}}, input_type=dict]\n    For further information visit https://errors.pydantic.dev/2.13/v/union_tag_invalid","type":"invalid_request_error","param":null,"code":"400"}}
HTTP 400

After (head e74b5be)

$ curl -s -w '\nHTTP %{http_code}\n' $PROXY_URL/v1/decisions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' -d @gemini.json
{"error":{"message":"litellm.UnsupportedParamsError: gemini does not support parameters: ['input_json'], for model=gemini/gemini-decision-1. To drop these, set `litellm.drop_params=True` or for proxy:\n\n`litellm_settings:\n drop_params: true`\n\n\nLiteLLM: model group 'litellm-qa-decisions-gemini' failed with the error above. No fallback was attempted.","type":"invalid_request_error","param":null,"code":"400"}}
HTTP 400
Gemini deployment with drop_params

Request body gemini-drop.json

{"model":"litellm-qa-decisions-gemini-drop","input":[{"role":"user","content":[{"type":"input_text","text":"Evaluate the ticket using the order evidence."},{"type":"input_json","data":{"ticket":{"body":"Please refund the duplicate charge."},"order":{"charges":[49,49]}}}]}],"questions":[{"type":"predicate","name":"duplicate_charge","instructions":"Does the ticket describe a duplicate charge supported by the order?"}]}

Before (base 436f6d5)

$ curl -s -w '\nHTTP %{http_code}\n' $PROXY_URL/v1/decisions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' -d @gemini-drop.json
{"error":{"message":"litellm.BadRequestError: Invalid Decisions request: 3 validation errors for OpenAIDecisionRequestBody\ninput.str\n  Input should be a valid string [type=string_type, input_value=({'role': 'user', 'conten...harges': [49, 49]}}})},), input_type=tuple]\n    For further information visit https://errors.pydantic.dev/2.13/v/string_type\ninput.json-or-python[json=list[function-after[_developer_and_system_are_text(), OpenAIDecisionInputMessage]],python=chain[is-instance[Sequence],function-wrap[sequence_validator()]]].0.content.str\n  Input should be a valid string [type=string_type, input_value=({'type': 'input_text', '...{'charges': [49, 49]}}}), input_type=tuple]\n    For further information visit https://errors.pydantic.dev/2.13/v/string_type\ninput.json-or-python[json=list[function-after[_developer_and_system_are_text(), OpenAIDecisionInputMessage]],python=chain[is-instance[Sequence],function-wrap[sequence_validator()]]].0.content.`json-or-python[json=list[tagged-union[...,...]],python=chain[is-instance[Sequence],function-wrap[sequence_validator()]]]`.1\n  Input tag 'input_json' found using 'type' does not match any of the expected tags: 'input_text', 'input_image' [type=union_tag_invalid, input_value={'type': 'input_json', 'd... {'charges': [49, 49]}}}, input_type=dict]\n    For further information visit https://errors.pydantic.dev/2.13/v/union_tag_invalid","type":"invalid_request_error","param":null,"code":"400"}}
HTTP 400

After (head e74b5be)

$ curl -s -w '\nHTTP %{http_code}\n' $PROXY_URL/v1/decisions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' -d @gemini-drop.json
{"model":"gemini/gemini-decision-1","answers":[{"type":"predicate","name":"duplicate_charge","probability":0.49215141732705986}],"usage":{"input_tokens":102,"input_tokens_details":{"cached_tokens":0,"cache_write_tokens":0},"output_tokens":0,"output_tokens_details":{"reasoning_tokens":0},"total_tokens":102}}
HTTP 200
prompt_cache_breakpoint on an input_json part

Request body breakpoint.json

{"model": "litellm-qa-decisions", "input": [{"role": "user", "content": [{"type": "input_text", "text": "Evaluate the ticket using the order evidence."}, {"type": "input_json", "data": {"ticket": {"body": "Please refund the duplicate charge."}, "order": {"charges": [49, 49]}}, "prompt_cache_breakpoint": {"mode": "explicit"}}]}], "questions": [{"type": "predicate", "name": "duplicate_charge", "instructions": "Does the ticket describe a duplicate charge supported by the order?"}]}

Before (base 436f6d5)

$ curl -s -w '\nHTTP %{http_code}\n' $PROXY_URL/v1/decisions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' -d @breakpoint.json
{"error":{"message":"litellm.BadRequestError: Invalid Decisions request: 3 validation errors for OpenAIDecisionRequestBody\ninput.str\n  Input should be a valid string [type=string_type, input_value=({'role': 'user', 'conten...harges': [49, 49]}}})},), input_type=tuple]\n    For further information visit https://errors.pydantic.dev/2.13/v/string_type\ninput.json-or-python[json=list[function-after[_developer_and_system_are_text(), OpenAIDecisionInputMessage]],python=chain[is-instance[Sequence],function-wrap[sequence_validator()]]].0.content.str\n  Input should be a valid string [type=string_type, input_value=({'type': 'input_text', '...{'charges': [49, 49]}}}), input_type=tuple]\n    For further information visit https://errors.pydantic.dev/2.13/v/string_type\ninput.json-or-python[json=list[function-after[_developer_and_system_are_text(), OpenAIDecisionInputMessage]],python=chain[is-instance[Sequence],function-wrap[sequence_validator()]]].0.content.`json-or-python[json=list[tagged-union[...,...]],python=chain[is-instance[Sequence],function-wrap[sequence_validator()]]]`.1\n  Input tag 'input_json' found using 'type' does not match any of the expected tags: 'input_text', 'input_image' [type=union_tag_invalid, input_value={'type': 'input_json', 'd... {'charges': [49, 49]}}}, input_type=dict]\n    For further information visit https://errors.pydantic.dev/2.13/v/union_tag_invalid","type":"invalid_request_error","param":null,"code":"400"}}
HTTP 400

After (head e74b5be)

$ curl -s -w '\nHTTP %{http_code}\n' $PROXY_URL/v1/decisions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' -d @breakpoint.json
{"error":{"message":"litellm.BadRequestError: Invalid Decisions request: 3 validation errors for OpenAIDecisionRequestBody\ninput.str\n  Input should be a valid string [type=string_type, input_value=[{'role': 'user', 'conten...{'mode': 'explicit'}}]}], input_type=list]\n    For further information visit https://errors.pydantic.dev/2.13/v/string_type\ninput.json-or-python[json=list[function-after[_developer_and_system_are_text(), OpenAIDecisionInputMessage]],python=chain[is-instance[Sequence],function-wrap[sequence_validator()]]].0.content.str\n  Input should be a valid string [type=string_type, input_value=[{'type': 'input_text', '...: {'mode': 'explicit'}}], input_type=list]\n    For further information visit https://errors.pydantic.dev/2.13/v/string_type\ninput.json-or-python[json=list[function-after[_developer_and_system_are_text(), OpenAIDecisionInputMessage]],python=chain[is-instance[Sequence],function-wrap[sequence_validator()]]].0.content.`json-or-python[json=list[tagged-union[...,...,...]],python=chain[is-instance[Sequence],function-wrap[sequence_validator()]]]`.1.input_json.prompt_cache_breakpoint\n  Extra inputs are not permitted [type=extra_forbidden, input_value={'mode': 'explicit'}, input_type=dict]\n    For further information visit https://errors.pydantic.dev/2.13/v/extra_forbidden\n\nLiteLLM: model group 'litellm-qa-decisions' failed with the error above. No fallback was attempted.","type":"invalid_request_error","param":null,"code":"400"}}
HTTP 400

The same body sent straight to OpenAI, as breakpoint-openai-direct.json with OpenAI's model name, gets OpenAI's own 400

$ curl -s -w '\nHTTP %{http_code}\n' https://api.openai.com/v1/decisions -H "Authorization: Bearer $OPENAI_API_KEY" -H 'Content-Type: application/json' -d @breakpoint-openai-direct.json
{"error":{"message":"Unknown parameter: 'input[0].content[1].prompt_cache_breakpoint'.","type":"invalid_request_error","param":"input[0].content[1].prompt_cache_breakpoint","code":"unknown_parameter"}}
HTTP 400

Round 1 cases, OpenAI SDK and spend logs

Before is the merge base 436f6d5 and After is bea2584, on 2 workers each with Redis

Case Before After
OpenAI SDK client.decisions.create 400 200
Spend log row, latest turn only No row [json omitted]

The rest is in main-round1.md in the gist

Round 4 cases, secret redaction and gif images

Before is the previous tip c4bdb8e and After is fd71cae, on the same rig. The base rejects input_json with a 400

Case Before After
hide-secrets, key in input_json Key reached OpenAI [REDACTED] reached OpenAI
gif and input_json, 8 calls 5 of 8 are 400 8 of 8 are 200
Config, commands and output

The Round 1 config gets these entries. python3 recorder.py 29573 upstream.log runs on the QA box, logs each body it gets, and forwards it to OpenAI. Each leg ran LEG=<leg> PROXY_URL=<leg proxy> zsh cases5.sh > out_<leg>_r4.txt, and the recorder log was copied after each leg

  - model_name: litellm-qa-decisions-gif
    litellm_params:
      model: typesafe/jev-1.14.0
      api_key: os.environ/TYPESAFE_API_KEY
      drop_params: true
      extra_headers: {"typesafe-danger-zone-images": "true"}
  - model_name: litellm-qa-decisions-gif
    litellm_params:
      model: openai/gpt-6-luna
      api_key: os.environ/OPENAI_API_KEY
  - model_name: litellm-qa-decisions-recorded
    litellm_params:
      model: openai/gpt-6-luna
      api_key: os.environ/OPENAI_API_KEY
      api_base: http://127.0.0.1:29573/v1
guardrails:
  - guardrail_name: hide-secrets
    litellm_params:
      guardrail: hide-secrets
      mode: pre_call

secret-json.json

{"model": "litellm-qa-decisions-recorded", "guardrails": ["hide-secrets"], "input": [{"role": "user", "content": [{"type": "input_text", "text": "Review this deploy config."}, {"type": "input_json", "data": {"deploy": {"env": "AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLF"}, "replicas": 2}}]}], "questions": [{"type": "predicate", "name": "key_masked", "instructions": "Is the value of deploy.env exactly the text AWS_ACCESS_KEY_ID=[REDACTED], with no access key id in it?"}]}

gif-json.json

{"model": "litellm-qa-decisions-gif", "input": [{"role": "user", "content": [{"type": "input_image", "image_url": "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"}, {"type": "input_json", "data": {"order": {"charges": [49, 49]}}}]}], "questions": [{"type": "predicate", "name": "duplicate_charge", "instructions": "Does the order show a duplicate charge?"}]}

cases5.sh

#!/bin/zsh
cd ${0:A:h}
run () {
  local case=$1
  print -r -- "#### $case"
  cmd="curl -s -D hdr-$LEG-$case.txt -w '\nHTTP %{http_code}\n' \$PROXY_URL/v1/decisions -H \"Authorization: Bearer \$LITELLM_MASTER_KEY\" -H 'Content-Type: application/json' -d @$case.json"
  printf '$ %s\n' "$cmd"
  eval "$cmd"
  grep -i -E '^x-litellm-(attempted-fallbacks|model-api-base):' hdr-$LEG-$case.txt | tr -d '\r'
}
run secret-json
call_id=$(grep -i '^x-litellm-call-id:' hdr-$LEG-secret-json.txt | tr -d '\r' | awk '{print $2}')
print -r -- "\$ python3 spend_guard.py <x-litellm-call-id of the secret-json call>"
python3 spend_guard.py $call_id
print -r -- "\$ grep -c AKIA upstream-$LEG.log; tail -1 upstream-$LEG.log"
print -r -- "(the recorder log is on the box, read after the run)"
for i in 1 2 3 4 5 6 7 8; do run gif-json; done

spend_guard.py

import json
import os
import sys
import time
import urllib.request

request = urllib.request.Request(
    f"{os.environ['PROXY_URL']}/spend/logs?request_id={sys.argv[1]}",
    headers={"Authorization": f"Bearer {os.environ['LITELLM_MASTER_KEY']}"},
)
for _ in range(30):
    rows = json.load(urllib.request.urlopen(request))
    if rows:
        row = rows[0]
        guard = (row.get("metadata") or {}).get("guardrail_information") or []
        print(json.dumps({
            "status": row.get("status"),
            "guardrails": [{key: entry.get(key) for key in ("guardrail_name", "guardrail_response", "masked_entity_count")} for entry in guard],
            "messages": row.get("messages"),
        }))
        break
    time.sleep(5)
else:
    print("no spend row after 150s")

calls5.py

import re
import sys

text = open(sys.argv[1]).read()
for block in re.split(r"^#### ", text, flags=re.M)[1:]:
    name = block.splitlines()[0]
    status = re.search(r"^HTTP (\d+)", block, re.M)
    model = re.search(r'"model":"([^"]*)"', block)
    error = re.search(r'"message":"([^"]{0,100})', block)
    base = re.search(r"^x-litellm-model-api-base: (\S+)", block, re.M | re.I)
    answer = f"model={model.group(1)}" if model else f"error={error.group(1) if error else '-'}"
    print(name, "HTTP", status.group(1) if status else "-", answer, f"api-base={base.group(1) if base else '-'}")

recorder.py

import http.server
import sys
import urllib.error
import urllib.request

PORT, LOG = int(sys.argv[1]), sys.argv[2]
DROPPED = {"host", "content-length", "accept-encoding", "connection"}


class Recorder(http.server.BaseHTTPRequestHandler):
    def do_POST(self):
        body = self.rfile.read(int(self.headers.get("content-length", 0)))
        with open(LOG, "ab") as sink:
            sink.write(self.path.encode() + b" " + body + b"\n")
        headers = {key: value for key, value in self.headers.items() if key.lower() not in DROPPED}
        request = urllib.request.Request("https://api.openai.com" + self.path, data=body, headers=headers, method="POST")
        try:
            response = urllib.request.urlopen(request, timeout=120)
            status, data, content_type = response.status, response.read(), response.headers.get("content-type")
        except urllib.error.HTTPError as error:
            status, data, content_type = error.code, error.read(), error.headers.get("content-type")
        self.send_response(status)
        self.send_header("content-type", content_type or "application/json")
        self.send_header("content-length", str(len(data)))
        self.end_headers()
        self.wfile.write(data)


http.server.ThreadingHTTPServer(("127.0.0.1", PORT), Recorder).serve_forever()

Base 436f6d5

$ python3 calls5.py out_base_r4.txt | sort | uniq -c
   8 gif-json HTTP 400 error=litellm.BadRequestError: Invalid Decisions request: 3 validation errors for OpenAIDecisionRequestBod api-base=-
   1 secret-json HTTP 400 error=litellm.BadRequestError: Invalid Decisions request: 3 validation errors for OpenAIDecisionRequestBod api-base=-

Before, previous tip c4bdb8e

$ python3 calls5.py out_prev_r4.txt
secret-json HTTP 200 model=gpt-6-luna api-base=http://127.0.0.1:29573/v1
gif-json HTTP 400 error=litellm.BadRequestError: typesafe takes only image/jpeg, image/jpg, image/png images, got image/gif\ api-base=-
gif-json HTTP 200 model=gpt-6-luna api-base=https://api.openai.com
gif-json HTTP 200 model=gpt-6-luna api-base=https://api.openai.com
gif-json HTTP 400 error=litellm.BadRequestError: typesafe takes only image/jpeg, image/jpg, image/png images, got image/gif\ api-base=-
gif-json HTTP 400 error=litellm.BadRequestError: typesafe takes only image/jpeg, image/jpg, image/png images, got image/gif\ api-base=-
gif-json HTTP 200 model=gpt-6-luna api-base=https://api.openai.com
gif-json HTTP 400 error=litellm.BadRequestError: typesafe takes only image/jpeg, image/jpg, image/png images, got image/gif\ api-base=-
gif-json HTTP 400 error=litellm.BadRequestError: typesafe takes only image/jpeg, image/jpg, image/png images, got image/gif\ api-base=-
$ python3 spend_guard.py <x-litellm-call-id of the secret-json call>
{"status": "success", "guardrails": [{"guardrail_name": "hide-secrets", "guardrail_response": "REDACTED_BY_LITELM", "masked_entity_count": {}}], "messages": {}}
$ cat upstream-prev.log
/v1/decisions {"model":"gpt-6-luna","input":[{"role":"user","type":"message","content":[{"type":"input_text","text":"Review this deploy config."},{"type":"input_json","data":{"deploy":{"env":"AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLF"},"replicas":2}}]}],"questions":[{"type":"predicate","name":"key_masked","instructions":"Is the value of deploy.env exactly the text AWS_ACCESS_KEY_ID=[REDACTED], with no access key id in it?"}]}

After, fd71cae

$ python3 calls5.py out_head_r4.txt
secret-json HTTP 200 model=gpt-6-luna api-base=http://127.0.0.1:29573/v1
gif-json HTTP 200 model=gpt-6-luna api-base=https://api.openai.com
gif-json HTTP 200 model=gpt-6-luna api-base=https://api.openai.com
gif-json HTTP 200 model=gpt-6-luna api-base=https://api.openai.com
gif-json HTTP 200 model=gpt-6-luna api-base=https://api.openai.com
gif-json HTTP 200 model=gpt-6-luna api-base=https://api.openai.com
gif-json HTTP 200 model=gpt-6-luna api-base=https://api.openai.com
gif-json HTTP 200 model=gpt-6-luna api-base=https://api.openai.com
gif-json HTTP 200 model=gpt-6-luna api-base=https://api.openai.com
$ python3 spend_guard.py <x-litellm-call-id of the secret-json call>
{"status": "success", "guardrails": [{"guardrail_name": "hide-secrets", "guardrail_response": "REDACTED_BY_LITELM", "masked_entity_count": {"AWS Access Key": 1}}], "messages": {}}
$ cat upstream-head.log
/v1/decisions {"model":"gpt-6-luna","input":[{"role":"user","type":"message","content":[{"type":"input_text","text":"Review this deploy config."},{"type":"input_json","data":{"deploy":{"env":"AWS_ACCESS_KEY_ID=[REDACTED]"},"replicas":2}}]}],"questions":[{"type":"predicate","name":"key_masked","instructions":"Is the value of deploy.env exactly the text AWS_ACCESS_KEY_ID=[REDACTED], with no access key id in it?"}]}

Round 5 cases, colliding secret keys and LLM Shield keys and numbers

Before is the previous tip dd0bfd2 and After is d85536a, on the same rig. The recorder shows what reached OpenAI

Case Before After
Two secret keys, hide-secrets One value lost Both kept
Email as a key, LLM Shield Unmasked Masked
Phone numbers, LLM Shield Unmasked Masked
Config, commands and output

LLM Shield ran on the QA box from the ghcr.io/ninadphalak/llm-shield-proxy image on port 26796, and the Round 4 config gets this guardrail. The rig wrote the shield's key inline, and here it is read from LLM_SHIELD_API_KEY

  - guardrail_name: llm-shield
    litellm_params:
      guardrail: llm_shield_proxy
      mode: ["pre_call", "post_call"]
      api_base: http://127.0.0.1:26796
      api_key: os.environ/LLM_SHIELD_API_KEY

Each leg ran LEG=<leg> RIG=dec-json-main-r1 PROXY_URL=<leg proxy> zsh cases6.sh. It empties the recorder log before each file and then prints the input_json the recorder got. cases6.sh, input_json_seen.py and the full output of every leg are in the gist with a main- prefix

secret-collide.json

{"model": "litellm-qa-decisions-recorded", "guardrails": ["hide-secrets"], "input": [{"role": "user", "content": [{"type": "input_text", "text": "Review this usage report."}, {"type": "input_json", "data": {"usage": {"AKIAIOSFODNN7EXAMPLF": {"calls": 3}, "AKIAIOSFODNN7EXAMPLD": {"calls": 5}}}}]}], "questions": [{"type": "predicate", "name": "both_kept", "instructions": "Does usage hold two entries, one with calls 3 and one with calls 5?"}]}

shield-json.json

{"model": "litellm-qa-decisions-recorded", "guardrails": ["llm-shield"], "input": [{"role": "user", "content": [{"type": "input_text", "text": "Review this customer record."}, {"type": "input_json", "data": {"jane.doe@example.com": {"phone": 4155550100, "visits": 3, "score": 0.5, "vip": true}, "ids": [4155550100, 7], "note": "call jane.doe@example.com"}}]}], "questions": [{"type": "predicate", "name": "has_vip", "instructions": "Is any customer in the record marked vip?"}]}

Before (dd0bfd2)

#### secret-collide
$ curl -s -D hdr-prev-secret-collide.txt -w '\nHTTP %{http_code}\n' $PROXY_URL/v1/decisions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' -d @secret-collide.json
{"model":"gpt-6-luna","answers":[{"type":"predicate","name":"both_kept","probability":0.0}],"usage":{"input_tokens":186,"input_tokens_details":{"cached_tokens":0,"cache_write_tokens":0},"output_tokens":0,"output_tokens_details":{"reasoning_tokens":0},"total_tokens":186}}
HTTP 200
$ python3 input_json_seen.py upstream-secret-collide-prev.log
upstream input_json data: {"usage": {"[REDACTED]": {"calls": 5}}}
#### shield-json
$ curl -s -D hdr-prev-shield-json.txt -w '\nHTTP %{http_code}\n' $PROXY_URL/v1/decisions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' -d @shield-json.json
{"model":"gpt-6-luna","answers":[{"type":"predicate","name":"has_vip","probability":1.0}],"usage":{"input_tokens":211,"input_tokens_details":{"cached_tokens":0,"cache_write_tokens":0},"output_tokens":0,"output_tokens_details":{"reasoning_tokens":0},"total_tokens":211}}
HTTP 200
$ python3 input_json_seen.py upstream-shield-json-prev.log
upstream input_json data: {"jane.doe@example.com": {"phone": 4155550100, "visits": 3, "score": 0.5, "vip": true}, "ids": [4155550100, 7], "note": "call hoffmanshawn@example.com"}

After (d85536a)

#### secret-collide
$ curl -s -D hdr-tip-secret-collide.txt -w '\nHTTP %{http_code}\n' $PROXY_URL/v1/decisions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' -d @secret-collide.json
{"model":"gpt-6-luna","answers":[{"type":"predicate","name":"both_kept","probability":1.0}],"usage":{"input_tokens":200,"input_tokens_details":{"cached_tokens":0,"cache_write_tokens":0},"output_tokens":0,"output_tokens_details":{"reasoning_tokens":0},"total_tokens":200}}
HTTP 200
$ python3 input_json_seen.py upstream-secret-collide-tip.log
upstream input_json data: {"usage": {"[REDACTED]": {"calls": 3}, "[REDACTED] (2)": {"calls": 5}}}
#### shield-json
$ curl -s -D hdr-tip-shield-json.txt -w '\nHTTP %{http_code}\n' $PROXY_URL/v1/decisions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' -d @shield-json.json
{"model":"gpt-6-luna","answers":[{"type":"predicate","name":"has_vip","probability":1.0}],"usage":{"input_tokens":220,"input_tokens_details":{"cached_tokens":0,"cache_write_tokens":0},"output_tokens":0,"output_tokens_details":{"reasoning_tokens":0},"total_tokens":220}}
HTTP 200
$ python3 input_json_seen.py upstream-shield-json-tip.log
upstream input_json data: {"william80@example.com": {"phone": "(882)516-0580x17383", "visits": 3, "score": 0.5, "vip": true}, "ids": ["(882)516-0580x17383", 7], "note": "call william80@example.com"}

The base answers HTTP 400 with Invalid Decisions request to both files, and the recorder gets nothing

Round 6 cases, Cisco AI Defense redact on input_json

Before is the previous tip d85536a, or b9e4e57 for the last row, and After is 264f9f7. A local stub answers for Cisco AI Defense, since there is no Cisco QA account, and OpenAI is real

Case Before After
Monitor mode, sanitized text 200, SSN sent 400
Monitor mode, sanitized messages 200, JSON sent as text 400
Block mode 400 400
Monitor mode, no input_json 200, redacted 200, redacted
Monitor mode, extra empty messages 200, SSN sent 400
Config, commands and output

The Round 5 config gets the two guardrails below. cisco_stub.py in the gist answers POST /api/v1/inspect/chat with "action": "redact" and a sanitized_text, or a sanitized_messages when the inspected text holds MSGS. cases_cisco.sh there sends the four bodies, and main-out_cisco_before.txt and main-out_cisco_after.txt hold the full output

  - guardrail_name: cisco-redact
    litellm_params:
      guardrail: cisco_ai_defense
      mode: pre_call
      api_key: stub-key
      api_base: http://127.0.0.1:26811
      on_flagged_action: monitor
  - guardrail_name: cisco-redact-block
    litellm_params:
      guardrail: cisco_ai_defense
      mode: pre_call
      api_key: stub-key
      api_base: http://127.0.0.1:26811
      on_flagged_action: block

First case's body

{"model": "litellm-qa-decisions-recorded", "guardrails": ["cisco-redact"], "input": [{"role": "user", "content": [{"type": "input_text", "text": "Check customer"}, {"type": "input_json", "data": {"customer": {"ssn": "123-45-6789"}}}]}], "questions": [{"type": "predicate", "name": "has_ssn", "instructions": "Does the evidence include a full social security number?"}]}

Before, at d85536a

$ zsh cases_cisco.sh dec-json-main-r1 28471 before-d85536a675e main
#### cisco-monitor-text (before-d85536a675e)
HTTP 200
/v1/decisions {"model":"gpt-6-luna","input":[{"role":"user","type":"message","content":[{"type":"input_text","text":"Check customer"},{"type":"input_json","data":{"customer":{"ssn":"123-45-6789"}}}]}],"questions":[{"type":"predicate","name":"has_ssn","instructions":"Does the evidence include a full 
#### cisco-monitor-msgs (before-d85536a675e)
HTTP 200
/v1/decisions {"model":"gpt-6-luna","input":[{"role":"user","type":"message","content":[{"type":"input_text","text":"Check customer MSGS [REDACTED]"}]}],"questions":[{"type":"predicate","name":"has_ssn","instructions":"Does the evidence include a full social security number?"}]}
#### cisco-block-text (before-d85536a675e)
{"error":{"message":"Blocked by Cisco AI Defense Guardrail","type":"invalid_request_error","param":null,"code":"400","provider_specific_fields":{"error":"Blocked by Cisco AI Defense Guardrail","message":"Blocked by Cisco AI Defense Guardrail","provider":"cisco_ai_defense","guardrail":"cisco-redact-b
HTTP 400
#### cisco-monitor-no-json (before-d85536a675e)
HTTP 200
/v1/decisions {"model":"gpt-6-luna","input":[{"role":"user","type":"message","content":[{"type":"input_text","text":"Check customer [REDACTED]"}]}],"questions":[{"type":"predicate","name":"has_ssn","instructions":"Does the evidence include a full social security number?"}]}

After, at b9e4e57

$ zsh cases_cisco.sh dec-json-main-r1 28471 after-b9e4e57fa63 main
#### cisco-monitor-text (after-b9e4e57fa63)
{"error":{"message":"Blocked by Cisco AI Defense Guardrail","type":"invalid_request_error","param":null,"code":"400","provider_specific_fields":{"error":"Blocked by Cisco AI Defense Guardrail","message":"Blocked by Cisco AI Defense Guardrail","provider":"cisco_ai_defense","guardrail":"cisco-redact",
HTTP 400
#### cisco-monitor-msgs (after-b9e4e57fa63)
{"error":{"message":"Blocked by Cisco AI Defense Guardrail","type":"invalid_request_error","param":null,"code":"400","provider_specific_fields":{"error":"Blocked by Cisco AI Defense Guardrail","message":"Blocked by Cisco AI Defense Guardrail","provider":"cisco_ai_defense","guardrail":"cisco-redact",
HTTP 400
#### cisco-block-text (after-b9e4e57fa63)
{"error":{"message":"Blocked by Cisco AI Defense Guardrail","type":"invalid_request_error","param":null,"code":"400","provider_specific_fields":{"error":"Blocked by Cisco AI Defense Guardrail","message":"Blocked by Cisco AI Defense Guardrail","provider":"cisco_ai_defense","guardrail":"cisco-redact-b
HTTP 400
#### cisco-monitor-no-json (after-b9e4e57fa63)
HTTP 200
/v1/decisions {"model":"gpt-6-luna","input":[{"role":"user","type":"message","content":[{"type":"input_text","text":"Check customer [REDACTED]"}]}],"questions":[{"type":"predicate","name":"has_ssn","instructions":"Does the evidence include a full social security number?"}]}

/live-pr-risk

Cells at b9e4e57

The head leg ran every earlier cell again at b9e4e57 with Redis, through tip_run.sh and cases7.sh in the gist. cmp_cells.py prints SAME when a cell keeps its status, answer, api-base host and fallback count against the d85536a run. All 29 cells are SAME

$ python3 cmp_cells.py <d85536a675e outputs> <b9e4e57fa63 outputs>
SAME sdk [('-', 'gpt-6-luna', '-', '-')]
SAME text-only [('200', 'gpt-6-luna', 'api.openai.com', '0')]
SAME empty-message-gemini [('200', 'gemini/gemini-decision-1', 'generativelanguage.googleapis.com', '0')]
SAME image-openai [('200', 'gpt-6-luna', 'api.openai.com', '0')]
SAME image-typesafe-drop [('200', 'jev-1.14.0', '-', '0')]
SAME malformed-image-drop [('200', 'gpt-6-luna', 'api.openai.com', '0')]
SAME fallback [('200', 'gpt-6-luna', 'api.openai.com', '1')]
SAME breakpoint-drop [('200', 'gpt-6-luna', 'api.openai.com', '0')]
SAME only-json-drop [('400', 'litellm.BadRequestError: gemini does not', '-', '-')]
SAME customer [('200', 'gpt-6-luna', 'api.openai.com', '0')]
SAME mixed {'200': 8} new hosts {'api.openai.com': 8}
SAME mixed-text-only {'200': 8} new hosts {'generativelanguage.googleapis.com': 4, 'api.openai.com': 4}
SAME mixed-drop {'200': 8} new hosts {'api.openai.com': 4, 'generativelanguage.googleapis.com': 4}
SAME mixed-json-only-drop {'200': 8} new hosts {'api.openai.com': 8}
SAME mixed-dev-json-only-drop {'200': 8} new hosts {'api.openai.com': 8}
SAME array [('200', 'gpt-6-luna', 'api.openai.com', '0')]
SAME gemini [('400', 'litellm.UnsupportedParamsError: gemini d', '-', '-')]
SAME gemini-drop [('200', 'gemini/gemini-decision-1', 'generativelanguage.googleapis.com', '0')]
SAME breakpoint [('400', 'litellm.BadRequestError: Invalid Decisio', '-', '-')]
SAME secret-json [('200', 'gpt-6-luna', '127.0.0.1:29573', '0')]
SAME gif-json [('200', 'gpt-6-luna', 'api.openai.com', '0'), ('200', 'gpt-6-luna', 'api.openai.com', '0'), ('200', 'gpt-6-luna', 'api.openai.com', '0'), ('200', 'gpt-6-luna', 'api.openai.com', '0'), ('200', 'gpt-6-luna', 'api.openai.com', '0'), ('200', 'gpt-6-luna', 'api.openai.com', '0'), ('200', 'gpt-6-luna', 'api.openai.com', '0'), ('200', 'gpt-6-luna', 'api.openai.com', '0')]
SAME secret-in-key [('200', 'gpt-6-luna', '-', '-')]
SAME secret-keyed [('200', 'gpt-6-luna', '-', '-')]
SAME secret-text [('200', 'gpt-6-luna', '-', '-')]
SAME secret-collide [('200', 'gpt-6-luna', '-', '-')]
SAME shield-json [('200', 'gpt-6-luna', '-', '-')]
SAME shield-array-root [('200', 'gpt-6-luna', '-', '-')]
SAME secret-collide-three [('200', 'gpt-6-luna', '-', '-')]
SAME responses-input-json [('400', 'litellm.BadRequestError: OpenAIException', '-', '-')]

The recorder got this data at b9e4e57. Secret keys keep their numbered names. LLM Shield picks new fake values on every call, so only their shape matches the d85536a run, with every email and phone number masked

array    [{"taylorhannah@example.com": "990532360732", "": 5, "score": -0.0, "big": 1e+300, "ids": ["001-814-884-9670x43768", true, null]}, {"n": 7}]
secrets  {"[REDACTED] (2)": "kept", "[REDACTED]": 1, "[REDACTED] (3)": 2, "[REDACTED] (4)": 3}
head     /v1/responses {"contrerasbrian@example.org": "+1-678-719-0650x569"}
base     /v1/responses {"jane.doe@example.com": 4155550100}

The base 436f6d5 rejects the first two with a 400 before any call, and OpenAI answers both sides' /v1/responses call with the same 400, Invalid value: 'input_json'

Carry from b9e4e57 to 264f9f7

264f9f7 changes one condition in the Cisco AI Defense guardrail, so a redact verdict on a request whose input carries input_json is refused even when the request also has a messages field. Only a Cisco redact verdict reaches that line, so the other cells keep the b9e4e57 run. The Cisco cells ran again at 264f9f7, in main-out_cisco9_after.txt in the gist, and the Cisco unit tests pass

Cells at the merge base 436f6d5 and at c4bdb8e

Both legs ran on the rig from Round 1 cases above, with the same config, 2 workers, and their own Postgres and Redis, against real OpenAI, Gemini and TypeSafe. The last column is the provider each call reached, read from x-litellm-model-api-base. The cdbe001 run also logged every upstream request body through a forwarding recorder and found them identical base against head on the cells that answer 200 on both sides

Cell Base Head Provider reached on head
Text only, OpenAI 200 200 OpenAI
Empty message, Gemini, drop_params 200 200 Gemini
Image, OpenAI 200 200 OpenAI
Image, TypeSafe, drop_params 200 200 TypeSafe
Bad image, OpenAI, drop_params 200 200 OpenAI
Gemini group, fallback to OpenAI 400 200 OpenAI after 1 fallback
Breakpoint on JSON, OpenAI, drop_params 400 200 OpenAI
Breakpoint on JSON, OpenAI 400 400 names the breakpoint None
Array data, OpenAI 400 200 OpenAI
JSON, Gemini, fallbacks off 400 400 names input_json None
Text and JSON, Gemini, drop_params 400 200 Gemini
Only a JSON part, Gemini, drop_params 400 400 None
JSON, then spend lookup 400 200 OpenAI, row shows [json omitted]
Mixed OpenAI and Gemini group, 8 JSON calls 8 of 8 are 400 8 of 8 are 200 OpenAI 8 times
Same mixed group, 8 text calls 8 of 8 are 200 8 of 8 are 200 OpenAI 3, Gemini 5
Mixed group, Gemini on drop_params, 8 JSON calls 8 of 8 are 400 8 of 8 are 200 OpenAI 3, Gemini 5
Same drop_params group, 8 JSON-only calls 8 of 8 are 400 8 of 8 are 200 OpenAI 8 times
Same group, developer text, JSON-only user, 8 calls 8 of 8 are 400 8 of 8 are 200 OpenAI 8 times

The last three rows are the drop_params choice in the Decisions block. With text in the user message, Gemini stays a candidate, drops the JSON part, and decides on the text. With only JSON in the user message, Gemini is skipped even next to a developer message, since Gemini drops that message too and would have nothing left to decide on

Raw status, model and api-base of every mixed-group call

cases.sh above also runs mixed-json-only-drop and then mixed-dev-json-only-drop 8 times each at the end. Each leg's output went to out_<leg>_r3.txt, and calls.py prints each mixed call's status, the answering model and x-litellm-model-api-base. Two worker PIDs and REDIS_HOST were checked under each head proxy at c4bdb8e

$ python3 calls.py out_base_r3.txt | sort | uniq -c
   8 mixed HTTP 400 error=litellm.BadRequestError: Invalid Decisions request: 3 validation error api-base=-
   8 mixed-dev-json-only-drop HTTP 400 error=litellm.BadRequestError: Invalid Decisions request: 3 validation error api-base=-
   8 mixed-drop HTTP 400 error=litellm.BadRequestError: Invalid Decisions request: 3 validation error api-base=-
   8 mixed-json-only-drop HTTP 400 error=litellm.BadRequestError: Invalid Decisions request: 3 validation error api-base=-
   4 mixed-text-only HTTP 200 model=gemini/gemini-decision-1 api-base=https://generativelanguage.googleapis.com/v1beta/models/gemini-decision-1:generateContent
   4 mixed-text-only HTTP 200 model=gpt-6-luna api-base=https://api.openai.com

$ python3 calls.py out_head_r3.txt | sort | uniq -c
   8 mixed HTTP 200 model=gpt-6-luna api-base=https://api.openai.com
   8 mixed-dev-json-only-drop HTTP 200 model=gpt-6-luna api-base=https://api.openai.com
   5 mixed-drop HTTP 200 model=gemini/gemini-decision-1 api-base=https://generativelanguage.googleapis.com/v1beta/models/gemini-decision-1:generateContent
   3 mixed-drop HTTP 200 model=gpt-6-luna api-base=https://api.openai.com
   8 mixed-json-only-drop HTTP 200 model=gpt-6-luna api-base=https://api.openai.com
   5 mixed-text-only HTTP 200 model=gemini/gemini-decision-1 api-base=https://generativelanguage.googleapis.com/v1beta/models/gemini-decision-1:generateContent
   3 mixed-text-only HTTP 200 model=gpt-6-luna api-base=https://api.openai.com

calls.py

import re
import sys

text = open(sys.argv[1]).read()
for block in re.split(r"^#### ", text, flags=re.M)[1:]:
    name = block.splitlines()[0]
    if not name.startswith("mixed"):
        continue
    status = re.search(r"^HTTP (\d+)", block, re.M)
    model = re.search(r'"model":"([^"]*)"', block)
    error = re.search(r'"message":"([^"]{0,70})', block)
    base = re.search(r"^x-litellm-model-api-base: (\S+)", block, re.M | re.I)
    answer = f"model={model.group(1)}" if model else f"error={error.group(1) if error else '-'}"
    print(name, "HTTP", status.group(1) if status else "-", answer, f"api-base={base.group(1) if base else '-'}")

mixed.json

{"model": "litellm-qa-decisions-mixed", "input": [{"role": "user", "content": [{"type": "input_text", "text": "Evaluate the ticket using the order evidence."}, {"type": "input_json", "data": {"ticket": {"body": "Please refund the duplicate charge."}, "order": {"charges": [49, 49]}}}]}], "questions": [{"type": "predicate", "name": "duplicate_charge", "instructions": "Does the ticket describe a duplicate charge supported by the order?"}]}

mixed-text-only.json

{"model": "litellm-qa-decisions-mixed", "input": [{"role": "user", "content": [{"type": "input_text", "text": "Evaluate the ticket using the order evidence."}, {"type": "input_text", "text": "Ticket: Please refund the duplicate charge. Order charges: 49, 49."}]}], "questions": [{"type": "predicate", "name": "duplicate_charge", "instructions": "Does the ticket describe a duplicate charge supported by the order?"}]}

mixed-drop.json

{"model": "litellm-qa-decisions-mixed-drop", "input": [{"role": "user", "content": [{"type": "input_text", "text": "Evaluate the ticket using the order evidence."}, {"type": "input_json", "data": {"ticket": {"body": "Please refund the duplicate charge."}, "order": {"charges": [49, 49]}}}]}], "questions": [{"type": "predicate", "name": "duplicate_charge", "instructions": "Does the ticket describe a duplicate charge supported by the order?"}]}

mixed-json-only-drop.json

{"model": "litellm-qa-decisions-mixed-drop", "input": [{"role": "user", "content": [{"type": "input_json", "data": {"ticket": {"body": "Please refund the duplicate charge."}, "order": {"charges": [49, 49]}}}]}], "questions": [{"type": "predicate", "name": "duplicate_charge", "instructions": "Does the ticket describe a duplicate charge supported by the order?"}]}

mixed-dev-json-only-drop.json

{"model": "litellm-qa-decisions-mixed-drop", "input": [{"role": "developer", "content": "Judge the ticket against the order evidence."}, {"role": "user", "content": [{"type": "input_json", "data": {"ticket": {"body": "Please refund the duplicate charge."}, "order": {"charges": [49, 49]}}}]}], "questions": [{"type": "predicate", "name": "duplicate_charge", "instructions": "Does the ticket describe a duplicate charge supported by the order?"}]}
Array, Gemini and breakpoint cells

cases4.sh runs the four cases with the same run as cases.sh, on the same two legs. array.json, gemini-drop.json and breakpoint.json are the bodies under Screenshots / Proof of Fix. gemini.json sends the headline Gemini body to litellm-qa-decisions-gemini-fallback with "disable_fallbacks": true, since that is this config's Gemini group without drop_params

Base 436f6d5

$ python3 calls5.py out_base_r3b.txt
array HTTP 400 error=litellm.BadRequestError: Invalid Decisions request: 3 validation errors for OpenAIDecisionRequestBod api-base=-
gemini HTTP 400 error=litellm.BadRequestError: Invalid Decisions request: 3 validation errors for OpenAIDecisionRequestBod api-base=-
gemini-drop HTTP 400 error=litellm.BadRequestError: Invalid Decisions request: 3 validation errors for OpenAIDecisionRequestBod api-base=-
breakpoint HTTP 400 error=litellm.BadRequestError: Invalid Decisions request: 3 validation errors for OpenAIDecisionRequestBod api-base=-

Head c4bdb8e

$ python3 calls5.py out_head_r3b.txt
array HTTP 200 model=gpt-6-luna api-base=https://api.openai.com
gemini HTTP 400 error=litellm.UnsupportedParamsError: gemini does not support parameters: ['input_json'], for model=gemini api-base=-
gemini-drop HTTP 200 model=gemini/gemini-decision-1 api-base=https://generativelanguage.googleapis.com/v1beta/models/gemini-decision-1:generateContent
breakpoint HTTP 400 error=litellm.BadRequestError: Invalid Decisions request: 3 validation errors for OpenAIDecisionRequestBod api-base=-

gemini.json

{"model": "litellm-qa-decisions-gemini-fallback", "input": [{"role": "user", "content": [{"type": "input_text", "text": "Evaluate the ticket using the order evidence."}, {"type": "input_json", "data": {"ticket": {"body": "Please refund the duplicate charge."}, "order": {"charges": [49, 49]}}}]}], "questions": [{"type": "predicate", "name": "duplicate_charge", "instructions": "Does the ticket describe a duplicate charge supported by the order?"}], "disable_fallbacks": true}

cases4.sh

#!/bin/zsh
cd ${0:A:h}
run () {
  local case=$1
  print -r -- "#### $case"
  cmd="curl -s -D hdr-$LEG-$case.txt -w '\nHTTP %{http_code}\n' \$PROXY_URL/v1/decisions -H \"Authorization: Bearer \$LITELLM_MASTER_KEY\" -H 'Content-Type: application/json' -d @$case.json"
  printf '$ %s\n' "$cmd"
  eval "$cmd"
  grep -i -E '^x-litellm-(attempted-fallbacks|model-api-base):' hdr-$LEG-$case.txt | tr -d '\r'
}
for case in array gemini gemini-drop breakpoint; do run $case; done

Type

🐛 Bug Fix

Caveats (if any)

Medium

  • No live Azure leg, since no Azure Decisions model answers a call yet. A unit test covers it
  • LLM Shield sends a number it masks as a string. Numbers it leaves alone keep their type

Low

  • A text-only request with an extra messages field still skips Cisco's redaction, as before this PR. It is filed as a follow-up
  • An SDK caller with a non-JSON Python object in data gets a raw PydanticSerializationError. The proxy is not affected
  • The router's pre-call token count leaves out input_json data, which matters only for a hand-set small max_input_tokens
  • When every deployment that takes input_json is cooling down, the call gets a 400 from one that refuses it, as audio and video calls do today

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR
Bugbot summary

[!NOTE]
Medium Risk
Touches decisions validation, multi-provider routing, and several guardrails on structured input, but behavior is gated by provider capability flags and covered by broad integration tests.

Overview
Adds OpenAI-style input_json user message parts to /v1/decisions, so structured evidence can be sent as JSON instead of being flattened to text.

OpenAI and Azure forward input_json unchanged; providers without supports_json_input return 400 naming input_json, or strip the part under drop_params (and error if that leaves nothing to decide on). The router treats JSON like audio/video: deployments that refuse JSON are skipped in mixed groups, with drop-params logic that only counts images the deployment actually keeps.

Guardrails and logging now walk input_json payloads: hide-secrets and LLM Shield redact strings, numbers, and keys in place; Cisco AI Defense blocks when it cannot rewrite input_json on a redact verdict; spend logs show [json omitted] for latest-turn storage. OpenAPI and Gemini/TypeSafe transforms ignore or drop JSON parts where unsupported.

Reviewed by Cursor Bugbot for commit 264f9f7. Bugbot is set up for automated code reviews on this repo. Configure here.

User messages on the OpenAI-format /v1/decisions route can now carry
input_json parts whose data is an object or an array of objects. OpenAI
and Azure deployments forward them unchanged. Providers without JSON input
answer 400 naming input_json, or drop the part under drop_params. An
input_json part takes no prompt_cache_breakpoint, matching OpenAI.
@veria-ai

veria-ai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Fixed/addressed: 4 · PR risk: 0/10

Reviews

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@greptile-apps

greptile-apps Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with no new actionable issues found.

Summary

Adds native input_json support to /v1/decisions, including provider checks, routing, redaction, and spend-log omission.

  • Decisions requests can send JSON evidence to providers that support it.
  • Mixed model groups route JSON requests to deployments that can use them.
  • Secret guardrails redact sensitive values and keys inside JSON evidence.
  • Cisco AI Defense refuses to redact JSON it cannot safely rewrite.
  • Latest-turn spend logs mark JSON evidence without storing its contents.

Reviews (9) · Last reviewed commit: "fix(guardrails): refuse Cisco redaction ..." · Reviewed by Greptile

Comment thread litellm/router_rust/steps/precall.py Resolved
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

…co, count only surely kept images

hide_secrets now checks each input_json value with its key in front and rewrites secrets found in keys too. LLM Shield scans the strings in input_json data, and Cisco AI Defense scans the data as JSON text and falls back to on_flagged_action in redact mode, since it cannot write redacted text back into JSON

The drop_params check that skips a deployment the drop would leave with no input now counts an image as kept only when it is well formed and its media type is known to be one the deployment takes
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

…eld mask keys and numbers

hide-secrets now gives a key that redacts to an existing name a numbered
suffix, so two secret keys in one object no longer collapse into one
value. LLM Shield now sends input_json keys and numbers to the shield
too, writes a number back only when the shield changed it, and renames
keys after every value write so no value lands under an old key
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 264f9f7. Configure here.

@mateo-berri mateo-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mateo-berri
mateo-berri merged commit fb00770 into BerriAI:main Nov 20, 2026
53 checks passed
mateo-berri added a commit that referenced this pull request Nov 23, 2026
…rt_51220_lts_1_108_x

Keeps main's DecisionsResponseValidationError beside the line's input_json, safety_identifier and missing-confidence handling, and ports #52805's Gemini hunk so Gemini skips input_json parts the line now has
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.

2 participants