1
- from typing import Any , Callable
1
+ from typing import Any , Callable , Optional
2
2
3
3
from agents import (
4
4
Agent ,
17
17
from durable_ai_agent_context import DurableAIAgentContext
18
18
19
19
20
- def activity_as_tool (context : DurableAIAgentContext , activity_func : Callable ) -> Tool :
20
+ def activity_as_tool (
21
+ context : DurableAIAgentContext ,
22
+ activity_func : Callable ,
23
+ * ,
24
+ description : Optional [str ] = None ,
25
+ ) -> Tool :
21
26
"""
22
27
Convert an Azure Durable Functions activity to an OpenAI Agents SDK Tool.
23
-
28
+
24
29
Args:
25
30
activity_func: The Azure Functions activity function to convert
26
-
31
+
27
32
Returns:
28
33
Tool: An OpenAI Agents SDK Tool object
29
34
"""
@@ -38,14 +43,14 @@ async def run_activity(ctx: RunContextWrapper[Any], input: str) -> Any:
38
43
func = activity_func ._function ._func ,
39
44
name_override = activity_name ,
40
45
docstring_style = None ,
41
- description_override = None ,
42
- use_docstring_info = False ,
46
+ description_override = description ,
47
+ use_docstring_info = True ,
43
48
strict_json_schema = False ,
44
49
)
45
50
46
51
return FunctionTool (
47
- name = activity_name ,
48
- description = "" ,
52
+ name = schema . name ,
53
+ description = schema . description or "" ,
49
54
params_json_schema = schema .params_json_schema ,
50
55
on_invoke_tool = run_activity ,
51
56
strict_json_schema = False ,
0 commit comments