Today Think & AiChatAgent allows to sanitize persisted messages via sanitizeMessageForPersistence(), but doesn't expose a hook to sanitize what is exposed to the client. For example, I might want to hide from the frontend a tool output. I know this does not 100% guarantee and the user might just ask like "what was that tool output", but for that we can add more system prompts and other anti-jailbreaks.
Something like:
protected sanitizeMessageForClient(message: UIMessage): UIMessage
// and
protected sanitizeChatResponseChunkForClient(
chunk: UIMessageChunk
): UIMessageChunk | null
or just a
protected sanitizeOutgoingChatFrame(
frame: OutgoingMessage
): OutgoingMessage | null
Ideally they should cover CF_AGENT_USE_CHAT_RESPONSE, CF_AGENT_CHAT_MESSAGES, /get-messages...
A more declarative option like:
clientTranscriptPolicy = {
stripToolOutputs: true,
stripToolInputs: true,
stripProviderMetadata: true,
}
would also be welcomed :)
Today Think & AiChatAgent allows to sanitize persisted messages via
sanitizeMessageForPersistence(), but doesn't expose a hook to sanitize what is exposed to the client. For example, I might want to hide from the frontend a tool output. I know this does not 100% guarantee and the user might just ask like "what was that tool output", but for that we can add more system prompts and other anti-jailbreaks.Something like:
or just a
Ideally they should cover
CF_AGENT_USE_CHAT_RESPONSE,CF_AGENT_CHAT_MESSAGES,/get-messages...A more declarative option like:
would also be welcomed :)