Python: Update agentserver to 2.1.0 - #7621
Conversation
There was a problem hiding this comment.
Pull request overview
Updates Python Foundry hosting for AgentServer 2.1, durable local storage, stable conversation identifiers, and custom Cosmos DB session storage.
Changes:
- Upgrades AgentServer dependencies and storage providers.
- Uses conversation-chain IDs for sessions and workflow checkpoints.
- Adds a custom Cosmos DB storage sample and updates tests/docs.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
custom_storage/requirements.txt |
Adds sample dependencies. |
custom_storage/README.md |
Documents custom storage usage. |
custom_storage/main.py |
Implements Cosmos-backed sessions. |
custom_storage/Dockerfile |
Packages the sample. |
custom_storage/.env.example |
Lists required configuration. |
custom_storage/.dockerignore |
Excludes local artifacts. |
tests/test_state_store.py |
Updates provider expectations. |
tests/test_responses.py |
Replaces removed in-memory approval store. |
foundry_hosting/README.md |
Documents durable local persistence. |
foundry_hosting/pyproject.toml |
Updates AgentServer dependencies. |
_state_store.py |
Uses Foundry stores in all environments. |
_responses.py |
Revises session and checkpoint scoping. |
_request_context.py |
Removes obsolete path validation. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
| "azure-ai-agentserver-responses>=2.0.0b1,<3", | ||
| "azure-ai-agentserver-invocations>=1.0.0b8,<2", | ||
| "azure-ai-agentserver-core>=2.1.0b1,<3", | ||
| "azure-ai-agentserver-responses>=2.0.0,<3", |
| context_id = context.conversation_chain_id | ||
| session = await session_storage.get(context_id) |
| context_id = context.conversation_chain_id | ||
| checkpoint_storage = self._checkpoint_storage_provider.get_store(config=self.config, context_id=context_id) | ||
|
|
| Set all variables in `.env.example`, including the Cosmos settings, and follow | ||
| [Deploying the Agent to Foundry](../../README.md#deploying-the-agent-to-foundry) | ||
| in the parent README. The hosted provider initializes Cosmos DB lazily on its first |
| config=self.config, | ||
| context_id=write_context_id, | ||
| ) | ||
| latest_checkpoint = await checkpoint_storage.get_latest(workflow_name=self._agent.workflow.name) |
| session = self._agent.create_session() | ||
| else: | ||
|
|
||
| context_id = context.conversation_chain_id |
There was a problem hiding this comment.
This key no longer restores regular-agent state for previous_response_id requests in the actual endpoint path: the existing generated-ID chain test observes [1, 1, 1] instead of restoring the prior session, and a missing previous response silently creates a fresh session. That breaks the core multi-turn workflow and discards conversation state without notifying the caller. Please ensure the first response and its continuations resolve to the same persisted key, while preserving an error for a genuinely unknown previous response.
| # any future async resources owned by the workflow are entered here. | ||
| await self._ensure_agent_ready() | ||
|
|
||
| context_id = context.conversation_chain_id |
There was a problem hiding this comment.
The new SDK safely hashes malformed context values into opaque IDs, but the three existing checkpoint-context tests still require these inputs to produce response.failed; all three now complete successfully and fail the suite. Please update the tests to assert the new safe-key behavior, or retain explicit rejection if that remains the package contract.
Motivation & Context
WIP: more testing is needed
Description & Review Guide
Related Issue
Fixes #
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.