Class AgentInvocationHandler
java.lang.Object
dev.langchain4j.agentic.agent.AgentInvocationHandler
- All Implemented Interfaces:
InternalAgent, AgentInstance, InvocationHandler
-
Constructor Summary
ConstructorsConstructorDescriptionAgentInvocationHandler(AiServiceContext context, Object agent, AgentBuilder<?, ?> builder, boolean agenticScopeDependent) -
Method Summary
Modifier and TypeMethodDescriptionThe condition under which this agent runs when it is invoked as a subagent, ornullwhen it always runs.agentId()voidbooleanasync()booleanThe description of this agent.voidlistener()name()booleanoptional()parent()voidregisterInheritedParentListener(AgentListener parentListener) voidsetAgentId(String agentId) voidsetParent(InternalAgent parent) topology()toString()Class<?> type()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface AgentInstance
as, leafMethods inherited from interface InternalAgent
allowChatMemory, allowStreamingOutput
-
Constructor Details
-
AgentInvocationHandler
public AgentInvocationHandler(AiServiceContext context, Object agent, AgentBuilder<?, ?> builder, boolean agenticScopeDependent)
-
-
Method Details
-
aiService
- Returns:
- the AI service implementing this agent, built by
AiServicesfrom the agent type: an integration that builds its own AI service implementation reaches it here, for instance to manage the chat memories it created
-
invoke
-
toString
-
compensateOnError
public boolean compensateOnError()- Specified by:
compensateOnErrorin interfaceInternalAgent
-
setParent
- Specified by:
setParentin interfaceInternalAgent
-
enableCrossAgentCompensation
public void enableCrossAgentCompensation()- Specified by:
enableCrossAgentCompensationin interfaceInternalAgent
-
registerInheritedParentListener
- Specified by:
registerInheritedParentListenerin interfaceInternalAgent
-
appendId
- Specified by:
appendIdin interfaceInternalAgent
-
setAgentId
- Specified by:
setAgentIdin interfaceInternalAgent
-
listener
- Specified by:
listenerin interfaceInternalAgent
-
type
- Specified by:
typein interfaceAgentInstance
-
plannerType
- Specified by:
plannerTypein interfaceAgentInstance
-
name
- Specified by:
namein interfaceAgentInstance
-
agentId
- Specified by:
agentIdin interfaceAgentInstance
-
description
Description copied from interface:AgentInstanceThe description of this agent. For a remote agent without an explicit description, like an A2A or an MCP one, it is read from the remote server the first time it is requested, so this call can block, and it fails with anAgentUnavailableExceptionwhen the server is unavailable.- Specified by:
descriptionin interfaceAgentInstance
-
outputType
- Specified by:
outputTypein interfaceAgentInstance
-
outputKey
- Specified by:
outputKeyin interfaceAgentInstance
-
async
public boolean async()- Specified by:
asyncin interfaceAgentInstance
-
optional
public boolean optional()- Specified by:
optionalin interfaceAgentInstance
-
activationCondition
Description copied from interface:AgentInstanceThe condition under which this agent runs when it is invoked as a subagent, ornullwhen it always runs. When the condition is false, the agent is skipped: it is not invoked, it writes nothing to theAgenticScopeand its parent's planner is notified of the skip. The condition is ignored when the agent is invoked directly, as the root of an agentic system.The condition can be evaluated more than once for a single invocation, by the planner of the parent while selecting its next agents and again when the agent is invoked, so it must be cheap and free of side effects.
- Specified by:
activationConditionin interfaceAgentInstance
-
arguments
- Specified by:
argumentsin interfaceAgentInstance
-
parent
- Specified by:
parentin interfaceAgentInstance
-
subagents
- Specified by:
subagentsin interfaceAgentInstance
-
topology
- Specified by:
topologyin interfaceAgentInstance
-