Skip to content

fix: compare in-memory task timestamps numerically - #1233

Open
AndreyGatsuk wants to merge 1 commit into
a2aproject:mainfrom
AndreyGatsuk:fix/inmemory-task-timestamp-ordering
Open

fix: compare in-memory task timestamps numerically#1233
AndreyGatsuk wants to merge 1 commit into
a2aproject:mainfrom
AndreyGatsuk:fix/inmemory-task-timestamp-ordering

Conversation

@AndreyGatsuk

Copy link
Copy Markdown

Description

Fix timestamp filtering and descending ordering in InMemoryTaskStore.list(). Comparing ToJsonString() values lexicographically reverses chronological order when fractional-second precision differs. For example, 2025-01-01T00:00:00.123Z incorrectly passes a filter whose threshold is 2025-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.
  • JSCPD: 2.61% duplication, below the 3% threshold.
  • Built the wheel and ran tests.install_smoke in 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 --with environments were prepared before the full runs to keep dependency downloads outside server-startup timeouts.

  • Follow the CONTRIBUTING guide: feature branch based on current upstream main.
  • Conventional Commit title: fix: compare in-memory task timestamps numerically.
  • Tests and linters pass.
  • Protocol reference included above; no public API changes.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

🧪 Code Coverage (vs main)

⬇️ Download Full Report

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
AndreyGatsuk marked this pull request as ready for review September 9, 2026 10:18
@AndreyGatsuk
AndreyGatsuk requested a review from a team as a code owner September 9, 2026 10:18
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