Nous.Plugins.SubAgent (nous v0.13.3)

View Source

Plugin that enables agents to delegate tasks to specialized sub-agents.

Provides two tools:

  • delegate_task — run a single sub-agent for one task (sequential)
  • spawn_agents — run multiple sub-agents in parallel via Task.Supervisor

Usage

agent = Agent.new("openai:gpt-4",
  plugins: [Nous.Plugins.SubAgent],
  deps: %{
    sub_agent_templates: %{
      "researcher" => Agent.new("openai:gpt-4o-mini",
        instructions: "You are a research specialist. Find accurate information."
      ),
      "coder" => Agent.new("openai:gpt-4",
        instructions: "You are a coding specialist. Write clean Elixir code."
      )
    }
  }
)

Templates

Pre-configured agent templates can be provided via deps[:sub_agent_templates]. Templates can be either %Nous.Agent{} structs or config maps:

# Using Agent structs (recommended)
"researcher" => Agent.new("openai:gpt-4o-mini", instructions: "Research specialist")

# Using config maps (legacy)
"researcher" => %{model: "openai:gpt-4o-mini", instructions: "Research specialist"}

Both delegate_task and spawn_agents can reference templates by name or provide inline model/instructions for ad-hoc sub-agents.

Parallel Configuration

Configure concurrency and timeout for spawn_agents via deps:

  • :parallel_max_concurrency — max concurrent sub-agents (default: 5)
  • :parallel_timeout — per-task timeout in ms (default: 120_000)