Commit 7137d8c
committed
feat: support dot-separated nested state values in instruction templates
Adds support for referencing nested dictionary values in instruction
templates using dot notation, e.g. {user.profile.name} resolves to
session.state['user']['profile']['name'].
This is useful when agents receive structured LLM responses via
output_schema and need to reference nested fields in instructions
without manually flattening state.
- Add _resolve_nested() helper for dot-separated path traversal
- Update _replace_match() to use nested resolution when path contains dots
- Update _is_valid_state_name() to accept dot-separated identifiers
- Preserve backward compatibility: flat keys, artifact. prefix, and
app:/user:/temp: namespaces all work unchanged
Fixes #5751 parent 9199189 commit 7137d8c
File tree
2 files changed
+121
-7
lines changed- src/google/adk/utils
- tests/unittests/utils
2 files changed
+121
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
29 | 52 | | |
30 | 53 | | |
31 | 54 | | |
| |||
36 | 59 | | |
37 | 60 | | |
38 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
39 | 69 | | |
40 | 70 | | |
41 | 71 | | |
| |||
45 | 75 | | |
46 | 76 | | |
47 | 77 | | |
48 | | - | |
| 78 | + | |
| 79 | + | |
49 | 80 | | |
50 | 81 | | |
51 | 82 | | |
| |||
106 | 137 | | |
107 | 138 | | |
108 | 139 | | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
114 | 147 | | |
| 148 | + | |
| 149 | + | |
115 | 150 | | |
116 | 151 | | |
117 | 152 | | |
| |||
120 | 155 | | |
121 | 156 | | |
122 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
123 | 161 | | |
124 | 162 | | |
125 | 163 | | |
| |||
129 | 167 | | |
130 | 168 | | |
131 | 169 | | |
| 170 | + | |
132 | 171 | | |
133 | 172 | | |
134 | 173 | | |
| |||
140 | 179 | | |
141 | 180 | | |
142 | 181 | | |
143 | | - | |
| 182 | + | |
| 183 | + | |
144 | 184 | | |
145 | 185 | | |
146 | 186 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
0 commit comments