Agentic.Loop.Engine (agentic v0.2.2)

Copy Markdown

Composable pipeline engine for agent loops.

Runs a list of stages as a pipeline. Each stage wraps the next, forming a middleware chain.

Usage

Engine.run(context, [ContextGuard, LLMCall, ModeRouter, ToolExecutor])

Stop-reason routing

The loop doesn't use a step counter. The ModeRouter stage decides whether to loop (tool_use), terminate (end_turn), or compact (max_tokens). A hard max_turns limit exists only as a safety rail.

Summary

Functions

Build a pipeline function from a list of stage modules.

Run the pipeline with the given stages.

Functions

build_pipeline(stages)

Build a pipeline function from a list of stage modules.

The pipeline is built right-to-left: the last stage in the list wraps the terminal function, and each preceding stage wraps the one after it.

run(ctx, stages)

Run the pipeline with the given stages.

Returns {:ok, result_map} or {:error, reason}.