Commit d5f156c
committed
fix(ambient): accept stringified u32 in Claude tool params
Claude tool calls occasionally serialize numeric arguments as strings
(e.g. {"compactions": "0"}) instead of JSON numbers. Strict u32
deserialization rejected those calls with:
invalid type: string "0", expected u32
which made every ambient cycle (end_ambient_cycle, schedule_ambient,
schedule_tool, next_schedule.wake_in_minutes) fail at the JSON layer
before it ever reached business logic.
Add two custom serde visitor helpers in src/tool/ambient.rs:
- deserialize_string_or_u32 — for required u32 fields
- deserialize_string_or_option_u32 — for Option<u32> fields
Both visitors accept a JSON number OR a numeric string and forward to
the appropriate parser. Non-numeric strings still fail loudly.
Apply via #[serde(deserialize_with = ...)] to:
- EndCycleInput::memories_modified
- EndCycleInput::compactions
- NextScheduleInput::wake_in_minutes
- ScheduleInput::wake_in_minutes
- ScheduleToolInput::wake_in_minutes
Add 5 regression tests in src/tool/ambient/tests.rs covering both the
new stringified form and the existing native-number form, plus a
defensive test that rejects non-numeric strings.
Ports the src/tool/ambient.rs portion of upstream PR
1jehuang#173 by @zanni098. The
docs/WINDOWS_SETUP.md hunk that upstream PR also carries belongs to a
different feature (upstream PR #172 / our issue #132) and is skipped
here.
Closes #1331 parent e1886bb commit d5f156c
2 files changed
Lines changed: 168 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 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 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
122 | 208 | | |
123 | 209 | | |
124 | 210 | | |
| 211 | + | |
125 | 212 | | |
| 213 | + | |
126 | 214 | | |
127 | 215 | | |
128 | 216 | | |
| |||
132 | 220 | | |
133 | 221 | | |
134 | 222 | | |
135 | | - | |
| 223 | + | |
136 | 224 | | |
137 | 225 | | |
138 | 226 | | |
| |||
280 | 368 | | |
281 | 369 | | |
282 | 370 | | |
283 | | - | |
| 371 | + | |
284 | 372 | | |
285 | 373 | | |
286 | 374 | | |
| |||
722 | 810 | | |
723 | 811 | | |
724 | 812 | | |
725 | | - | |
| 813 | + | |
726 | 814 | | |
727 | 815 | | |
728 | 816 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
445 | 445 | | |
446 | 446 | | |
447 | 447 | | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
0 commit comments