Skip to content

fix(logging): stop dumping the request body at every layer under --detailed_debug - #48973

Merged
ryan-crabbe-berri merged 3 commits into
mainfrom
litellm_quiet_detailed_debug_request_dumps
Oct 29, 2026
Merged

ryan-crabbe-berri merged 3 commits into
mainfrom
litellm_quiet_detailed_debug_request_dumps

Conversation

@ryan-crabbe-berri

@ryan-crabbe-berri ryan-crabbe-berri commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

With --detailed_debug on, the proxy printed the full request body again at almost every step it passed through, so one Codex "hi" (a 34KB system prompt plus tools) wrote about 500KB of log. Now the body shows up where it enters the proxy and where it leaves for the provider, and a handful of lines that fire on every request with nothing to say are gone. Errors, warnings and info logs are untouched

Details

TLDR

  • Debug logs printed your whole prompt about nine times per request
  • Now it prints once as received and once as sent upstream
  • Lines that only said "nothing to do here" on every request are gone
  • One Codex-style request drops from about 540KB of log to about 115KB
  • Secret redaction is unchanged and keys stay hidden in what still prints

User Flow

Before: a developer debugging Codex through the proxy gets a wall of repeated prompt text for one "hi"

  1. They start the proxy with --detailed_debug and point Codex at it
  2. Codex sends POST http://localhost:4000/v1/responses with its long system prompt, tools and "hi"
  3. The proxy writes about 100 lines and 540KB of log for that one request
  4. The same 31KB system prompt appears 9 times, the tool list 12 times, plus 12 lines saying no callbacks were disabled

After: the same request gives a log where the prompt shows up once as received and once as sent

  1. They start the proxy with --detailed_debug and point Codex at it
  2. Codex sends the same POST http://localhost:4000/v1/responses
  3. The proxy writes about 80 lines and 115KB of log for that request
  4. The prompt and tools appear in "Request received by LiteLLM" and in "POST Request Sent from LiteLLM", plus the one reply line that echoes them

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

Screenshots / Proof of Fix

Setup, shared by both runs. The proxy runs on port 4172 with no database and --detailed_debug, logs go to a file. Two deployments, one native OpenAI Responses model and one that goes through the Responses to chat completions bridge (a translated path like the one Codex hits when its model has no native Responses API)

# config.yaml
model_list:
  - model_name: gpt-6.1-sol
    litellm_params:
      model: openai/gpt-6.1-sol
      api_key: os.environ/OPENAI_API_KEY
  - model_name: gpt-6.1-sol-bridge
    litellm_params:
      model: custom_openai/gpt-6.1-terra
      api_base: https://api.openai.com/v1
      api_key: os.environ/OPENAI_API_KEY
general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY
python litellm/proxy/proxy_cli.py --config config.yaml --port 4172 --detailed_debug > proxy.log 2>&1 &

The payloads mimic Codex. Each has a 31,239 character system prompt (150 numbered rules, each starting "Rule N: You are a coding agent...") and the user turn "hi". The two /v1/responses payloads and the chat one also carry 4 tools (shell, apply_patch, view_image, update_plan), and the bridge ones set reasoning effort to none since that model rejects tools otherwise. Each request is sent once to warm up, then once more for the measurement. measure slices out only the bytes the proxy logged for that one request

measure() {  # $1 = route, $2 = payload file
  start=$(wc -c < proxy.log)
  curl -s localhost:4172$1 -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "x-api-key: $LITELLM_MASTER_KEY" \
    -H 'anthropic-version: 2023-06-01' -H 'Content-Type: application/json' -d @$2 > resp.json
  sleep 3; tail -c +$((start + 1)) proxy.log > one_request.log
}

Before (49ccce7)

/v1/responses through the chat completions bridge (Codex path)

  1. measure /v1/responses req_bridge.json && jq -r '.output[] | select(.type=="message") | .content[0].text' resp.json prints Hi! How can I help?
  2. wc -lc < one_request.log prints 102 544313
  3. grep -c "Rule 0" one_request.log prints 9, the prompt is in "Request received by LiteLLM", "receiving data", "[PROXY] returned data from litellm_pre_call_utils", "Inside ageneric_api_call_with_fallbacks() ... kwargs", the green litellm.aresponses(...) and litellm.acompletion(...) echoes, "Params passed to completion()", the outgoing curl, and the reply echo
  4. grep -c callback_controls one_request.log prints 12, two "is this callback disabled" lines per callback with no disable header sent
  5. grep -c "Run a shell command in the workspace" one_request.log prints 12, the tool list repeats on top of the prompt copies

/v1/responses native OpenAI

  1. measure /v1/responses req_native.json returns Hi! What can I help you build or fix?
  2. wc -lc < one_request.log prints 252 493029
  3. grep -c "Rule 0" one_request.log prints 9
  4. grep -c "Error decoding response_id" one_request.log prints 1, logged for a normal OpenAI response id

/v1/chat/completions

  1. measure /v1/chat/completions req_chat.json returns Hi! How can I help?
  2. wc -lc < one_request.log prints 93 356843
  3. grep -c "Rule 0" one_request.log prints 6
  4. grep -c potential_model_names one_request.log prints 3
  5. grep -c "Run a shell command in the workspace" one_request.log prints 9

/v1/messages

  1. measure /v1/messages req_msgs.json (model gpt-6.1-sol, no tools) returns Hi! What can I help you with?
  2. wc -lc < one_request.log prints 180 496929
  3. grep -c "Rule 0" one_request.log prints 9

After (6756dcb)

/v1/responses through the chat completions bridge (Codex path)

  1. measure /v1/responses req_bridge.json && jq -r '.output[] | select(.type=="message") | .content[0].text' resp.json prints Hi! How can I help?
  2. wc -lc < one_request.log prints 79 115572
  3. grep -c "Rule 0" one_request.log prints 3, the prompt is only in "Request received by LiteLLM", the outgoing curl, and the reply echo
  4. grep -c callback_controls one_request.log prints 0
  5. grep -c "Run a shell command in the workspace" one_request.log prints 3, the same three places as the prompt
  6. Excerpt of one_request.log (lines cut at 140 chars). The SDK call echo now shows sizes instead of the prompt, and the outgoing curl still masks the key
18:35:02 - LiteLLM Proxy:DEBUG: common_request_processing.py:2840 - Request received by LiteLLM:
{"model": "gpt-6.1-sol-bridge", "instructions": "Rule 0: You are a coding agent running in a terminal. Keep edits minimal, explain changes b
18:35:02 - LiteLLM Router:DEBUG: router.py:6327 - Inside ageneric_api_call_with_fallbacks() - model: gpt-6.1-sol-bridge
18:35:02 - LiteLLM:DEBUG: utils.py:579 - Request to litellm:
18:35:02 - LiteLLM:DEBUG: utils.py:579 - litellm.aresponses(REDACTED', api_base='https://api.openai.com/v1', allow_client_keepalive_override
          ... instructions=<str len=31239> ... tools=<list len=4> ... proxy_server_request=<dict len=7> ... metadata=<dict len=66> ...
18:35:02 - LiteLLM:DEBUG: utils.py:579 - Request to litellm:
18:35:02 - LiteLLM:DEBUG: utils.py:579 - litellm.acompletion(extra_body=None, timeout=600.0, allowed_openai_params=['reasoning_effort'], RED
          ... messages=<list len=2> ...
LiteLLM: Non-Default params passed to completion() {'stream': False, 'tools': <list len=4>, 'max_retries': 0, 'reasoning_effort': 'none'}
18:35:02 - LiteLLM:DEBUG: utils.py:579 - Final returned optional params: {'stream': False, 'tools': <list len=4>, 'max_retries': 0}
POST Request Sent from LiteLLM:
curl -X POST \
https://api.openai.com/v1/ \
-H 'Authorization: Be****gA' \
-d '{'model': 'gpt-6.1-terra', 'messages': [{'role': 'system', 'content': 'Rule 0: You are a coding agent running in a terminal. Keep edits 
  1. The OpenAI key and the master key appear 0 times in the full before and after logs (grep -cF "$OPENAI_API_KEY" proxy.log prints 0, same for the first 12 characters of the key)

/v1/responses native OpenAI

  1. measure /v1/responses req_native.json returns Hi! What can I help you with?
  2. wc -lc < one_request.log prints 233 148963
  3. grep -c "Rule 0" one_request.log prints 4, received, sent, and the two reply lines (OpenAI echoes the instructions back in its reply)
  4. grep -c "Error decoding response_id" one_request.log prints 0

/v1/chat/completions

  1. measure /v1/chat/completions req_chat.json returns Hi! How can I help?
  2. wc -lc < one_request.log prints 71 79582
  3. grep -c "Rule 0" one_request.log prints 2
  4. grep -c potential_model_names one_request.log prints 0
  5. grep -c "Run a shell command in the workspace" one_request.log prints 2

/v1/messages

  1. measure /v1/messages req_msgs.json returns Hi! What can I help you with?
  2. wc -lc < one_request.log prints 161 107141
  3. grep -c "Rule 0" one_request.log prints 3, received, sent, and the reply echo

Type

🐛 Bug Fix

Caveats (if any)

Medium

  • The body still prints twice, as received and as sent upstream
    • The received copy is the documented MAX_PAYLOAD_SIZE_FOR_DEBUG_LOG line, so it stays
    • Setting MAX_PAYLOAD_SIZE_FOR_DEBUG_LOG=0 shrinks it to a size and keys summary

Low

  • The green "Request to litellm" line and the two param mapping lines now show values over 500 characters as a size
    • Short values like model, api_base, temperature and small headers still print in full
  • Responses API replies are still logged twice, raw and after routing, a possible follow-up
  • With no database, two per-request lines remain ("user fetch swallowed" and "Prisma client not found")
    • Both report a check that really was skipped, so they were left alone
  • The red osv-scan check is a known false positive on main

Note

Low Risk
Changes are limited to debug logging and response-id decode error handling; request handling, auth, and credential redaction paths are not altered for normal operation.

Overview
Under --detailed_debug, this PR cuts repeated full request-body and kwargs dumps so large prompts/tools are not logged at every proxy, router, and completion hop.

Removed or narrowed debug noise includes proxy receiving data / pre-call full data logs (including one that ran before credential overrides), logging of optional_params, per-request vector-store “nothing to do” lines, router “Inside …” lines that printed entire kwargs, search API fallback logs, and enterprise callback “checking disabled” lines when no disable header is set. Completion debug drops the extra “params passed” line and only logs potential_model_names when a model lookup actually fails.

Where debug still shows payloads, _debug_arg_repr / _debug_params_repr in utils.py replace values longer than 500 characters with <type len=N> summaries in the green litellm.*(...) echo and non-default/optional param lines; credential redaction behavior is unchanged.

decode_responses_api_response_id now treats ValueError like other decode failures (fallback id, no spurious “Error decoding response_id” for normal OpenAI ids).

Tests assert callback-disable checks stay silent without a disable header and that a sentinel prompt appears only twice in debug logs (received + upstream send) for chat and responses routes.

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

…tailed_debug

The proxy dumped the full request body at every layer it passed through
(proxy entry, pre-call, router, SDK call echo, param mapping, logging
object), so one Codex "hi" wrote over 500KB of debug log. Keep the inbound
request line and the outgoing provider request, summarize large values in
the SDK call echo, and stop per-request lines that report nothing
(callback disable checks with no disable header, cost map name probes,
response id decode misses, vector store path misses).
@codspeed

codspeed Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 37 untouched benchmarks


Comparing litellm_quiet_detailed_debug_request_dumps (6756dcb) with main (3b9a593)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (57c1df8) during the generation of this report, so 3b9a593 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.14286% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
litellm/utils.py 94.11% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

@greptileai review

@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge

Summary

This PR cuts repeated request-body debug logs and summarizes large arguments while keeping the received and outgoing request logs

  • Detailed logs show long request bodies at fewer points.
  • Callback checks stay quiet when a request disables nothing.
  • Vector-store and model lookup logs focus on useful events.
  • Undecodable Responses IDs keep their original value without an error log.

Reviews (3) · Last reviewed commit: "perf(logging): build the param mapping d..." · Reviewed by Greptile

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

Comment thread tests/unit/proxy/test_proxy_server.py Resolved
Non-Default params and Final returned optional params still printed full
tool definitions, so a Codex-style request repeated them twice more. Use
the same size summary as the SDK call echo and cover tools in the test.
@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

@greptileai re review

@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

Comment thread litellm/utils.py Resolved

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

@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

@greptileai re review

@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

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 6756dcb. Configure here.

@ryan-crabbe-berri
ryan-crabbe-berri enabled auto-merge (squash) October 29, 2026 01:45

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

@ryan-crabbe-berri
ryan-crabbe-berri merged commit 019a9de into main Oct 29, 2026
114 of 119 checks passed
@ryan-crabbe-berri
ryan-crabbe-berri deleted the litellm_quiet_detailed_debug_request_dumps branch October 29, 2026 02:30
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