Class PlannerModelResponse

java.lang.Object
dev.langchain4j.agentic.observability.PlannerModelResponse

public final class PlannerModelResponse extends Object
The response of a model called by the planner of an agent, like the one a supervisor asks which subagent to invoke next or the decision model of a decision router, with its token usage and its model name, reported to AgentListener.onPlannerModelResponse(PlannerModelResponse) when the planner receives that response. These are the model calls that the planner makes itself and reports through reportChatModelResponse or reportDecisionModelResponse, and not the ones of its subagents, which are reported by their own invocations.

A response reported by a planner is either a chat response or a decision response, the other one being null, while the token usage and the model name are available for both.

  • Constructor Details

    • PlannerModelResponse

      public PlannerModelResponse(AgenticScope agenticScope, AgentInstance agent, @Nullable TokenUsage tokenUsage, @Nullable String modelName)
      Creates a notification with the token usage and the model name only, without the response of the model.
      Parameters:
      agenticScope - the scope of the agentic system running the planner
      agent - the agent whose planner called the model
      tokenUsage - the token usage of this model call, or null if the provider didn't report it
      modelName - the name of the model that answered this call, or null if the provider didn't report it
    • PlannerModelResponse

      public PlannerModelResponse(AgenticScope agenticScope, AgentInstance agent, ChatResponse chatResponse)
      Creates the notification of the response of a chat model, with the token usage and the model name of that response.
      Parameters:
      agenticScope - the scope of the agentic system running the planner
      agent - the agent whose planner called the model
      chatResponse - the response of the chat model called by the planner
    • PlannerModelResponse

      public PlannerModelResponse(AgenticScope agenticScope, AgentInstance agent, DecisionResponse decisionResponse)
      Creates the notification of the response of a decision model, with the token usage and the model name of that response.
      Parameters:
      agenticScope - the scope of the agentic system running the planner
      agent - the agent whose planner called the model
      decisionResponse - the response of the decision model called by the planner, with its answers and their probabilities
  • Method Details

    • agenticScope

      public AgenticScope agenticScope()
    • agent

      public AgentInstance agent()
    • tokenUsage

      public @Nullable TokenUsage tokenUsage()
      Returns the token usage of this model call, or null if the provider didn't report it.
    • modelName

      public @Nullable String modelName()
      Returns the name of the model that answered this call, or null if the provider didn't report it.
    • chatResponse

      public @Nullable ChatResponse chatResponse()
      Returns the response of the chat model called by the planner, or null if it called a decision model or if this notification was created without the response.
    • decisionResponse

      public @Nullable DecisionResponse decisionResponse()
      Returns the response of the decision model called by the planner, with its answers and their probabilities, or null if it called a chat model or if this notification was created without the response.
    • agentName

      public String agentName()
    • agentId

      public String agentId()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object