Class DefaultA2AClientBuilder<T>
java.lang.Object
dev.langchain4j.agentic.a2a.DefaultA2AClientBuilder<T>
- All Implemented Interfaces:
A2AClientBuilder<T>, InternalAgent, AgentInstance, InvocationHandler
public class DefaultA2AClientBuilder<T>
extends Object
implements A2AClientBuilder<T>, InternalAgent, InvocationHandler
-
Method Summary
Modifier and TypeMethodDescriptionThe condition under which this agent runs when it is invoked as a subagent, ornullwhen it always runs.activationCondition(String description, Predicate<AgenticScope> activationCondition) Sets the condition under which the agent runs when it is invoked as a subagent of an agentic system.agentId()voidbooleanasync()async(boolean async) Sets whether the agent should be invoked asynchronously, allowing the workflow to continue without waiting for the agent's result.build()Builds the A2A client proxy implementing the agent service interface.clientCustomizer(Consumer<?> clientCustomizer) Sets a customizer that will be applied to the underlying a2a-java SDKClientBuilderbefore theClientis constructed.Sets the state keys whose values will be sent as message parts to the remote agent.listener()listener(AgentListener agentListener) Sets anAgentListenerfor observing agent invocations.name()Sets the state key under which the agent's response will be stored.parent()voidregisterInheritedParentListener(AgentListener parentListener) voidsetParent(InternalAgent parent) streamingClientListener(A2AStreamingClientListener<?> clientListener) Sets anA2AStreamingClientListenerfor observing updates received from the remote agent during streaming invocation.Sets the tenant identifier that will be sent with every A2A message.topology()Class<?> type()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface A2AClientBuilder
activationConditionMethods inherited from interface AgentInstance
as, leaf, optionalMethods inherited from interface InternalAgent
allowChatMemory, allowStreamingOutput, compensateOnError, enableCrossAgentCompensation, setAgentId
-
Method Details
-
build
Description copied from interface:A2AClientBuilderBuilds the A2A client proxy implementing the agent service interface.- Specified by:
buildin interfaceA2AClientBuilder<T>- Returns:
- the proxy instance
-
invoke
-
inputKeys
Description copied from interface:A2AClientBuilderSets the state keys whose values will be sent as message parts to the remote agent.- Specified by:
inputKeysin interfaceA2AClientBuilder<T>- Parameters:
inputKeys- the names of the input keys- Returns:
- this builder for method chaining
-
outputKey
Description copied from interface:A2AClientBuilderSets the state key under which the agent's response will be stored.- Specified by:
outputKeyin interfaceA2AClientBuilder<T>- Parameters:
outputKey- the name of the output key- Returns:
- this builder for method chaining
-
async
Description copied from interface:A2AClientBuilderSets whether the agent should be invoked asynchronously, allowing the workflow to continue without waiting for the agent's result.- Specified by:
asyncin interfaceA2AClientBuilder<T>- Parameters:
async-truefor asynchronous invocation- Returns:
- this builder for method chaining
-
listener
Description copied from interface:A2AClientBuilderSets anAgentListenerfor observing agent invocations.- Specified by:
listenerin interfaceA2AClientBuilder<T>- Parameters:
agentListener- the listener to attach- Returns:
- this builder for method chaining
-
activationCondition
public DefaultA2AClientBuilder<T> activationCondition(String description, Predicate<AgenticScope> activationCondition) Description copied from interface:A2AClientBuilderSets the condition under which the agent runs when it is invoked as a subagent of an agentic system. When the condition is false the remote agent is not called and the agent is skipped. It can be evaluated more than once, so it must be free of side effects.- Specified by:
activationConditionin interfaceA2AClientBuilder<T>- Parameters:
description- a human-readable description of the condition, used in logs, listeners and reportsactivationCondition- the predicate deciding whether the agent runs- Returns:
- this builder for method chaining
-
clientCustomizer
Description copied from interface:A2AClientBuilderSets a customizer that will be applied to the underlying a2a-java SDKClientBuilderbefore theClientis constructed.The wildcard type avoids a compile-time dependency on the a2a-java SDK in this module. At runtime the value must be a
Consumer<org.a2aproject.sdk.client.ClientBuilder>.- Specified by:
clientCustomizerin interfaceA2AClientBuilder<T>- Parameters:
clientCustomizer- aConsumer<ClientBuilder>from the a2a-java SDK- Returns:
- this builder for method chaining
-
streamingClientListener
Description copied from interface:A2AClientBuilderSets anA2AStreamingClientListenerfor observing updates received from the remote agent during streaming invocation.Like
DefaultA2AClientBuilder, which usesa2a-java, can be used with the following example:streamingClientListener((TaskUpdateEvent event) -> { // handle the streaming event });The listener is invoked with task update events received from the remote agent.
- Specified by:
streamingClientListenerin interfaceA2AClientBuilder<T>- Parameters:
clientListener- the listener to attach- Returns:
- this builder for method chaining
-
setParent
- Specified by:
setParentin interfaceInternalAgent
-
registerInheritedParentListener
- Specified by:
registerInheritedParentListenerin interfaceInternalAgent
-
appendId
- Specified by:
appendIdin 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
- Specified by:
descriptionin interfaceAgentInstance
-
outputType
- Specified by:
outputTypein interfaceAgentInstance
-
outputKey
- Specified by:
outputKeyin interfaceAgentInstance
-
async
public boolean async()- Specified by:
asyncin 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
-
tenant
Description copied from interface:A2AClientBuilderSets the tenant identifier that will be sent with every A2A message.- Specified by:
tenantin interfaceA2AClientBuilder<T>- Parameters:
tenant- the tenant identifier- Returns:
- this builder for method chaining
-