Visitar URL original
Count UTF-8 bytes when batching imported session entries by gulagala001 · Pull Request #1499 · anthropics/claude-agent-sdk-python · GitHub
Skip to content

Count UTF-8 bytes when batching imported session entries - #1499

Open
gulagala001 wants to merge 1 commit into
anthropics:mainfrom
gulagala001:fix/import-utf8-byte-budget
Open

gulagala001 wants to merge 1 commit into
anthropics:mainfrom
gulagala001:fix/import-utf8-byte-budget

Conversation

@gulagala001

Copy link
Copy Markdown

import_session_to_store flushes a batch after reaching a threshold in line bytes. It currently increments the counter with the number of Unicode characters. A transcript containing unescaped CJK text or emoji can therefore send much larger batches to the destination store.

Count UTF-8 bytes of the JSON line. The existing entry-count trigger and handling of single large entries are unchanged. The regression test imports a real temporary transcript through the public API, with a byte threshold equal to two entries. On main it flushed all four together. With the fix it flushes two batches of two, in order, on both asyncio and Trio.

Local checks: 1,651 tests passed, 6 skipped. Ruff and mypy passed. Prepared and tested with Codex.

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.

1 participant