SIGN IN SIGN UP

fix(ambient): accept string-encoded numbers/bools in tool inputs (#106)

Claude's tool calling emits numeric and boolean tool arguments as JSON
strings (e.g. {"compactions": "0"} instead of {"compactions": 0}), even
when the tool schema declares integer/boolean types. serde_json is strict and
rejected these with 'invalid type: string "0", expected u32', failing the
end_ambient_cycle call and forcing every ambient cycle to end as 'forced end
after 2 attempts'. No ambient cycle could ever complete.

Add a reusable tool::serde_coerce module with string-or-number / string-or-bool
deserializers and apply it to the affected ambient tool-input fields:
EndCycleInput.{memories_modified,compactions}, NextScheduleInput/ScheduleInput/
ScheduleToolInput.wake_in_minutes, and RequestPermissionInput.wait.

The helper respects each field's declared schema type (it is only applied to
numeric/boolean fields), so legitimate string values for string-typed fields
are unaffected. Other tools across the codebase that hit the same provider
quirk can now opt in with #[serde(deserialize_with = ...)].

Adds regression tests covering the exact #106 payload (string "0"), the other
ambient inputs, and the helper's coercion/rejection behavior.
J
jeremy committed
260a2ac24df89d8db46b295c352401614d2f138c
Parent: 2f8af3f