Handoff

org.llm4s.agent.Handoff
See theHandoff companion object
case class Handoff(targetAgent: Agent, transferReason: Option[String], preserveContext: Boolean, transferSystemMessage: Boolean)

Represents a handoff to another agent.

Handoffs provide a simpler alternative to DAG-based orchestration for common delegation patterns. The LLM decides when to invoke a handoff by calling a generated handoff tool.

Example:

val generalAgent = new Agent(client)
val specialistAgent = new Agent(client)

generalAgent.run(
 "Explain quantum entanglement",
 tools,
 handoffs = Seq(
   Handoff(
     targetAgent = specialistAgent,
     transferReason = Some("Requires physics expertise"),
     preserveContext = true
   )
 )
)

Value parameters

preserveContext

Whether to transfer conversation history (default: true)

targetAgent

The agent to hand off to

transferReason

Optional reason for the handoff (shown to LLM in tool description)

transferSystemMessage

Whether to transfer system message (default: false)

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def handoffId: String

Generate a unique identifier for this handoff. Used for tool naming and logging.

Generate a unique identifier for this handoff. Used for tool naming and logging.

Attributes

def handoffName: String

Generate a human-readable name for this handoff.

Generate a human-readable name for this handoff.

Attributes

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product