Record Class CurrentPlanningContext

java.lang.Object
java.lang.Record
dev.langchain4j.agentic.internal.CurrentPlanningContext
All Implemented Interfaces:
LangChain4jManaged

public record CurrentPlanningContext(PlanningContext planningContext) extends Record implements LangChain4jManaged
The PlanningContext of the planner calling a model on the current thread. A planner puts it in the LangChain4jManaged parameters around a model call that it cannot report itself, because the call is made by a component with no access to the planning context: an AI service shared by all the invocations on the same scope, which reports through its listener, or the summarizer of the supervisor context, which runs inside the request transformer of that AI service.
  • Constructor Details

    • CurrentPlanningContext

      public CurrentPlanningContext(PlanningContext planningContext)
      Creates an instance of a CurrentPlanningContext record class.
      Parameters:
      planningContext - the value for the planningContext record component
  • Method Details

    • reportChatModelResponse

      public static void reportChatModelResponse(ChatResponse chatResponse)
      Reports the response of a model to the planning context of the current thread, if there is one.
    • modelResponseListener

      public static AiServiceResponseReceivedListener modelResponseListener()
      Returns the listener that a planner registers on an AI service that it calls with its planning context in the managed parameters. It reports each response that the AI service receives from its model to the planning context found in the invocation context of the event, if there is one, as soon as the response is received: so also a response that the AI service then fails to parse.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • planningContext

      public PlanningContext planningContext()
      Returns the value of the planningContext record component.
      Returns:
      the value of the planningContext record component