Conversation
Co-authored-by: larohra <41490930+larohra@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add orchestration ID to durable agent entity state
Python: Add orchestration ID to durable agent entity state
Nov 26, 2025
larohra
approved these changes
Nov 26, 2025
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds orchestration ID tracking to durable agent entity state, porting functionality from the .NET implementation (PR #2137). This enables bidirectional correlation between orchestrations and agent requests, which is essential for tools like the DTS Dashboard to analyze agent state and trace requests back to their originating orchestration.
Key Changes
- Added
orchestration_idfield toRunRequestandDurableAgentStateRequestmodels with proper serialization asorchestrationId - Bumped schema version from
1.0.0to1.1.0to reflect the state structure change - Modified
DurableAIAgent.run()to automatically capture and propagatecontext.instance_idas the orchestration ID
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| python/packages/azurefunctions/agent_framework_azurefunctions/_models.py | Added orchestration_id field to RunRequest with camelCase serialization |
| python/packages/azurefunctions/agent_framework_azurefunctions/_durable_agent_state.py | Added orchestration_id to DurableAgentStateRequest, bumped schema version to 1.1.0, and refactored parsing helper functions |
| python/packages/azurefunctions/agent_framework_azurefunctions/_orchestration.py | Set orchestration_id from context.instance_id in DurableAIAgent.run() |
| python/packages/azurefunctions/tests/test_models.py | Added comprehensive tests for orchestration_id serialization/deserialization in RunRequest |
| python/packages/azurefunctions/tests/test_orchestration.py | Added tests verifying orchestration_id is set from context.instance_id |
| python/packages/azurefunctions/tests/test_entities.py | Added tests for orchestration_id in DurableAgentStateRequest and minor type annotation change |
| python/packages/azurefunctions/agent_framework_azurefunctions/_app.py | Unrelated refactoring: type annotations and code improvements in MCP tool handler |
| python/uv.lock | Dependency updates for a2a-sdk, pydantic, redisvl, and uv |
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
python/packages/azurefunctions/agent_framework_azurefunctions/_durable_agent_state.py
Show resolved
Hide resolved
cgillum
reviewed
Nov 26, 2025
python/packages/azurefunctions/agent_framework_azurefunctions/_models.py
Show resolved
Hide resolved
cgillum
approved these changes
Nov 27, 2025
Member
cgillum
left a comment
There was a problem hiding this comment.
My remaining comment is not a blocker.
gavin-aguiar
approved these changes
Dec 1, 2025
Member
cgillum
approved these changes
Dec 2, 2025
arisng
pushed a commit
to arisng/agent-framework
that referenced
this pull request
Feb 2, 2026
…efactor (microsoft#2484) * Initial plan * Add orchestration ID to durable agent entity state for Python Co-authored-by: larohra <41490930+larohra@users.noreply.github.com> * Fix type safety checks * Fix tests --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: larohra <41490930+larohra@users.noreply.github.com> Co-authored-by: Laveesh Rohra <larohra@microsoft.com>
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.
Motivation and Context
Enables correlation of agent requests back to their originating orchestration—currently this correlation only works in one direction (orchestration → agent). Tools like the DTS Dashboard need this to analyze agent state.
Fixes #2205 (similar to #2137)
Sample data in entity - (
"orchestrationId": "0b6fbdcf474946b38c37c293010f567d"){"schemaVersion": "1.1.0", "data": {"conversationHistory": [{"$type": "request", "correlationId": "5d16b15d-c915-5dec-93ce-67787dea8fd0", "createdAt": "2025-11-26T21:15:19.146197+00:00", "messages": [{"role": "user", "contents": [{"$type": "text", "text": "What is temperature?"}], "createdAt": "2025-11-26T21:15:19.146191+00:00"}], "orchestrationId": "0b6fbdcf474946b38c37c293010f567d", "responseType": "text"}, {"$type": "response", "correlationId": "5d16b15d-c915-5dec-93ce-67787dea8fd0", "createdAt": "2025-11-26T13:15:20+00:00", "messages": [{"role": "assistant", "contents": [{"$type": "text", "text": "Temperature, from a chemistry perspective, is a physical property that represents the average kinetic energy of the particles (atoms, ions, or molecules) in a substance. It reflects how much motion or energy is present within a system at the microscopic level. \n\nIn simple terms:\n- Higher temperature means particles are moving faster (more kinetic energy).\n- Lower temperature means particles are moving slower (less kinetic energy).\n\nTemperature is crucial in chemistry because it affects the rate of chemical reactions, the phase of matter (solid, liquid, gas), and the properties of substances (e.g., solubility, viscosity). It is measured using scales like Celsius (\u00b0C), Kelvin (K), or Fahrenheit (\u00b0F), with Kelvin being favored in scientific contexts because it starts at absolute zero, the theoretical point where particle motion ceases completely."}], "authorName": "ChemistAgent"}], "usage": {"inputTokenCount": 30, "outputTokenCount": 166, "totalTokenCount": 196}}]}}azurefunctionspackage.Description
Propagates orchestration ID from
DurableOrchestrationContext.instance_idto the agent's entity state whenDurableAIAgent.run()is called within an orchestration.Changes:
_models.py: Addedorchestration_idfield toRunRequestwith serialization asorchestrationId_durable_agent_state.py: Addedorchestration_idtoDurableAgentStateRequest, updatedfrom_run_request()to transfer the field_durable_agent_state.py: Bumped schema version1.0.0→1.1.0_orchestration.py: Setorchestration_id=self.context.instance_idinDurableAIAgent.run()Usage in orchestration:
The
orchestrationIdfield appears in persisted entity state under each request entry, enabling reverse correlation from agent state to orchestration.Contribution Checklist
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.