Class ResponsesMultiAgentFormatter

java.lang.Object
io.agentscope.extensions.model.openaiofficial.ResponsesMultiAgentFormatter

public class ResponsesMultiAgentFormatter extends Object
Multi-agent formatter for the OpenAI Responses API.

Converts AgentScope Msg objects to Responses API ResponseInputItem objects with multi-agent support.

The formatter groups messages into:

  • SYSTEM - extracted individually as EasyInputMessage with SYSTEM role
  • TOOL_SEQUENCE - tool calls and results, passed through to ResponsesRequestMapper unchanged (including reasoning replay)
  • AGENT_CONVERSATION - merged into a single EasyInputMessage with USER role, wrapped in <history> tags
  • BYPASS - messages with BYPASS_MULTIAGENT_HISTORY_MERGE metadata, passed through individually as user messages
  • Constructor Details

    • ResponsesMultiAgentFormatter

      public ResponsesMultiAgentFormatter()
      Create a formatter with the default conversation history prompt.
    • ResponsesMultiAgentFormatter

      public ResponsesMultiAgentFormatter(String conversationHistoryPrompt)
      Create a formatter with a custom conversation history prompt.
      Parameters:
      conversationHistoryPrompt - the prompt to prepend before the first history block
  • Method Details

    • formatHistory

      public List<com.openai.models.responses.ResponseInputItem> formatHistory(List<io.agentscope.core.message.Msg> messages)
      Formats AgentScope messages into Responses API input items with multi-agent merging.

      System messages and tool sequences are passed through to ResponsesRequestMapper unchanged. Agent conversation messages are merged into single user messages with <history> tags.

      Parameters:
      messages - the conversation history
      Returns:
      Responses API input items