Package com.google.genkit.ai
Class AgentHandoffException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.google.genkit.ai.AgentHandoffException
- All Implemented Interfaces:
Serializable
Exception thrown when an agent tool is called to signal a handoff.
When the model calls an agent-as-tool, this exception is thrown to signal that the chat should switch context to the target agent. The Chat class catches this exception and updates its system prompt, tools, and model to those of the target agent.
This enables the "handoff" pattern where conversations can be transferred between specialized agents.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionAgentHandoffException(String targetAgentName, AgentConfig targetAgentConfig, Map<String, Object> handoffInput) Creates a new AgentHandoffException. -
Method Summary
Modifier and TypeMethodDescriptionGets the input passed to the agent tool.Gets the configuration of the target agent.Gets the name of the target agent.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
AgentHandoffException
public AgentHandoffException(String targetAgentName, AgentConfig targetAgentConfig, Map<String, Object> handoffInput) Creates a new AgentHandoffException.- Parameters:
targetAgentName- the name of the agent to hand off totargetAgentConfig- the configuration of the target agenthandoffInput- the input passed to the agent tool (can be used for context)
-
-
Method Details
-
getTargetAgentName
Gets the name of the target agent.- Returns:
- the target agent name
-
getTargetAgentConfig
Gets the configuration of the target agent.- Returns:
- the target agent config
-
getHandoffInput
Gets the input passed to the agent tool.- Returns:
- the handoff input
-