Skip to content

Commit e777033

Browse files
committed
Match call_activity and call_activity_with_retry signatures and docstrings precisely
1 parent 1244b42 commit e777033

File tree

1 file changed

+46
-8
lines changed

1 file changed

+46
-8
lines changed

azure/durable_functions/openai_agents/context.py

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Callable, Optional, TYPE_CHECKING
1+
from typing import Any, Callable, Optional, TYPE_CHECKING, Union
22

33
from azure.durable_functions.models.DurableOrchestrationContext import (
44
DurableOrchestrationContext,
@@ -8,6 +8,8 @@
88
from agents import RunContextWrapper, Tool
99
from agents.function_schema import function_schema
1010
from agents.tool import FunctionTool
11+
12+
from azure.durable_functions.models.Task import TaskBase
1113
from .task_tracker import TaskTracker
1214

1315

@@ -55,17 +57,53 @@ def __init__(
5557
self._task_tracker = task_tracker
5658
self._model_retry_options = model_retry_options
5759

58-
def call_activity(self, activity_name, input: str):
59-
"""Call an activity function and record the activity call."""
60-
task = self._context.call_activity(activity_name, input)
60+
def call_activity(
61+
self, name: Union[str, Callable], input_: Optional[Any] = None
62+
) -> TaskBase:
63+
"""Schedule an activity for execution.
64+
65+
Parameters
66+
----------
67+
name: str | Callable
68+
Either the name of the activity function to call, as a string or,
69+
in the Python V2 programming model, the activity function itself.
70+
input_: Optional[Any]
71+
The JSON-serializable input to pass to the activity function.
72+
73+
Returns
74+
-------
75+
Task
76+
A Durable Task that completes when the called activity function completes or fails.
77+
"""
78+
task = self._context.call_activity(name, input_)
6179
self._task_tracker.record_activity_call()
6280
return task
6381

6482
def call_activity_with_retry(
65-
self, activity_name, retry_options: RetryOptions, input: str = None
66-
):
67-
"""Call an activity function with retry options and record the activity call."""
68-
task = self._context.call_activity_with_retry(activity_name, retry_options, input)
83+
self,
84+
name: Union[str, Callable],
85+
retry_options: RetryOptions,
86+
input_: Optional[Any] = None,
87+
) -> TaskBase:
88+
"""Schedule an activity for execution with retry options.
89+
90+
Parameters
91+
----------
92+
name: str | Callable
93+
Either the name of the activity function to call, as a string or,
94+
in the Python V2 programming model, the activity function itself.
95+
retry_options: RetryOptions
96+
The retry options for the activity function.
97+
input_: Optional[Any]
98+
The JSON-serializable input to pass to the activity function.
99+
100+
Returns
101+
-------
102+
Task
103+
A Durable Task that completes when the called activity function completes or
104+
fails completely.
105+
"""
106+
task = self._context.call_activity_with_retry(name, retry_options, input_)
69107
self._task_tracker.record_activity_call()
70108
return task
71109

0 commit comments

Comments
 (0)