Commit a298f63
committed
feat(streaming): cleanup task Redis stream on terminal status transitions
The SDK defines RedisStreamRepository.cleanup_stream(topic) but never
calls it. As a result, every task:* stream that an agent writes to
during its lifetime stays in Redis forever, even after the task
completes. For long-lived clusters this leaks unbounded memory.
This change wires cleanup_stream into all terminal status transitions
on TasksService: cancel, complete, fail, terminate, timeout, and
delete. After the corresponding agentex API call returns successfully,
the task's Redis stream (task:{task_id}) is deleted best-effort -- any
failure is logged and swallowed so cleanup issues never break the
lifecycle call itself.
TasksService now accepts an optional stream_repository in __init__.
The two existing construction sites pass one in:
- get_all_activities() reuses the same RedisStreamRepository already
constructed for StreamingService
- TasksModule's lazy default constructs its own when no service is
provided
Note: this only fires when an application actually calls a terminal
transition method (e.g. adk.tasks.complete). Workflows that exit
without calling these still leak streams; that is a separate concern
for the application layer.1 parent 23bfd6e commit a298f63
3 files changed
Lines changed: 34 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| 46 | + | |
45 | 47 | | |
46 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
47 | 51 | | |
48 | 52 | | |
49 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
16 | 21 | | |
17 | 22 | | |
18 | 23 | | |
19 | 24 | | |
20 | 25 | | |
| 26 | + | |
21 | 27 | | |
22 | 28 | | |
23 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
24 | 45 | | |
25 | 46 | | |
26 | 47 | | |
| |||
75 | 96 | | |
76 | 97 | | |
77 | 98 | | |
| 99 | + | |
| 100 | + | |
78 | 101 | | |
79 | 102 | | |
80 | 103 | | |
| |||
94 | 117 | | |
95 | 118 | | |
96 | 119 | | |
| 120 | + | |
97 | 121 | | |
98 | 122 | | |
99 | 123 | | |
| |||
113 | 137 | | |
114 | 138 | | |
115 | 139 | | |
| 140 | + | |
116 | 141 | | |
117 | 142 | | |
118 | 143 | | |
| |||
132 | 157 | | |
133 | 158 | | |
134 | 159 | | |
| 160 | + | |
135 | 161 | | |
136 | 162 | | |
137 | 163 | | |
| |||
151 | 177 | | |
152 | 178 | | |
153 | 179 | | |
| 180 | + | |
154 | 181 | | |
155 | 182 | | |
156 | 183 | | |
| |||
170 | 197 | | |
171 | 198 | | |
172 | 199 | | |
| 200 | + | |
173 | 201 | | |
174 | 202 | | |
175 | 203 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
| |||
0 commit comments