Reshape the helper module so AsyncToolMessagePayload is the canonical in-memory form and the on-the-wire JSON is always derived from it (never stored). This eliminates a drift risk that came with caching the JSON in raw_content, and it lets prepare_message_payload_for_realtime edit the payload (graft the re-invocation reminder into 'description') and then serialize cleanly — which fixes a 'Tool Response parsing error' from AWS Nova Sonic that was caused by wrapping the JSON with extra prose. Other changes: - Builders construct an AsyncToolMessagePayload internally and convert via shared private _payload_to_message and _payload_to_json helpers (centralizing field-omission rules, e.g. no 'result' on 'started'). - prepare_message_payload_for_realtime replaces format_text_for_provider, dispatching to per-kind helpers. Reminder is now appended after the canonical description so the model reads the protocol explanation first and the directive flows from it. - Final-result payloads are pass-through; the task is done at that point and re-invocation is no longer a mistake. - Stream-tool example: lengthen intermediate sleeps 10s → 20s for more interesting empirical testing.
12 KiB
12 KiB