Repository navigation
Commit 9ddbdd4
committed
fix(temporal): send activity heartbeats from inside activities
heartbeat_if_in_workflow() only called activity.heartbeat() when
workflow.in_workflow() was true. activity.heartbeat() is only legal
inside an activity, where workflow.in_workflow() is false, so the guard
never passed where it mattered. Every ADK service that calls it (tasks,
messages, streaming, the LiteLLM/OpenAI/SGP providers, ACP, tracing,
templating) runs inside an activity and never heartbeated.
The shipped defaults hide this because each provider sets
heartbeat_timeout equal to start_to_close_timeout. An agent that sets a
shorter heartbeat_timeout for a long activity, the usual Temporal
pattern, gets ActivityTaskTimedOut (HEARTBEAT) on every attempt, and
activity cancellation is never delivered through the heartbeat channel.
Add heartbeat_if_in_activity(), which heartbeats when
activity.in_activity() is true and is a no-op everywhere else, and keep
heartbeat_if_in_workflow() as an alias so the existing call sites work
unchanged.
Verified with temporalio.testing.ActivityEnvironment: inside an activity
the old helper records no heartbeat, the new one (and the alias) records
one. tests/lib/test_temporal_utils.py, tests/lib/core/services and
tests/lib/core/temporal: 74 passed.1 parent 6d68f3a commit 9ddbdd4
2 files changed
Lines changed: 62 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
17 | 23 | | |
18 | 24 | | |
19 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
20 | 35 | | |
21 | 36 | | |
22 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
8 | 12 | | |
9 | 13 | | |
10 | 14 | | |
| 15 | + | |
| 16 | + | |
11 | 17 | | |
12 | 18 | | |
13 | 19 | | |
| |||
18 | 24 | | |
19 | 25 | | |
20 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
21 | 66 | | |
22 | 67 | | |
23 | 68 | | |
| |||
0 commit comments