Skip to content

fix: ignore internal API request snapshots in turn assembly - #107

Open
rodaddy wants to merge 2 commits into
langfuse:mainfrom
rodaddy:fix/ignore-api-request-blobs
Open

rodaddy wants to merge 2 commits into
langfuse:mainfrom
rodaddy:fix/ignore-api-request-blobs

Conversation

@rodaddy

@rodaddy rodaddy commented Oct 18, 2026 •

Copy link
Copy Markdown

agent: codex · model gpt-6.1-sol · seat langfuse worker · 2026-10-18

Summary

Claude Code's internal api-request-blob records can contain a nested
message.role of user or assistant. The role classifier currently accepts
that fallback, so a request snapshot can start a conversation turn or append
an assistant message. Ignore these records before classifying conversation
rows. Other nested-role transcript formats retain their existing behavior.

Plain words

Claude Code saves internal copies of requests alongside the conversation.
This change skips those copies so they cannot become extra messages or
split the conversation into incorrect turns.

Validation

Add one parameterized regression using the existing hook_module fixture:
both nested roles must return None for api-request-blob. Both cases fail
against main at b5b7cc3 and pass with the guard.

Also use the existing _now_iso() helper for the other-session state fixture.
Its fixed September timestamp has expired under the 30-day retention rule,
which prevents the test from exercising concurrent-entry preservation.
Production retention behavior is unchanged.

Validation: 281 tests pass, Ruff F/E9 passes, and the empty-payload hook smoke
passes. The affected turn-assembly file passes all five cases. No formatter
changes are included.

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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