Record Class PlanningContext
- Record Components:
agenticScope- the scope of the agentic system running the plannerpreviousAgentInvocation- the invocation of the subagent that just completed, ornullfor the first actionplannerAgent- the agent running the planner, ornullwhen the context is not created by an agentic system, for instance in a unit test of the planner. The model responses reported to a context are notified only when this is an agent created by the agentic system.
Planner decides its next action.-
Constructor Summary
ConstructorsConstructorDescriptionPlanningContext(AgenticScope agenticScope, @Nullable AgentInvocation previousAgentInvocation) PlanningContext(AgenticScope agenticScope, @Nullable AgentInvocation previousAgentInvocation, @Nullable AgentInstance plannerAgent) Creates an instance of aPlanningContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theagenticScoperecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanisActive(AgentInstance agent) Tells whether the given subagent would run if it were invoked now, according to itsactivation condition.@Nullable AgentInstanceReturns the value of theplannerAgentrecord component.@Nullable AgentInvocationReturns the value of thepreviousAgentInvocationrecord component.voidreportChatModelResponse(@Nullable ChatResponse chatResponse) Reports the response of a chat model that the planner called itself to decide what to do.voidreportDecisionModelResponse(@Nullable DecisionResponse decisionResponse) Reports the response of a decision model that the planner called itself to decide what to do, likereportChatModelResponse(ChatResponse)does for a chat model.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
PlanningContext
public PlanningContext(AgenticScope agenticScope, @Nullable AgentInvocation previousAgentInvocation) -
PlanningContext
public PlanningContext(AgenticScope agenticScope, @Nullable AgentInvocation previousAgentInvocation, @Nullable AgentInstance plannerAgent) Creates an instance of aPlanningContextrecord class.- Parameters:
agenticScope- the value for theagenticScoperecord componentpreviousAgentInvocation- the value for thepreviousAgentInvocationrecord componentplannerAgent- the value for theplannerAgentrecord component
-
-
Method Details
-
isActive
Tells whether the given subagent would run if it were invoked now, according to itsactivation condition. A planner never needs this for correctness, because an inactive agent is skipped when invoked anyway, but a planner selecting its candidates from the state of theAgenticScopecan use it to avoid selecting inactive agents.The condition is evaluated each time this method is called and once more when the agent is invoked, so the agent can still be skipped if the state changed in between: the planner must handle a
skippedinvocation anyway. A condition throwing an exception is considered to hold here, so that the failure is raised, and handled by the error handler, when the agent is invoked.- Parameters:
agent- a subagent of the planner- Returns:
trueif the agent has no activation condition, was already activated, or its condition holds
-
reportChatModelResponse
Reports the response of a chat model that the planner called itself to decide what to do. Its token usage and its model name are notified to thelistenersof the agent running the planner, so that the token usage is counted on the invocation of that agent, for instance by theAgentMonitor: a model call that is not reported is invisible to them. Call it as soon as the model returns, once for each call.A planner calling its model through an AI service calls this method from an
AiServiceResponseReceivedListenerregistered on that service, which receives each response of the model before the AI service parses it: so a response that cannot be parsed is reported too.It does nothing when this context has no
planner agentcreated by the agentic system, or when the response isnull.- Parameters:
chatResponse- the response returned by the chat model, ornull, which is ignored
-
reportDecisionModelResponse
Reports the response of a decision model that the planner called itself to decide what to do, likereportChatModelResponse(ChatResponse)does for a chat model.- Parameters:
decisionResponse- the response returned by the decision model, ornull, which is ignored
-
toString
-
hashCode
-
equals
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 withObjects::equals(Object,Object). -
agenticScope
Returns the value of theagenticScoperecord component.- Returns:
- the value of the
agenticScoperecord component
-
previousAgentInvocation
Returns the value of thepreviousAgentInvocationrecord component.- Returns:
- the value of the
previousAgentInvocationrecord component
-
plannerAgent
Returns the value of theplannerAgentrecord component.- Returns:
- the value of the
plannerAgentrecord component
-