Class AgentResponseImpl

java.lang.Object
org.cibseven.connect.impl.AbstractConnectorResponse
org.cibseven.connect.ai.agent.impl.AgentResponseImpl
All Implemented Interfaces:
AgentResponse, CloseableConnectorResponse, ConnectorResponse

public class AgentResponseImpl extends AbstractConnectorResponse implements AgentResponse, CloseableConnectorResponse
Default implementation of AgentResponse.

Stores the agent output text returned by the connector execution and exposes it both through the generic parameter map (for BPMN output variable mapping) and through a typed getter method.

  • Constructor Details

    • AgentResponseImpl

      public AgentResponseImpl(String output)
    • AgentResponseImpl

      public AgentResponseImpl(String output, String memoryId)
    • AgentResponseImpl

      public AgentResponseImpl(String output, String memoryId, Map<String,Object> outputAiMeta)
    • AgentResponseImpl

      public AgentResponseImpl(String output, String memoryId, Map<String,Object> outputAiMeta, boolean stepCalledTools)
  • Method Details

    • collectResponseParameters

      protected void collectResponseParameters(Map<String,Object> responseParameters)
      Description copied from class: AbstractConnectorResponse
      To be implemented by subclasses for collecting the generic response parameters of a response.
      Specified by:
      collectResponseParameters in class AbstractConnectorResponse
      Parameters:
      responseParameters - a map to save the response parameters in
    • close

      public void close()
      Once the engine has applied an AI agent service task's output parameters, stores the one that holds the AI-output marker itself Java-serialized, as the agentic ad hoc sub process does (CIB7-2819). Where JSON is the default format, the engine stores it as JSON, and Spin's map type detector names the marker's type after its first value, a Boolean: the variable could not be read back, nor could any read of all of the instance's variables.

      The connect plugin calls this right after it applied the output parameters, before the task is left, also after an output parameter failed; it logs an exception of this method and goes on. The marker is found by identity among the connector's output parameters, whatever their expression; a copy of it, or a map that holds it, stays as the engine stored it, and so does an activity's own output parameter, which the engine applies after this. Nothing happens unless the engine stored the marker as JSON (the default format, or the first one that can store a map where the default format cannot), outside a service task, where the agent's engine plugin did not parse the task, or where the engine cannot store the marker Java-serialized.

      The variable is written twice in one command: one more variable update for listeners and conditional events, and at history level full one more history row. That first row keeps the engine's JSON; under the map type detector it does not read back, while the variable's history does.

      Specified by:
      close in interface CloseableConnectorResponse
    • getOutput

      public String getOutput()
      Description copied from interface: AgentResponse
      Returns the final text response produced by the agent.
      Specified by:
      getOutput in interface AgentResponse
    • getOutputAiMeta

      public Map<String,Object> getOutputAiMeta()
      Description copied from interface: AgentResponse
      Returns the EU AI Act Art. 50(2) marker describing the AI-generated nature of AgentResponse.getOutput(), or null when no marker could be assembled (e.g. the agent returned no successful response).
      Specified by:
      getOutputAiMeta in interface AgentResponse
    • getMemoryId

      public String getMemoryId()
      Description copied from interface: AgentResponse
      Returns the chat memory identifier used during this invocation, or null when chat memory was not activated.
      Specified by:
      getMemoryId in interface AgentResponse