Skip to main content
OpenAIResponsesToolResponseAdapter is the default ToolResponseAdapter used whenever you pair an agent with the OpenAI Responses adapter. It converts tool outputs into the payloads the OpenAI Responses API expects and exposes a plain-text summary that hosts can display or log.

Behavior summary

  • Plain-text rendering: to_plain_text generates concise strings for each response type (LinkResponse, JsonResponse, TextResponse, FileResponse, EmptyResponse). Hosts decide whether to show or log that text.
  • Chat context updates: create_messages returns OpenAI Responses function_call_output objects so the model receives the tool result on the next turn.
  • Developer logging: Emits events via room.developer.log_nowait to aid debugging when tools are called.

Response handling

Response typePlain text exampleNotes
TextResponseThe returned textInjected as-is into the chat transcript.
JsonResponseJSON string dumpUseful when the LLM expects structured output.
FileResponsefilename.extThe chat message embeds the file bytes as a base64 input_file blob.
LinkResponse{ "name": ..., "url": ... }Links become JSON strings so the user can follow the URL.
EmptyResponse"ok"Signals successful execution without additional data.

Extending or replacing

You can subclass OpenAIResponsesToolResponseAdapter to tweak the plain-text summary or adjust logging, provided the emitted messages continue to match the OpenAI Responses schema. Alternatively, supply your own adapter instance when constructing the agent (for example, ChatBot(..., tool_adapter=...)).

Where it is used

  • Automatically when you construct OpenAIResponsesAdapter without specifying a custom tool_adapter.
  • In the CLI chatbot and MeshAgent Studio when interacting with OpenAI models.
  • Any agent that wants to reuse the same formatting logic can import and instantiate it directly.