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_textgenerates concise strings for common response types (LinkResponse,JsonResponse,TextResponse,FileResponse,EmptyResponse). Hosts decide whether to show or log that text. - Chat context updates:
create_messagesreturns OpenAI Responsesfunction_call_outputobjects so the model receives the tool result on the next turn. - Developer logging: Emits events via
room.developer.log_nowaitto aid debugging when tools are called.
Response handling
| Response type | Plain text example | Notes |
|---|---|---|
TextResponse | The returned text | Injected as-is into the chat transcript. |
JsonResponse | JSON string dump | Useful when the LLM expects structured output. |
FileResponse | filename.ext | Images become input_image payloads; PDFs use input_file; text/JSON are inlined; other formats return a “not supported” message. |
LinkResponse | { "name": ..., "url": ... } | Links become JSON strings so the user can follow the URL. |
EmptyResponse | "ok" | Signals successful execution without additional data. |
RawOutputs | n/a | Passed through directly as OpenAI Responses outputs, bypassing plain-text conversion. |
Extending or replacing
You can subclassOpenAIResponsesToolResponseAdapter 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
OpenAIResponsesAdapterwithout specifying a customtool_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.
Related references
- Adapters Overview: Understand LLMAdapters and ToolResponseAdapters
- OpenAI Responses Adapter: Understand the LLM integration that uses this adapter.