Skip to content

[Agent Server] Persist identity fields in checkpoints - #49765

Open
Slai.life (huong8373tt-beep) wants to merge 3 commits into
Azure:mainfrom
huong8373tt-beep:fix/checkpoint-persist-response-identity-49475
Open

Slai.life (huong8373tt-beep) wants to merge 3 commits into
Azure:mainfrom
huong8373tt-beep:fix/checkpoint-persist-response-identity-49475

Conversation

@huong8373tt-beep

@huong8373tt-beep Slai.life (huong8373tt-beep) commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #49475.

Checkpoint writes from a ResponseEventStream(response_id=...) now use the same response-snapshot normalization as terminal persistence. This stamps the resolved response identity before update_response, including:

  • response_id
  • agent reference
  • model
  • agent session
  • conversation
  • persisted background mode

The change is limited to checkpoint persistence and does not expose checkpoint events on the wire. Snapshot preparation remains inside the existing failure guard, so an extension value that cannot be deep-copied (for example, a generator) safely skips the checkpoint without breaking the live response.

Validation

  • tests/unit/test_checkpoint.py — 9 passed.
  • tests/unit/test_event_copy_reuse.py — 27 passed.
  • Combined checkpoint/event-copy regression — 36 passed.
  • MyPy passed for the 70 affected source files after the explicit provider-boundary cast.
  • python -m compileall -q sdk/agentserver/azure-ai-agentserver-responses/azure tests — passed.
  • python -m build --wheel — passed.
  • git diff --check — passed.
  • Pytest used an E-drive --basetemp because the Windows host had a stale C-drive temporary link with insufficient access; no production dependency was changed.

The targeted regression covers an unseeded checkpoint and asserts that the independently persisted payload contains the resolved identity and background mode. It also covers generator-valued extensions and verifies that checkpoint preparation failures are swallowed without affecting the live response.

Disclosure and authorization

Slai Agent Runtime performed the investigation, implementation, and test execution. The account owner authorized this contribution and is responsible for its content.

Copilot AI balanced review requested due to automatic review settings October 29, 2026 22:52
@github-actions github-actions Bot added Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. Hosted Agents sdk/agentserver/* labels Oct 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution Slai.life (@huong8373tt-beep)! We will review the pull request and get back to you soon.

@huong8373tt-beep
Slai.life (huong8373tt-beep) marked this pull request as draft October 29, 2026 22:53
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
10 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

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.

🟡 Changes recommended

The new deepcopy can raise an uncaught TypeError for generator-valued extensions, causing live responses to fail instead of safely skipping the checkpoint.

1 open issue
What changed in this PR

This PR addresses #49475 by applying terminal-response identity normalization to checkpoint persistence, making checkpoints independently storable without exposing checkpoint events on the wire.

Changes:

  • Forward resolved agent, model, session, and conversation identity to checkpoint persistence.
  • Normalize checkpoint snapshots and persist the background mode flag.
  • Add a regression test asserting the persisted checkpoint payload includes identity fields.
File Description
sdk/​agentserver/​azure-ai-agentserver-responses/​tests/​unit/​test_checkpoint.py Adds checkpoint identity and background-mode assertions.
sdk/​agentserver/​azure-ai-agentserver-responses/​azure/​ai/​agentserver/​responses/​hosting/​_orchestrator.py Normalizes checkpoint payloads and forwards resolved identity from both checkpoint call sites.

Review effort: Balanced

@huong8373tt-beep

Copy link
Copy Markdown
Contributor Author

Addressed the Copilot review finding in e7809a0974.

Checkpoint snapshot preparation is now inside the existing serialization guard. If a response extension contains a generator or another value that cannot be deep-copied, checkpointing returns the prior snapshot without failing the live response. Added test_checkpoint_preparation_failure_is_swallowed to cover this path.

Validation:

  • tests/unit/test_checkpoint.py: 9 passed
  • tests/unit/test_event_copy_reuse.py: 27 passed
  • combined: 36 passed
  • python -m compileall -q azure tests: passed
  • wheel build: passed
  • git diff --check: passed

The test environment required the repository's current httpx2 dependency for Starlette's test client; no production dependency was changed.

@huong8373tt-beep

Copy link
Copy Markdown
Contributor Author

Addressed the Azure Pipelines MyPy failure reported by the analyzer: checkpoint_response is normalized as a dictionary at runtime, but the response provider protocol expects the generated ResponseObject TypedDict. The persistence call now uses an explicit cast at the provider boundary. Local validation: MyPy passed for 70 source files; checkpoint and event-copy tests passed (36 tests). Commit: 660a5759d1.

@huong8373tt-beep

Copy link
Copy Markdown
Contributor Author

Revalidated the checkpoint change at the current head: test_checkpoint.py plus test_event_copy_reuse.py pass (36 passed), and python -m compileall -q sdk/agentserver/azure-ai-agentserver-responses/azure passes. The checkpoint preparation path retains the generator-safe failure guard; the current type-boundary update is included in the refreshed head. Azure Pipelines has been restarted.

@huong8373tt-beep
Slai.life (huong8373tt-beep) marked this pull request as ready for review October 30, 2026 01:22
Copilot AI balanced review requested due to automatic review settings October 30, 2026 01:22

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 were identified for the checkpoint persistence normalization change.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@huong8373tt-beep

Copy link
Copy Markdown
Contributor Author

The current Azure pipeline run completed all build, documentation, MyPy, lint, and test jobs successfully. The only failure is the repository dependency analyzer, which reports that azure-ai-agentserver-core >=2.3.0, <3.0.0 has no resolvable combination. This PR does not change dependency declarations. Could a maintainer confirm whether this analyzer failure is a repository/package-index baseline issue or whether an additional metadata update is expected for this change?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. Hosted Agents sdk/agentserver/*

Projects

None yet

2 participants