Skip to content

fix: floor AgentCore Memory event timestamps to milliseconds#573

Merged
jariy17 merged 1 commit into
mainfrom
fix/monotonic-timestamp-ms-floor
Jul 9, 2026
Merged

fix: floor AgentCore Memory event timestamps to milliseconds#573
jariy17 merged 1 commit into
mainfrom
fix/monotonic-timestamp-ms-floor

Conversation

@jariy17

@jariy17 jariy17 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #572 (now merged), addressing @opieter-aws's review feedback.

Problem

_get_monotonic_timestamp compares and stores at microsecond precision (datetime.now() is microsecond-precision), but AgentCore Memory only keeps milliseconds (the eventId prefix 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_timestamp to 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). Existing test_none_desired_uses_current_time updated to compare against ms-floored bounds. Memory module green locally (2 unrelated async tests need pytest-asyncio, green in CI).

@jariy17 jariy17 requested a review from a team July 9, 2026 20:16
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Jul 9, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Jul 9, 2026
aidandaly24
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.
@jariy17 jariy17 dismissed aidandaly24’s stale review July 9, 2026 20:40

The merge-base changed after approval.

@jariy17 jariy17 force-pushed the fix/monotonic-timestamp-ms-floor branch from 3ce8ddd to 649d940 Compare July 9, 2026 20:40
@jariy17 jariy17 changed the title fix: order AgentCore Memory events at millisecond resolution fix: floor AgentCore Memory event timestamps to milliseconds Jul 9, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Jul 9, 2026
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

✅ No Breaking Changes Detected

No public API breaking changes found in this PR.

@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Jul 9, 2026
@jariy17 jariy17 merged commit f855616 into main Jul 9, 2026
41 checks passed
@jariy17 jariy17 deleted the fix/monotonic-timestamp-ms-floor branch July 9, 2026 20:44
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