Visitar URL original
Python: Normalize Foundry checkpoint timestamps for comparison by ryo-whaletech · Pull Request #10337 · microsoft/agent-framework · GitHub
Skip to content

Python: Normalize Foundry checkpoint timestamps for comparison - #10337

Open
WhaleTech (ryo-whaletech) wants to merge 1 commit into
microsoft:mainfrom
ryo-whaletech:codex/fix-foundry-checkpoint-timestamps
Open

WhaleTech (ryo-whaletech) wants to merge 1 commit into
microsoft:mainfrom
ryo-whaletech:codex/fix-foundry-checkpoint-timestamps

Conversation

@ryo-whaletech

Copy link
Copy Markdown
Contributor

Motivation & Context

Foundry checkpoint selection raises TypeError when saved checkpoints mix naive and timezone-aware ISO timestamps.
Both representations pass through save() and load(), but the selector cannot compare them. The default generated
timestamps are aware; this affects supplied or existing naive timestamps.

Apply the comparison policy already used by Core after #9944
to the Foundry store.

Description & Review Guide

  • What are the major changes?
    • Add a local timestamp parser that assigns UTC to naive values for comparison.
    • Use it for both newest-timestamp selection and candidate filtering, preserving lineage/ID tie-breakers.
    • Add six save() / get_latest() regressions covering naive-older, naive-newer, equal-instant lineage, and both
      save orders. Only the external SDK storage boundary is mocked.
  • What is the impact of these changes?
    • Mixed timestamps select the expected checkpoint instead of raising the comparison TypeError.
    • Saved timestamp strings, checkpoint encodings, scopes, SDK calls, and public signatures stay the same.
    • Malformed timestamp strings still raise ValueError; the change does not catch or suppress storage failures.
    • The local parser also works with the declared Core 1.25.0 floor, whose published selector still lacks this fix.
      No dependency-floor increase or reliance on a newer private Core helper is introduced.
  • What do you want reviewers to focus on?
    • Naive-as-UTC comparison, same-instant parent/child selection, and preservation of the original persisted values.

Local validation on 7a166e79e7a0025f3bc3a752e328f341cbaddf25 with Python 3.11.14 on macOS arm64:
Foundry Hosting gives 1,113 passed / 36 integration tests deselected. The frozen-workspace aggregate command
poe test -A -n 4 gives 21,441 passed / 580 skipped / 5 xfailed. Strict source Pyright, all five test type checkers,
Ruff lint/format, and changed-file pre-commit hooks pass (poe-check skipped as in CI).

The released hosting wheel fails all six new cases with Core 1.25.0 and the direct SDK dependency floors.
Installing the locally built candidate wheel in the same environment gives 67 passing state-store tests. The
compatible lower-bound combination uses httpx2 2.5.0 because MCP 2.2.0 requires it. Dependency checks also pass.
Test runs include existing deprecation/experimental warnings; the aggregate run reports 1,494 warnings.
Linux/Windows runners and live-service integration tests were not run locally.

Related Issue

Fixes #10336

Maintainer agreement on this Foundry-specific follow-up has not yet been recorded.

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: Duplicate research, reproduction, diagnosis, implementation, regression tests, validation,
and this description.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Treat naive checkpoint timestamps as UTC when selecting the latest Foundry
checkpoint. Compare normalized instants for newest selection and lineage
ties while preserving the original timestamp strings in storage.

Cover saved checkpoint selection for mixed naive and aware timestamps,
equivalent instants, and both save orders without a newer Core helper.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the checkpoint timestamp-comparison update.

No open issues 🎉

What changed in this PR

This PR aligns Foundry checkpoint selection with Core’s timestamp policy, fixing comparisons between naive and timezone-aware timestamps without changing persisted values or public APIs.

Changes:

  • Treat naive timestamps as UTC during latest-checkpoint selection and candidate filtering.
  • Preserve lineage and checkpoint-ID tie-breaking.
  • Add six regression cases covering mixed timestamps, equal-instant lineage, both save orders, and unchanged stored timestamp strings.
File Description
python/​packages/​foundry_hosting/​tests/​test_state_store.py Adds save/get-latest regressions for mixed timestamps and persistence preservation.
python/​packages/​foundry_hosting/​agent_framework_foundry_hosting/​_state_store.py Adds a local timestamp parser and uses it for checkpoint comparisons.

Review effort: Balanced

This branch was successfully deployed

1 active deployment
github-app-auth — 66034005 Deployed Nov 13, 2026 by ryo-whaletech via team_check #9429
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: Foundry checkpoint selection fails on mixed naive and aware timestamps

2 participants