Repository navigation
fix(sdk): accept 6+ digit event indices in EventLog filename regex - #3927
Merged
Merged
Conversation
EVENT_FILE_PATTERN zero-pads the event index to a minimum of 5 digits
({idx:05d}) but never caps it, so a conversation whose append-only event
log grows past 99999 events writes 6-digit filenames. The reader regex
EVENT_NAME_RE matched exactly 5 digits (\d{5}), so on a cold reload
(process restart -> resume/fork) every event with index >= 100000 was
treated as "Unrecognized", silently truncating the log and corrupting the
length accounting (the prefix-based _count_events_on_disk kept counting
them). Relax the reader to \d{5,} so it accepts whatever width the writer
emits. Backward compatible: existing 5-digit names still match.
Closes OpenHands#3926
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
tomsen02
marked this pull request as ready for review
June 30, 2026 12:10
VascoSch92
reviewed
Jun 30, 2026
VascoSch92
left a comment
Member
There was a problem hiding this comment.
LGTM!
If you can fix the couple of nits I pointed out, than we can merge. ;-)
- Trim the persistence_const comment to a single concise line. - Drop the regression divider comment block in the test module. - Hoist the per-test persistence_const imports to module top. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Thanks for the review! Addressed all four nits in 455b86d:
Tests still green (29 passed), ruff check/format clean. Ready when you are 🙂 |
5 tasks
Draft
1 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HUMAN:
The writer pads the event index with
{idx:05d}(a 5-digit minimum, uncapped) while the reader regex matched exactly\d{5}. So any event log that grows past 99,999 events writes 6-digit filenames the reader can no longer recognise, and the tail of the history is silently dropped on the next cold reload. This widens the reader to\d{5,}and adds regression tests across the boundary.AGENT:
Why
EVENT_FILE_PATTERN = "event-{idx:05d}-{event_id}.json"zero-pads the event index to a minimum of 5 digits and never caps it, so an append-only event log that grows past 99,999 events writes 6-digit filenames (event-100000-...). The readerEVENT_NAME_REmatched exactly 5 digits (\d{5}), so on a cold reload (process restart → resume/fork) every event with index ≥ 100000 was treated as "Unrecognized event file name" and excluded from the rebuilt index.Consequences (silent, persistent, irreversible):
_scan_and_build_index()stops at the first missing contiguous index, solen(EventLog)is truncated to 100000 — the tail of the history is silently lost on reload._count_events_on_disk()still counts the 6-digit files, so it diverges from the scan; the nextappend()triggers_sync_from_diskand the length accounting becomes permanently inconsistent (idx 100000+ are on disk but unreadable holes).Reported and analysed in #3926.
Summary
\d{5}to\d{5,}so it accepts whatever width the{idx:05d}writer emits. One character; fully backward compatible (existing 5-digit names still match).Issue Number
Closes #3926
How to Test
Run the new + existing EventLog tests:
Guard verification — the new tests fail on the pre-fix regex and pass after the fix. Temporarily reverting
\d{5,}→\d{5}:End-to-end reproduction before the fix (a 100,002-event log cold-reloads as length 100000, and idx 100000/100001 raise
IndexError: Event index out of range); after the fix the same log reloads as 100002 with all events readable.lint/format:
uv run ruff checkandruff format --checkclean on both files.