fix: compare in-memory task timestamps numerically - #1233
Open
AndreyGatsuk wants to merge 1 commit into
Open
Conversation
🧪 Code Coverage (vs
|
| Base | PR | Delta | |
|---|---|---|---|
| src/a2a/server/tasks/inmemory_task_store.py | 97.06% | 100.00% | 🟢 +2.94% |
| Total | 93.06% | 93.09% | 🟢 +0.03% |
Generated by coverage-comment.yml
AndreyGatsuk
marked this pull request as ready for review
September 9, 2026 10:18
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.
Description
Fix timestamp filtering and descending ordering in
InMemoryTaskStore.list(). ComparingToJsonString()values lexicographically reverses chronological order when fractional-second precision differs. For example,2025-01-01T00:00:00.123Zincorrectly passes a filter whose threshold is2025-01-01T00:00:00.123000001Z, despite being one nanosecond earlier. The same comparison also produces incorrectly ordered pages.Compare integer nanoseconds using
ToNanoseconds()for both filtering and sorting. Preserve the inclusive filter boundary, descending ID tie-breaker, and placement of tasks without timestamps after timestamped tasks.A2A specification §5.6.1, Timestamps states: “Millisecond precision SHOULD be used where available”. It also specifies
google.protobuf.Timestamp, whose representation contains seconds and nanoseconds, and permits omitted fractional seconds. Numeric comparison handles these precisions without discarding sub-millisecond information.Add 15 regression cases covering seconds, milliseconds, microseconds, nanoseconds, equal timestamps, second boundaries, pagination, ID tie-breaking, absent timestamps/status, and timestamps before/at the Unix epoch. Before the fix, 11 cases fail and four pass; after the fix, all 35 in-memory task store tests pass.
Validation on Python 3.10 with PostgreSQL 15 and MySQL 8:
./scripts/lint.sh: Ruff check/format and ty passed (three existing unused-ignore warnings outside this change).uv run pytest: 2,092 passed, 3 xfailed, 1 xpassed. The xfail/xpass cases are already marked for [Feat]: Improve server concurrency architecture #869.uv run pytest --cov=src --cov-report=term-missing --cov-fail-under=88: same test results, 93.17% coverage.tests.install_smokein six clean environments: base, http-server, fastapi, grpc, telemetry, and sql all passed.Local transport checks used proxy exclusions for loopback addresses. Cross-version
uv --withenvironments were prepared before the full runs to keep dependency downloads outside server-startup timeouts.fix: compare in-memory task timestamps numerically.