Skip to content

fix(proxy): log guardrailed Responses stream output - #46530

Open
IxayWolf wants to merge 1 commit into
BerriAI:mainfrom
IxayWolf:litellm_responses_served_output_logging
Open

IxayWolf wants to merge 1 commit into
BerriAI:mainfrom
IxayWolf:litellm_responses_served_output_logging

Conversation

@IxayWolf

Copy link
Copy Markdown

TLDR

Problem this solves:

  • Stream logs can retain pre-guardrail Responses output
  • Tool input rewrites can be absent from observability exports

How it solves it:

  • Capture the terminal event actually served to clients
  • Use it for success logs and logging hooks

User Flow

Before: a streamed Responses request is rewritten for the client, but its request log can retain the original output

  1. A developer sends POST https://litellm-domain/v1/responses with "stream": true
  2. A post-call guardrail rewrites response text or tool input
  3. The client receives the rewritten terminal event
  4. The developer inspects the request log and can see the original output

After: the same request log contains the response actually served to the client

  1. A developer sends POST https://litellm-domain/v1/responses with "stream": true
  2. A post-call guardrail rewrites response text or tool input
  3. The client receives the rewritten terminal event
  4. The developer inspects the request log and sees only the rewritten output

Pre-Submission checklist

  • I have added meaningful tests
  • The handful of test files covering my change pass locally
  • My PR passes all required CI/CD checks
  • My PR scope is as isolated as possible
  • Every automated review on the latest commit has finished

Type

🐛 Bug Fix

Final Attestation

  • The tests cover rewritten text, tool input, logging hooks, and sync and async success paths

@CLAassistant

CLAassistant commented Oct 14, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codspeed

codspeed Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

⚠️ 1 benchmark spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 31 untouched benchmarks


Comparing IxayWolf:litellm_responses_served_output_logging (ff16d72) with main (685c3ec)

Open in CodSpeed

@codecov

codecov Bot commented Oct 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

This branch has not been deployed

No deployments
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