Commit 59c1164
authored
Add dynamic node/task summaries to LangGraph plugin (#1612)
* Add dynamic node/task summaries to LangGraph plugin
Adds a per-node/per-task summary_fn(args, kwargs) -> str | None (and a
plugin-wide default_summary_fn) that computes a Temporal summary at
runtime from the node's input.
- execute_in="activity" nodes: the result sets the activity summary
(user_metadata, shown on each scheduled-activity event).
- execute_in="workflow" nodes: the result updates the workflow's current
details via workflow.set_current_details (last-writer-wins).
A static summary activity option already flowed through to
execute_activity; this is now documented. Setting both a static summary
and summary_fn on the same node raises ValueError. summary_fn runs in
workflow context (must be deterministic and must not raise) and is
replay-safe, since summaries ride in user_metadata.
* Comment why summary_fn is popped from node opts
* Scope summary_fn per-node and normalize static summary
- Drop the plugin-level default_summary_fn; summary_fn is now set only
per node (Graph metadata) / per task (activity_options), matching the
ADK plugin's per-model scoping so each node manages its own summary.
- Normalize a static summary into a summary_fn (a constant function), so
static and dynamic summaries share one resolution path feeding the
activity summary kwarg / set_current_details.
- Workflow-bound nodes now clear current details when summary_fn returns
empty, so a node no longer shows a stale summary from an earlier node.
* Layer node summary settings over defaults instead of conflicting
summary and summary_fn are two forms of one setting, but as separate
dict keys a default of one form and a node-level value of the other
survived the merge together and tripped the exclusivity guard (e.g.
default_activity_options={"summary_fn": fn} + one node with a static
summary raised ValueError). Merge now drops the inherited form when a
node/task supplies either, so the more-specific setting wins, and the
exclusivity check only rejects both forms set at the same level
(per-node, or in default_activity_options via a new init check).1 parent d824821 commit 59c1164
5 files changed
Lines changed: 490 additions & 13 deletions
File tree
- temporalio/contrib/langgraph
- tests/contrib/langgraph
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
146 | 186 | | |
147 | 187 | | |
148 | 188 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| 112 | + | |
112 | 113 | | |
113 | 114 | | |
114 | 115 | | |
| |||
156 | 157 | | |
157 | 158 | | |
158 | 159 | | |
159 | | - | |
160 | | - | |
161 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
162 | 169 | | |
163 | 170 | | |
164 | 171 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 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 | + | |
| 66 | + | |
| 67 | + | |
38 | 68 | | |
39 | 69 | | |
40 | 70 | | |
| |||
69 | 99 | | |
70 | 100 | | |
71 | 101 | | |
72 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
73 | 105 | | |
74 | 106 | | |
75 | 107 | | |
| |||
130 | 162 | | |
131 | 163 | | |
132 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
133 | 175 | | |
134 | 176 | | |
135 | 177 | | |
| |||
168 | 210 | | |
169 | 211 | | |
170 | 212 | | |
171 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
172 | 216 | | |
173 | 217 | | |
174 | 218 | | |
175 | 219 | | |
176 | | - | |
| 220 | + | |
177 | 221 | | |
178 | 222 | | |
179 | 223 | | |
180 | 224 | | |
181 | 225 | | |
182 | 226 | | |
183 | 227 | | |
184 | | - | |
| 228 | + | |
185 | 229 | | |
186 | 230 | | |
187 | 231 | | |
| |||
208 | 252 | | |
209 | 253 | | |
210 | 254 | | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
| 255 | + | |
215 | 256 | | |
216 | 257 | | |
217 | 258 | | |
| |||
253 | 294 | | |
254 | 295 | | |
255 | 296 | | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
256 | 309 | | |
257 | 310 | | |
258 | 311 | | |
| |||
262 | 315 | | |
263 | 316 | | |
264 | 317 | | |
265 | | - | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
266 | 321 | | |
267 | | - | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
268 | 325 | | |
269 | 326 | | |
270 | 327 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
31 | 37 | | |
32 | 38 | | |
33 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
34 | 45 | | |
35 | 46 | | |
36 | 47 | | |
| |||
0 commit comments