Skip to content

Commit de870d1

Browse files
committed
Small tool fix
1 parent 7c4204f commit de870d1

File tree

1 file changed

+4
-9
lines changed
  • examples/tutorials/10_async/10_temporal/070_open_ai_agents_sdk_tools/project

1 file changed

+4
-9
lines changed

examples/tutorials/10_async/10_temporal/070_open_ai_agents_sdk_tools/project/tools.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,20 @@ async def move_money(from_account: str, to_account: str, amount: float) -> str:
2929

3030
# STEP 1: Start the withdrawal activity
3131
# This creates a Temporal activity that will be retried if it fails
32-
withdraw_handle = workflow.start_activity_method(
32+
withdraw_result = await workflow.execute_activity(
3333
withdraw_money,
34+
args=[from_account, amount],
3435
start_to_close_timeout=timedelta(days=1) # Long timeout for banking operations
3536
)
3637

37-
# Wait for withdrawal to complete before proceeding
38-
# If this fails, the entire tool call fails and can be retried
39-
await withdraw_handle.result()
40-
4138
# STEP 2: Only after successful withdrawal, start the deposit activity
4239
# This guarantees the sequence: withdraw THEN deposit
43-
deposit_handle = workflow.start_activity_method(
40+
deposit_result = await workflow.execute_activity(
4441
deposit_money,
42+
args=[to_account, amount],
4543
start_to_close_timeout=timedelta(days=1)
4644
)
4745

48-
# Wait for deposit to complete
49-
await deposit_handle.result()
50-
5146
# PATTERN 2 BENEFIT: From the agent's perspective, this was ONE tool call
5247
# But in Temporal UI, you'll see TWO activities executed in sequence
5348
# Each activity gets its own retry logic and durability guarantees

0 commit comments

Comments
 (0)