Builds a routable team-member agent for LangEx.Prebuilt.Swarm and
LangEx.Prebuilt.Supervisor.
A member is an ordinary tool-calling agent (LLM node plus tool node)
compiled as its own graph, with one extra behaviour: it tracks an
:active_agent state key. While :active_agent names the member
itself the tool loop continues; once a handoff tool points it at a
different agent the member ends its turn so the enclosing team can
route control onward.
build/1 returns the compiled member graph; node/3 wraps it as a
parent-graph node that runs one turn and contributes only the messages
it produced (so a shared conversation is not duplicated on every hop).
The team's runtime context is forwarded into each member turn, and each
turn's token usage is contributed back under :llm_usage.
A member runs its turn as a nested execution, so a LangEx.Interrupt
raised inside a member is not resumable across the team boundary —
node/3 surfaces it as an error instead. Keep human-in-the-loop pauses
at the team level.
Summary
Types
How much of a member's turn is contributed back to the team.
Functions
The state key a team uses to track which agent holds the conversation.
Builds and compiles a member agent.
Wraps a compiled member as a parent-graph node.
Routing function for a member's tool node: keep looping while this member is active, otherwise end the turn so the team can re-route.
Types
Functions
@spec active_agent_key() :: atom()
The state key a team uses to track which agent holds the conversation.
@spec build(keyword()) :: LangEx.Graph.Compiled.t()
Builds and compiles a member agent.
Options
:name(required) - the member's own name; also its:active_agentidentity:tools- the member's own%LangEx.Tool{}list (default[]):handoff_tools- handoff%LangEx.Tool{}list appended to:tools:system_prompt- a string, or a 1-arity function(state -> string)for a dynamic prompt; prepended when the conversation has no system message:compaction- forwarded toLangEx.ContextCompaction.compact_if_needed/2;falsedisables:tool_opts- forwarded toLangEx.Tool.Node.node/2:store- long-term memory backend:pre_model_hook-(messages -> messages)applied to the message list just before the LLM call (e.g. trimming or extra instructions):post_model_hook-(update -> update)applied to the node result map after the LLM call (e.g. guardrails)- all other options (
:model/:provider,:temperature, ...) are forwarded toLangEx.LLM.ChatModel.node/1
@spec node(LangEx.Graph.Compiled.t(), atom(), output_mode()) :: (map(), term() -> map())
Wraps a compiled member as a parent-graph node.
The node runs one member turn seeded with the shared conversation and
the member's own name as the active agent, then returns just the
messages produced this turn (per output_mode), the resulting
:active_agent, and the turn's :llm_usage. The enclosing team's
runtime context is forwarded into the member turn.
Routing function for a member's tool node: keep looping while this member is active, otherwise end the turn so the team can re-route.