module LittleGhost::Agent::Delegation

Give one agent a bounded way to ask another agent for help. Delegated agents can run as managed subagents or behind an ordinary tool call.

class CustomerSupportAgent < LittleGhost::Agent
  subagent ResearchAgent, kind: "research"
  agent_as_tool SentimentAgent, name: "classify_sentiment"
end

The support model receives spawn, messaging, interruption, waiting, and listing tools for the research kind. It sees the sentiment agent as one regular tool whose result is returned to the current turn.

Static declarations may be combined with a resolver that returns dynamic Subagents::Definition objects. Managed conversations persist when a session store is configured unless persist: false keeps them local to one invocation. An agent exposed as a tool starts with empty history unless preserve_context: true serializes calls and retains its history.

Tool overrides must be classes. A delegated agent otherwise receives only its own declared tools; it does not inherit the parent’s registry. The manager enforces its concurrency, identity, polling, and persistence bounds.