Skip to content

feat: add request / response body logging to Claude batch API#1304

Open
tasoo-oos wants to merge 9 commits into
kwaroran:mainfrom
tasoo-oos:feat-claude-batch-logging
Open

feat: add request / response body logging to Claude batch API#1304
tasoo-oos wants to merge 9 commits into
kwaroran:mainfrom
tasoo-oos:feat-claude-batch-logging

Conversation

@tasoo-oos
Copy link
Copy Markdown
Contributor

@tasoo-oos tasoo-oos commented Mar 3, 2026

PR Checklist

  • Required Checks
    • Have you added type definitions?
    • Have you tested your changes?
    • Have you checked that it won't break any existing features?
  • If your PR uses models1, check the following:
    • Have you checked if it works normally in all models?
    • Have you checked if it works normally in all web, local, and node-hosted versions? If it doesn't, have you blocked it in those versions?
  • If your PR is highly AI generated2, check the following:
    • Have you understood what the code does?
    • Have you cleaned up any unnecessary or redundant code?
    • Is it not a huge change?
      • We currently do not accept highly AI generated PRs that are large changes.

Note

This PR is a continuation of the pre-existing PR called #1263.
I seperated this PR from that because this PR introduces seperate feature based on the new batch API implementation.

Summary

Unlike Other streaming
Add request / response body logging logic to the claude batch API.

Related Issues

None

Changes

Before changes

Example images image image
  • For per-message debug logging
    • Batch API does not leave any log
  • Request Logs viewer UI in advanced settings
    • Are filled with polling requests, which is useless for end users
    • No response body logged at all, only "Streamed Fetch"

After changes

Example images image image image image
  • Batch API does leave a request / response log
  • Now there's two log (initial batch API call, final batch result / errored API call) per one batch request
    • No redundant polling request logs saved
  • Now request uses header format defined in anthropic.ts. Refer to Example images for more detail.

Impact

No breaking changes

  • fetchNative now has optional function parameter
  • No more polling request visible on the native UI
    • visible only with f12 developers panel
    • Also, it was not so helpful for devs anyway

Additional Notes

I renewed the API key so don't worry.
Currently testing.....

Footnotes

  1. Modifies the behavior of prompting, requesting, or handling responses from AI models.

  2. Over 80% of the code is AI generated.

@tasoo-oos tasoo-oos marked this pull request as ready for review March 5, 2026 17:39
@tasoo-oos tasoo-oos marked this pull request as draft March 6, 2026 15:24
@tasoo-oos tasoo-oos marked this pull request as ready for review March 10, 2026 01:15
Copy link
Copy Markdown
Collaborator

@cubicj cubicj left a comment

Choose a reason for hiding this comment

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

The batch logging change looks good overall.

One unrelated change: redacted_thinking now exposes content.data only in the batch path, while the other Claude paths still render {{redacted_thinking}}. It also opens a backtick without closing it.

Could you check if that was intentional?

@tasoo-oos
Copy link
Copy Markdown
Contributor Author

tasoo-oos commented May 31, 2026

Done! I rolled it back to {{redacted_thinking}}.

Changed redacted thinking text was intentional back then, except for the typo. But come to think of it, there would be almost no practical reason to add informational message inside <thinking> block.

That was clumsy change on my side, thanks for the feedback!

Copy link
Copy Markdown
Collaborator

@cubicj cubicj left a comment

Choose a reason for hiding this comment

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

Verified the updated batch path. redacted_thinking now matches the regular Claude path again. Check, tests, and build pass on a trial merge with current origin/main.

Approving — thanks for the contribution!

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