Skip to content

enable raw response logging#264

Merged
Alex Z (CLowbrow) merged 9 commits into
mainfrom
alex/enable-raw-response-logging
Jun 12, 2026
Merged

enable raw response logging#264
Alex Z (CLowbrow) merged 9 commits into
mainfrom
alex/enable-raw-response-logging

Conversation

@CLowbrow

@CLowbrow Alex Z (CLowbrow) commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Want to be able to log untransformed responses

@CLowbrow Alex Z (CLowbrow) changed the title [WIP] enable raw response logging enable raw response logging Jun 1, 2026

/// Stream of transformed chunks ready for output.
/// Serialized using lingua's serde_json at the boundary.
pub type ResponseStream = Pin<Box<dyn Stream<Item = Result<StreamChunk>> + Send>>;

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.

I wonder if another possible version is to return a stream that returns something like StreamChunkWithRaw, instead of adding a callback function? Just so we get all results the same way and don't have to worry about blocking this loop with the callback function. I don't feel too strongly about this, though

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think this is right but is also hard because raw chunks can produce 0+ transformed chunks. I am cowardly going to back out of trying this for now.

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.

That's fair. Maybe add a comment that callback does block the response stream so not to do anything too crazy in it?

Comment thread crates/braintrust-llm-router/src/router.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5039c88669

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "Codex (@codex) address that feedback".

Comment thread crates/braintrust-llm-router/src/router.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

let result = lingua::transform_response(response_bytes.clone(), output_format)?;

P2 Badge Preserve raw body when response transformation fails

When an upstream returns a 2xx body that lingua::transform_response cannot parse or convert for the requested output format, this new raw-response API returns Err here before constructing CompleteResponseWithRaw, so callers cannot log the raw provider body in exactly the failure case raw logging is meant to diagnose. The streaming capture path explicitly captures before transform errors, but the non-streaming path drops the already-received response_bytes on this ?.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "Codex (@codex) address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5deca009e8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "Codex (@codex) address that feedback".

Comment thread crates/braintrust-llm-router/src/error.rs Outdated
@CLowbrow Alex Z (CLowbrow) requested a review from aswink June 5, 2026 23:30
@CLowbrow Alex Z (CLowbrow) merged commit 9a18f86 into main Jun 12, 2026
7 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.

2 participants