Skip to content

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

Merged
mateo-berri merged 9 commits into
BerriAI:lts/1.108.xfrom
zoveki:litellm_decisions_input_json_lts
Nov 20, 2026
Merged

mateo-berri merged 9 commits into
BerriAI:lts/1.108.xfrom
zoveki:litellm_decisions_input_json_lts

Conversation

@zoveki

@zoveki zoveki commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Handwritten 1-3 sentence description

/v1/decisions on the LTS line 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
  • This is the lts/1.108.x twin of fix(decisions): accept OpenAI input_json content parts on /v1/decisions #52805, adapted to the line's older code

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. 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
  3. 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
  4. 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. Forwarding it unverified is the alternative, and stays open for anyone who can test Vercel
  5. A malformed input_json (string or scalar data) is refused even under drop_params, the same as on main (fix(decisions): accept OpenAI input_json content parts on /v1/decisions #52805). drop_params drops a part a provider does not support, and no provider takes malformed data, since OpenAI's reference requires an object or an array of objects. Dropping it, as this line does for a malformed image part, is the alternative
  6. 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. 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, 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 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 input is only input_json parts, or those parts and images, goes only to the deployments that take JSON
  7. 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)
  8. 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
  9. 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
  10. 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
How this differs from the main PR

The main change does not cherry-pick onto lts/1.108.x, so this is a port of the same behavior to the line's older decisions code. Content parts on this line have no prompt_cache_breakpoint, so there is no breakpoint handling or test. Messages here are user-only, so there is no developer-message test. The line has no Gemini decisions provider, so TypeSafe is the provider whose text building skips JSON parts, and the drop_params test covers both Perplexity and TypeSafe. The line has no _supported_messages, so dropping images and dropping input_json both happen in _without_unsupported_params. The tests use this line's openai_default_base fixture. Main skips deployments that would refuse input_json in a mixed model group by extending its Decisions audio and video filter. This line has no such filter, so the port adds one to the router's healthy-deployment step, next to the check that a deployment can serve the route. Main's [json omitted] placeholder for spend logs is not ported, since this line has no latest-turn prompt storage, and the pair block records it as main-only. Main redacts data with its existing walk over tool-call JSON. This line has no such walk, so the port adds one that loops instead of recursing, so deep data cannot hit Python's recursion limit

main commit LTS commits
e74b5be831227e7ff30b67cb42297670f8cd7de8 792715531287cdc8664ebf6aad09a82e2dfc445a 886057a552f811656527cd8c68e51a7bc8d9937d
cdbe001e9c8f9e55e5db3cc669d90e3a0be4a7a3 971a4e3bceec6f2337003a3c9feb67d2ea1f7ef2
d43574dc1f9 971a4e3bceec6f2337003a3c9feb67d2ea1f7ef2
bea258420fa2b1116d89c859166e8db064ffef50 971a4e3bceec6f2337003a3c9feb67d2ea1f7ef2, spend-log part main-only
1d446a7f0bd84f25b70ef923a0b6da67daaf2cc6 34f617c5219d8d72fad50c738c3faa6daf9a0153
c4bdb8e34b260d8a85d099668f611156229bb10e 34f617c5219d8d72fad50c738c3faa6daf9a0153
fd71cae85149877b02040f30c0d7cf663b227d07 f2fa8904ed254ca9f097aaafda2d0043e8cbdd21
dd0bfd2236a99645180b8b63a7b9cacf17becbe8 ecd11a162073557fed079849d82722a82e035913
d85536a675e25f6de30b06cf7e2bef8b0e77c896 3e5f3d895d61a5d8e96bbf23aaf70fd80443595c
b9e4e57fa633912a31af16d5ffab0987ce0059be caa9ae203f7e08e2d7e65dbb96a643bcdca86b81
264f9f703aa 2c031e1d859

Screenshots / Proof of Fix

Before is the LTS merge base f76134d and After is 7927155, 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 TypeSafe (jev-1.14.0). The OpenAI SDK run is under Round 1

Last updated: 2c031e1, 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
TypeSafe, no drop_params 400 400 names input_json
TypeSafe, drop_params 400 200

Headline case, object data sent to OpenAI

  1. Boot the proxy with the config below, LITELLM_MASTER_KEY, OPENAI_API_KEY and TYPESAFE_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
Request body and output at the base, at 7927155 and at f2fa890

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 f76134d)

$ 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...charges': [49, 49]}}}]}], input_type=list]\n    For further information visit https://errors.pydantic.dev/2.13/v/string_type\ninput.json-or-python[json=list[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=list]\n    For further information visit https://errors.pydantic.dev/2.13/v/string_type\ninput.json-or-python[json=list[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 (QA tip 7927155)

$ 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

At f2fa890

$ 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-typesafe
    litellm_params:
      model: typesafe/jev-1.14.0
      api_key: os.environ/TYPESAFE_API_KEY
  - model_name: litellm-qa-decisions-typesafe-drop
    litellm_params:
      model: typesafe/jev-1.14.0
      api_key: os.environ/TYPESAFE_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 typesafe typesafe-drop; 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 f76134d)

$ 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...charges': [49, 49]}]}]}], input_type=list]\n    For further information visit https://errors.pydantic.dev/2.13/v/string_type\ninput.json-or-python[json=list[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=list]\n    For further information visit https://errors.pydantic.dev/2.13/v/string_type\ninput.json-or-python[json=list[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 (QA tip 7927155)

$ 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
TypeSafe deployment without drop_params

Request body typesafe.json

{"model": "litellm-qa-decisions-typesafe", "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 f76134d)

$ curl -s -w '\nHTTP %{http_code}\n' $PROXY_URL/v1/decisions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' -d @typesafe.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...charges': [49, 49]}}}]}], input_type=list]\n    For further information visit https://errors.pydantic.dev/2.13/v/string_type\ninput.json-or-python[json=list[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=list]\n    For further information visit https://errors.pydantic.dev/2.13/v/string_type\ninput.json-or-python[json=list[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 (QA tip 7927155)

$ curl -s -w '\nHTTP %{http_code}\n' $PROXY_URL/v1/decisions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' -d @typesafe.json
{"error":{"message":"litellm.UnsupportedParamsError: typesafe does not support parameters: ['input_json'], for model=typesafe/jev-1.14.0. 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-typesafe' failed with the error above. No fallback was attempted.","type":"invalid_request_error","param":null,"code":"400"}}
HTTP 400
TypeSafe deployment with drop_params

Request body typesafe-drop.json

{"model": "litellm-qa-decisions-typesafe-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 f76134d)

$ curl -s -w '\nHTTP %{http_code}\n' $PROXY_URL/v1/decisions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' -d @typesafe-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...charges': [49, 49]}}}]}], input_type=list]\n    For further information visit https://errors.pydantic.dev/2.13/v/string_type\ninput.json-or-python[json=list[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=list]\n    For further information visit https://errors.pydantic.dev/2.13/v/string_type\ninput.json-or-python[json=list[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 (QA tip 7927155)

$ curl -s -w '\nHTTP %{http_code}\n' $PROXY_URL/v1/decisions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' -d @typesafe-drop.json
{"model":"jev-1.14.0","answers":[{"type":"predicate","name":"duplicate_charge","probability":0.23}],"usage":{"input_tokens":286,"input_tokens_details":{"cached_tokens":0,"cache_write_tokens":0},"output_tokens":21,"output_tokens_details":{"reasoning_tokens":0},"total_tokens":307}}
HTTP 200

Round 1 cases, OpenAI SDK and mixed groups

Before is the line's base f76134d and After is 971a4e3, on 2 workers each with Redis

Case Before After
OpenAI SDK, OpenAI group 400 200
OpenAI SDK, mixed group 400 200
Mixed group, 8 JSON calls 8 of 8 are 400 8 of 8 are 200
Mixed group on drop_params, 8 JSON calls 8 of 8 are 400 8 of 8 are 200

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

Round 4 cases, secret redaction and gif images

Before is the previous tip 34f617c and After is f2fa890, on the same rig

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

The Round 1 config gets these entries. python3 recorder.py 29574 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:29574/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 f76134d

$ 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 34f617c

$ python3 calls5.py out_prev_r4.txt
secret-json HTTP 200 model=gpt-6-luna api-base=http://127.0.0.1:29574/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 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 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
$ 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, f2fa890

$ python3 calls5.py out_head_r4.txt
secret-json HTTP 200 model=gpt-6-luna api-base=http://127.0.0.1:29574/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 ecd11a1 and After is 3e5f3d8, 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-lts-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 lts- 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 (ecd11a1)

#### 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":209,"input_tokens_details":{"cached_tokens":0,"cache_write_tokens":0},"output_tokens":0,"output_tokens_details":{"reasoning_tokens":0},"total_tokens":209}}
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 umay@example.net"}

After (3e5f3d8)

#### 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":218,"input_tokens_details":{"cached_tokens":0,"cache_write_tokens":0},"output_tokens":0,"output_tokens_details":{"reasoning_tokens":0},"total_tokens":218}}
HTTP 200
$ python3 input_json_seen.py upstream-shield-json-tip.log
upstream input_json data: {"michael88@example.net": {"phone": "216-687-7939x36962", "visits": 3, "score": 0.5, "vip": true}, "ids": ["216-687-7939x36962", 7], "note": "call michael88@example.net"}

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 3e5f3d8, or caa9ae2 for the last row, and After is 2c031e1. 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 lts-out_cisco_before.txt and lts-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 3e5f3d8

$ zsh cases_cisco.sh dec-json-lts-r1 27652 before-3e5f3d895d6 lts
#### cisco-monitor-text (before-3e5f3d895d6)
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-3e5f3d895d6)
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-3e5f3d895d6)
{"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-3e5f3d895d6)
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 caa9ae2

$ zsh cases_cisco.sh dec-json-lts-r1 27652 after-caa9ae203f7 lts
#### cisco-monitor-text (after-caa9ae203f7)
{"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-caa9ae203f7)
{"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-caa9ae203f7)
{"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-caa9ae203f7)
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 caa9ae2

The head leg ran every earlier cell again at caa9ae2 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 3e5f3d8 run. All 26 cells are SAME

$ python3 cmp_cells.py <3e5f3d895d6 outputs> <caa9ae203f7 outputs>
SAME sdk [('-', 'gpt-6-luna', '-', '-')]
SAME text-only [('200', 'gpt-6-luna', 'api.openai.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 spend [('200', 'gpt-6-luna', 'api.openai.com', '0')]
SAME fallback [('200', 'gpt-6-luna', 'api.openai.com', '1')]
SAME only-json-drop [('400', 'litellm.BadRequestError: typesafe does n', '-', '-')]
SAME mixed {'200': 8} new hosts {'api.openai.com': 8}
SAME mixed-text-only {'200': 8} new hosts {'-': 6, 'api.openai.com': 2}
SAME mixed-drop {'200': 8} new hosts {'-': 6, 'api.openai.com': 2}
SAME mixed-json-only-drop {'200': 8} new hosts {'api.openai.com': 8}
SAME mixed-image-json-only-drop {'200': 8} new hosts {'api.openai.com': 8}
SAME array [('200', 'gpt-6-luna', 'api.openai.com', '0')]
SAME typesafe [('400', 'litellm.UnsupportedParamsError: typesafe', '-', '-')]
SAME typesafe-drop [('200', 'jev-1.14.0', '-', '0')]
SAME secret-json [('200', 'gpt-6-luna', '127.0.0.1:29574', '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 caa9ae2. Secret keys keep their numbered names. LLM Shield picks new fake values on every call, so only their shape matches the 3e5f3d8 run, with every email and phone number masked

array    [{"stephen98@example.com": "981495088157", "": 5, "score": -0.0, "big": 1e+300, "ids": ["(391)321-8320x7491", true, null]}, {"n": 7}]
secrets  {"[REDACTED] (2)": "kept", "[REDACTED]": 1, "[REDACTED] (3)": 2, "[REDACTED] (4)": 3}
head     /v1/responses {"becky77@example.org": "310.671.1503"}
base     /v1/responses {"jane.doe@example.com": 4155550100}

The base f76134d 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 caa9ae2 to 2c031e1

2c031e1 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 caa9ae2 run. The Cisco cells ran again at 2c031e1, in lts-out_cisco9_after.txt in the gist, and the Cisco unit tests pass

Cells at base f76134d and at 34f617c

Both legs ran on the rig from Round 1 cases above. The last column is the provider each call reached, read from x-litellm-model-api-base. TypeSafe answers carry no such header, so in a mixed group a call without it is a TypeSafe call. The 886057a run also logged every upstream request through a forwarding recorder and found the bodies identical base against head on the cells that answered 200 on both

Cell Base Head Provider reached on head
Text only, OpenAI 200 200 OpenAI
Image, OpenAI 200 200 OpenAI
Image, TypeSafe, drop_params 200 200 TypeSafe
Bad image, OpenAI, drop_params 200 200 OpenAI
JSON, then spend lookup 400 200 OpenAI, one success row
TypeSafe group, fallback to OpenAI 400 200 OpenAI after 1 fallback
Only a JSON part, TypeSafe, drop_params 400 400 None
Array data, OpenAI 400 200 OpenAI
JSON, TypeSafe, fallbacks off 400 400 names input_json None
Text and JSON, TypeSafe, drop_params 400 200 TypeSafe
Mixed OpenAI and TypeSafe 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 5, TypeSafe 3
Mixed group, TypeSafe on drop_params, 8 JSON calls 8 of 8 are 400 8 of 8 are 200 OpenAI 3, TypeSafe 5
Same drop_params group, 8 JSON-only calls 8 of 8 are 400 8 of 8 are 200 OpenAI 8 times
Same group, image and JSON only, 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 request, TypeSafe stays a candidate, drops the JSON part, and decides on the text. With only JSON, or JSON and an image, TypeSafe is skipped, since it drops both and would have nothing left to decide on

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

This block moved to lts-raw-mixed-group-calls-34f617c5219.md in the gist to keep the body under GitHub's size limit. It holds the calls.py output for every mixed-group call at the base and at 34f617c, the two worker PID and REDIS_HOST checks, and the request bodies

Array and TypeSafe cells

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

Base f76134d

#### array
$ curl -s -D hdr-base-array.txt -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...charges': [49, 49]}]}]}], input_type=list]\n    For further information visit https://errors.pydantic.dev/2.13/v/string_type\ninput.json-or-python[json=list[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=list]\n    For further information visit https://errors.pydantic.dev/2.13/v/string_type\ninput.json-or-python[json=list[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
#### typesafe
$ curl -s -D hdr-base-typesafe.txt -w '\nHTTP %{http_code}\n' $PROXY_URL/v1/decisions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' -d @typesafe.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...charges': [49, 49]}}}]}], input_type=list]\n    For further information visit https://errors.pydantic.dev/2.13/v/string_type\ninput.json-or-python[json=list[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=list]\n    For further information visit https://errors.pydantic.dev/2.13/v/string_type\ninput.json-or-python[json=list[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
#### typesafe-drop
$ curl -s -D hdr-base-typesafe-drop.txt -w '\nHTTP %{http_code}\n' $PROXY_URL/v1/decisions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' -d @typesafe-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...charges': [49, 49]}}}]}], input_type=list]\n    For further information visit https://errors.pydantic.dev/2.13/v/string_type\ninput.json-or-python[json=list[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=list]\n    For further information visit https://errors.pydantic.dev/2.13/v/string_type\ninput.json-or-python[json=list[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

Head 34f617c

#### array
$ curl -s -D hdr-head-array.txt -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
x-litellm-model-api-base: https://api.openai.com
x-litellm-attempted-fallbacks: 0
#### typesafe
$ curl -s -D hdr-head-typesafe.txt -w '\nHTTP %{http_code}\n' $PROXY_URL/v1/decisions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' -d @typesafe.json
{"error":{"message":"litellm.UnsupportedParamsError: typesafe does not support parameters: ['input_json'], for model=typesafe/jev-1.14.0. To drop these, set `litellm.drop_params=True` or for proxy:\n\n`litellm_settings:\n drop_params: true`\n","type":"invalid_request_error","param":null,"code":"400"}}
HTTP 400
#### typesafe-drop
$ curl -s -D hdr-head-typesafe-drop.txt -w '\nHTTP %{http_code}\n' $PROXY_URL/v1/decisions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' -d @typesafe-drop.json
{"model":"jev-1.14.0","answers":[{"type":"predicate","name":"duplicate_charge","probability":0.23}],"usage":{"input_tokens":286,"input_tokens_details":{"cached_tokens":0,"cache_write_tokens":0},"output_tokens":21,"output_tokens_details":{"reasoning_tokens":0},"total_tokens":307}}
HTTP 200
x-litellm-attempted-fallbacks: 0

typesafe.json

{"model": "litellm-qa-decisions-typesafe-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 typesafe typesafe-drop; 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
  • osv-scan is red on lts/1.108.x itself too. This PR changes no dependencies

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 request validation, provider routing, and multiple pre-call guardrails on structured JSON payloads; mis-routing or incomplete redaction could affect which deployment serves a call or what reaches upstream.

Overview
Adds OpenAI input_json content parts to /v1/decisions, so structured evidence can ride alongside input_text / input_image instead of failing validation.

Decisions pipeline: New OpenAIDecisionInputJSON type and OpenAPI schema; OpenAI/Azure forward the part unchanged. Providers without JSON input get a clear input_json refusal or drop it under drop_params (with “no input left” checks). The router skips deployments that would refuse or fully drop JSON-only requests in mixed model groups.

Guardrails: Shared walk_user_text / _content_utils now traverse and rewrite nested JSON in input_json data (including keys). hide_secrets redacts secrets in place; LLM Shield scans strings, numbers, and keys; Cisco AI Defense scans serialized JSON but blocks redact verdicts when input_json cannot be rewritten in place (even in monitor mode).

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

@zoveki
zoveki requested a review from a team November 19, 2026 07:41
@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

@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

@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 latest change appears safe to merge and closes the Cisco combined-field bypass

Summary

/v1/decisions accepts input_json, forwards it to supported providers, and rejects or drops it elsewhere. Guardrails inspect the structured data without turning it into text sent to the model

The latest change closes Cisco's combined-field bypass. An extra messages field can no longer make a redaction request leave input_json unchanged and continue upstream. Tests cover both blocking and monitor modes

The earlier unnumbered live-QA thread was manually resolved without an explanatory reply

  • Decision requests can carry structured JSON evidence in their messages.
  • Mixed model groups route JSON requests to deployments that can use them.
  • Guardrails can inspect and redact text inside JSON evidence.
  • LLM Shield can mask values, keys, and numbers inside JSON evidence.
  • Cisco AI Defense blocks JSON input when it cannot apply a requested redaction.

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

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

@surlymochan surlymochan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Read through the full diff. The routing itself looks sound: OpenAIDecisionsConfig.supports_json_input = True while the Vercel gateway explicitly opts out (False), and unsupported providers get the input_json parts stripped via without_json_input instead of failing the call; has_json_input/without_json_input correctly no-op on DecisionsIRState, which cannot carry message parts. I also checked request_carries_json_input against the helpers in mid_conversation_system.py — parts_of returns () for a plain-string input and message_field returns None for non-mapping messages, so a string input cannot crash that path.

One thing worth clearing up before review: this overlaps heavily with your own #52805 (same title, same author, branch litellm_decisions_input_json, also OPEN). #52805 is broader — it also touches litellm/llms/gemini/decisions/transformation.py, spend-tracking utils, and router_rust — while this PR (..._lts) is narrower. Which one is canonical? Two open PRs with the same title will split review and risk conflicting merges; if #52805 is superseded, closing it (or noting so here) would help maintainers pick the right one.

Non-blocking otherwise — the input_json handling and test coverage in tests/unit/decisions/test_main.py + the OpenAI-format wire test look thorough.

@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 2c031e1. 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 21bf566 into BerriAI:lts/1.108.x Nov 20, 2026
62 of 63 checks passed
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.

3 participants