Skip to content

Function: sanitizeOpenResponsesInput()

sanitizeOpenResponsesInput(body): Record<string, unknown>

Rewrite Responses input so Open Responses will accept it.

Two OpenAI / Codex shapes that Databricks Open Responses (Claude, Gemini, …) reject:

  1. Prior assistant turns with output_text / output_* content parts — Open Responses only allows input_text, input_image, input_file, input_audio. Map every output_<kind> part to input_<kind>.
  2. Replayed extended-thinking blocks (thinking, redacted_thinking, reasoning content parts, and top-level reasoning input items). Claude signs those; any client round-trip that mutates them (or a cross-provider replay) fails with e.g. “messages.N.content.M: Invalid data in redacted_thinking block” Strip them — the UI/client already showed the thinking; replay does not need the signed blob. Same policy as appkit-mastra’s serving sanitize.

Returns a shallow copy when anything changes; otherwise the input body.

Record<string, unknown>

Record<string, unknown>