AgentSea.Crew.Delegation behaviour (agentsea_crews v0.1.0)

Copy Markdown

Strategy behaviour for assigning a task to an agent. Each strategy is a module implementing delegate/3; the coordinator selects one by config.

Summary

Types

A candidate agent: its name, pid, and (optional) role.

Strategy context, e.g. :counter, :bidding_time_ms, :minimum_bid, :selection_criteria.

Functions

Run a delegation strategy, timing the decision.

Types

agent_ref()

@type agent_ref() :: %{
  :name => term(),
  :pid => pid() | nil,
  optional(:role) => AgentSea.Role.t() | nil
}

A candidate agent: its name, pid, and (optional) role.

ctx()

@type ctx() :: map()

Strategy context, e.g. :counter, :bidding_time_ms, :minimum_bid, :selection_criteria.

Callbacks

delegate(task, list, ctx)

@callback delegate(task :: term(), [agent_ref()], ctx()) ::
  {:ok, AgentSea.Crew.Delegation.Result.t()} | {:error, term()}

Functions

select(strategy, task, agents, ctx \\ %{})

@spec select(module(), term(), [agent_ref()], ctx()) ::
  {:ok, AgentSea.Crew.Delegation.Result.t()} | {:error, term()}

Run a delegation strategy, timing the decision.