What every chat client needs to map ContentParts: a client describes the parts it sends as a partial function from part to its wire form, and a part it does not cover fails the request with an UnsupportedContentPartError - never dropped, never sent as text.
A provider module uses check to refuse a conversation before anything is sent and encodeAll to encode a message's parts.
Right when user covers every part of every user message in messages, and tool every part of every tool message; else the error for the first part one does not. For a client that builds its request in steps that cannot fail, so it checks the conversation first. It asks only isDefinedAt: nothing is encoded, so inline media is not base64-encoded twice per request.
Right when user covers every part of every user message in messages, and tool every part of every tool message; else the error for the first part one does not. For a client that builds its request in steps that cannot fail, so it checks the conversation first. It asks only isDefinedAt: nothing is encoded, so inline media is not base64-encoded twice per request.