Agentic.Loop.Stage behaviour (agentic v0.2.2)

Copy Markdown

Behaviour for loop pipeline stages.

Each stage receives a context and a next function representing the rest of the pipeline. Stages can:

  • Pass through: call next.(context) to continue the pipeline
  • Short-circuit: return {:done, result} to stop the pipeline
  • Transform: modify context before calling next
  • Loop: call next multiple times (e.g. ModeRouter)

Stages optionally declare a model_tier/0 if they need an LLM model.

Summary

Callbacks

Execute this stage. Call next.(context) to continue the pipeline.

The model tier this stage needs (e.g. :primary, :lightweight, :image, :vision). Return nil if no model is needed.

Types

context()

@type context() :: map()

next()

@type next() :: (context() -> result())

result()

@type result() :: {:ok, context()} | {:done, map()} | {:error, term()}

Callbacks

call(context, next)

@callback call(context(), next()) :: result()

Execute this stage. Call next.(context) to continue the pipeline.

model_tier()

(optional)
@callback model_tier() :: atom() | nil

The model tier this stage needs (e.g. :primary, :lightweight, :image, :vision). Return nil if no model is needed.