Skip to content

Commit 9ca14a7

Browse files
committed
Invoke the tool activity
1 parent 6b5c371 commit 9ca14a7

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

samples-v2/openai_agents/function_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def weather_expert(context):
124124
name="Hello world",
125125
instructions="You are a helpful agent.",
126126
tools=[
127-
activity_as_tool(get_weather)
127+
activity_as_tool(context, get_weather)
128128
],
129129
)
130130

samples-v2/openai_agents/tools.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
default_tool_error_function,
1515
function_tool,
1616
)
17+
from durable_ai_agent_context import DurableAIAgentContext
1718

1819

19-
def activity_as_tool(activity_func: Callable) -> Tool:
20+
def activity_as_tool(context: DurableAIAgentContext, activity_func: Callable) -> Tool:
2021
"""
2122
Convert an Azure Durable Functions activity to an OpenAI Agents SDK Tool.
2223
@@ -27,11 +28,12 @@ def activity_as_tool(activity_func: Callable) -> Tool:
2728
Tool: An OpenAI Agents SDK Tool object
2829
"""
2930

30-
async def run_activity(ctx: RunContextWrapper[Any], input: str) -> Any:
31-
return "Weather in Tokyo: 14-20C, sunny with wind."
32-
3331
activity_name = activity_func._function._name
3432

33+
def run_activity(ctx: RunContextWrapper[Any], input: str) -> Any:
34+
result = context.get_activity_call_result(activity_name, input)
35+
return result
36+
3537
schema = function_schema(
3638
func=run_activity,
3739
name_override=activity_name,

0 commit comments

Comments
 (0)