-
Notifications
You must be signed in to change notification settings - Fork 1k
Python: Complete durableagent package #3058
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python: Complete durableagent package #3058
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR completes the durabletask package implementation by refactoring the Azure Functions agent integration to use shared durable task library components. The main changes remove redundant models from Azure Functions, consolidate session ID management, and improve the separation of concerns between orchestration context and agent execution.
Key Changes:
- Removes duplicate model implementations (
AgentSessionId,DurableAgentThread) from Azure Functions package, delegating to shared durabletask library - Adds comprehensive test coverage for the durabletask package (worker, client, executors, models, orchestration context)
- Introduces executor pattern with
ClientAgentExecutorandOrchestrationAgentExecutorfor different execution contexts - Updates Azure Functions to use shared components and improves API consistency
- Adds new durabletask sample code demonstrating single agent, orchestration chaining, and multi-agent concurrency patterns
Reviewed changes
Copilot reviewed 47 out of 48 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| python/packages/durabletask/agent_framework_durabletask/_models.py | Added AgentSessionId and DurableAgentThread with correlation_id as required field |
| python/packages/durabletask/agent_framework_durabletask/_client.py | New client wrapper for external interactions with durable agents |
| python/packages/durabletask/agent_framework_durabletask/_worker.py | New worker wrapper for agent registration as durable entities |
| python/packages/durabletask/agent_framework_durabletask/_executors.py | Executor implementations for client and orchestration contexts |
| python/packages/durabletask/agent_framework_durabletask/_shim.py | Agent protocol implementation delegating to executors |
| python/packages/durabletask/agent_framework_durabletask/_orchestration_context.py | Orchestration context wrapper for agent access |
| python/packages/durabletask/agent_framework_durabletask/_response_utils.py | Shared response handling utilities |
| python/packages/durabletask/tests/*.py | Comprehensive unit tests for all new components |
| python/packages/azurefunctions/agent_framework_azurefunctions/_orchestration.py | Refactored to use shared executor pattern and utilities |
| python/packages/azurefunctions/agent_framework_azurefunctions/_app.py | Updated to use shared models and improved session ID handling |
| python/packages/azurefunctions/agent_framework_azurefunctions/_models.py | Removed (all content moved to durabletask package) |
| python/samples/getting_started/durabletask/* | New samples demonstrating durabletask agent patterns |
| python/samples/getting_started/azure_functions/*.py | Minor fixes for type hints and removed redundant null checks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 47 out of 48 changed files in this pull request and generated no new comments.
| "[DurableAgentTask] Failed to convert result for correlation_id: %s", | ||
| self._correlation_id, | ||
| ) | ||
| raise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andystaples just to confirm, if a CompositeTask throws an exception, does the durable orchestrator handle it gracefully or do we need to do extra checks here?
Context: We're wrapping the task to call an entity in a CompositeTask so that we can strongly type the response back to AgentRunResponse to the caller.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This throw will cause the entire orchestration to fail without hitting user code, preventing users from try/catching the yield.
Instead you need to set _is_complete and _exception like you are doing on line 71-77, but since you'll need to construct a TaskFailedError, you will probably need a change like this
microsoft/durabletask-python#99
Reviewing this with the Python folks from Durable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that the required changes in Durabletask are in a PR, I'm going to merge this PR and follow-up with the required changes once the new version of durabletask is ready in production.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 45 out of 46 changed files in this pull request and generated no new comments.
python/packages/azurefunctions/agent_framework_azurefunctions/_app.py
Outdated
Show resolved
Hide resolved
python/packages/azurefunctions/agent_framework_azurefunctions/_app.py
Outdated
Show resolved
Hide resolved
python/packages/durabletask/agent_framework_durabletask/_client.py
Outdated
Show resolved
Hide resolved
python/packages/durabletask/agent_framework_durabletask/_executors.py
Outdated
Show resolved
Hide resolved
python/packages/durabletask/agent_framework_durabletask/_executors.py
Outdated
Show resolved
Hide resolved
python/packages/durabletask/agent_framework_durabletask/_executors.py
Outdated
Show resolved
Hide resolved
python/packages/durabletask/agent_framework_durabletask/_orchestration_context.py
Outdated
Show resolved
Hide resolved
python/packages/durabletask/agent_framework_durabletask/_orchestration_context.py
Show resolved
Hide resolved
Python Test Coverage Report •
Python Unit Test Overview
|
|||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 45 out of 46 changed files in this pull request and generated no new comments.
e3eff65
into
microsoft:feature-durabletask-python
Motivation and Context
Description
This PR adds the remainder of the changes needed for getting the
durabletaskpackage to work inagent-framework.This pull request refactors and simplifies the Azure Functions agent integration, focusing on removing redundant models, improving agent session handling, and clarifying type usage. The changes enhance maintainability and consistency by delegating responsibilities to shared libraries and updating internal APIs.
Removal of redundant models and code simplification
AgentSessionIdandDurableAgentThreadimplementation fromagent_framework_azurefunctions/_models.py, delegating session ID management to the shared durable task library insteadpython/packages/azurefunctions/agent_framework_azurefunctions/_models.pyL1-L201agent_framework_azurefunctions/_app.pyand_orchestration.pyto use session ID and agent types from the shared durable task library, eliminating local definitions and reducing duplication.Agent proxy and executor improvements
get_agentmethod inAgentFunctionAppto instantiateDurableAIAgentwith anAzureFunctionsAgentExecutor, ensuring better separation of orchestration context and agent execution. Also clarified the return type toDurableAIAgent[AgentTask].Session ID and entity management consistency
entity_nameandkeyproperties when constructingEntityIdobjects, rather than relying on a local conversion method. This affects both HTTP trigger and tool invocation flows.API response formatting and payload handling
Durable orchestration response handling
load_agent_responseandensure_response_formatfunctions, improving reliability and centralizing response format enforcement.Contribution Checklist