Nous.Teams.Role (nous v0.16.1)
View SourceRole definitions for team agents.
A role configures an agent's system prompt, tool access, and iteration limits. Roles are plain structs with helper functions — no process needed.
Architecture
Roles are applied when spawning agents into a team. The system_prompt is
prepended to the agent's instructions, and allowed_tools/denied_tools
filter the available tool set.
Quick Start
# Use a built-in role
role = Role.researcher()
# Create a custom role
role = Role.new(name: :reviewer, system_prompt: "Review code carefully", denied_tools: ["execute_code"])
# Filter tools based on role
filtered = Role.apply_tool_filter(role, all_tools)
Summary
Functions
Filter a list of tools based on the role's allowed/denied lists.
Default coder role.
Default lead role.
Create a new role from keyword attributes.
Default researcher role.
Types
@type t() :: %Nous.Teams.Role{ allowed_tools: [String.t()] | nil, denied_tools: [String.t()] | nil, max_iterations: pos_integer(), name: atom(), system_prompt: String.t() | nil }
Functions
@spec apply_tool_filter(t(), [Nous.Tool.t()]) :: [Nous.Tool.t()]
Filter a list of tools based on the role's allowed/denied lists.
- If
allowed_toolsis set, only tools in that list are kept. - If
denied_toolsis set, tools in that list are removed. - If neither is set, all tools are returned.
allowed_toolstakes precedence overdenied_tools.
Examples
iex> role = Nous.Teams.Role.new(name: :restricted, allowed_tools: ["search", "read_file"])
iex> tools = [%Nous.Tool{name: "search", function: &Function.identity/1}, %Nous.Tool{name: "execute", function: &Function.identity/1}]
iex> filtered = Nous.Teams.Role.apply_tool_filter(role, tools)
iex> length(filtered)
1
@spec coder() :: t()
Default coder role.
Has access to code editing tools but restricted from destructive operations.
Examples
iex> role = Nous.Teams.Role.coder()
iex> role.name
:coder
@spec lead() :: t()
Default lead role.
Has unrestricted tool access and coordinates the team.
Examples
iex> role = Nous.Teams.Role.lead()
iex> role.name
:lead
Create a new role from keyword attributes.
Options
:name— atom identifying the role (required):system_prompt— system prompt prepended to agent instructions:allowed_tools— whitelist of tool names (nil means all allowed):denied_tools— blacklist of tool names (nil means none denied):max_iterations— max agent loop iterations (default: 15)
Examples
iex> role = Nous.Teams.Role.new(name: :researcher, system_prompt: "Research topics thoroughly")
iex> role.name
:researcher
@spec researcher() :: t()
Default researcher role.
Focused on information gathering with read-only tool access.
Examples
iex> role = Nous.Teams.Role.researcher()
iex> role.name
:researcher