fix: floor AgentCore Memory event timestamps to milliseconds#573
Merged
Conversation
Contributor
|
Claude Security Review: no high-confidence findings. (run) |
aidandaly24
previously approved these changes
Jul 9, 2026
Comparing at microsecond precision missed collisions: two events in the same millisecond but different microseconds passed the tie check yet collide once the service floors both to the same millisecond (AgentCore Memory stores and orders eventTimestamp at ms resolution). Floor the desired timestamp to ms first so same-ms events are detected as a tie and separated by 1ms.
The merge-base changed after approval.
3ce8ddd to
649d940
Compare
Contributor
✅ No Breaking Changes DetectedNo public API breaking changes found in this PR. |
Contributor
|
Claude Security Review: no high-confidence findings. (run) |
aidandaly24
approved these changes
Jul 9, 2026
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.
Follow-up to #572 (now merged), addressing @opieter-aws's review feedback.
Problem
_get_monotonic_timestampcompares and stores at microsecond precision (datetime.now()is microsecond-precision), but AgentCore Memory only keeps milliseconds (theeventIdprefix is a ms epoch). So two events in the same millisecond but different microseconds pass the tie check — the later one looks strictly greater — yet collide once the service floors both to the same millisecond. That reintroduces the ambiguous ordering the tie-break is meant to prevent.Change
Floor
desired_timestampto milliseconds before the comparison, so same-ms events are correctly detected as a tie and separated by 1ms.Testing
Two regression tests added to
TestMonotonicTimestamp: timestamps are floored to ms, and a same-millisecond / different-microsecond pair is treated as a tie (second bumped to +1ms). Existingtest_none_desired_uses_current_timeupdated to compare against ms-floored bounds. Memory module green locally (2 unrelated async tests needpytest-asyncio, green in CI).