LlmCore.Agent.Pipeline.Iteration (llm_core v0.3.0)

Copy Markdown View Source

ALF pipeline for processing a single agentic loop iteration.

Given an LLM response that may contain tool calls, this pipeline:

  1. ParseToolCalls — Extracts tool calls from the response
  2. ValidateCalls — Checks names exist, validates args vs schema
  3. BudgetGuard — Iteration budget enforcement
  4. DispatchTools — Executes tools via the resolver, collects results
  5. InjectResults — Builds tool result messages for the next turn
  6. LoopDecision — Decides {:continue, msgs} or {:done, response}

This is the per-iteration counterpart to the outer loop in LlmCore.Agent.Loop. The relationship mirrors the pattern of an outer iteration controller wrapping a per-event processing pipeline:

GrooveExecutor.run_steps          LlmCore.Agent.Loop.run
Stepwise.Pipeline.Stepwise        LlmCore.Agent.Pipeline.Iteration
StepwiseAction / Advance / etc.   ParseToolCalls / Dispatch / etc.

Summary

Functions

alf_components()

call(event, opts \\ [debug: false])

@spec call(any(), Keyword.t()) :: any() | [any()] | nil
@spec call(any(), Keyword.t()) :: reference()

cast(event, opts \\ [debug: false, send_result: false])

components()

@spec components() :: [map()]

ensure_started(opts \\ [])

@spec ensure_started(keyword()) :: :ok | {:error, term()}

Ensures the ALF pipeline process is running, starting it if necessary.

Checks if the pipeline process is registered. If not, starts it with the given options. Supports sync: true for deterministic test execution.

Parameters

  • opts — keyword list passed to the ALF manager. Common options:
    • :sync — when true, pipeline runs synchronously (useful for tests)

Returns

  • :ok — pipeline is running
  • {:error, reason} — pipeline failed to start

Examples

:ok = LlmCore.Agent.Pipeline.Iteration.ensure_started(sync: true)

flow(flow, names, opts \\ [debug: false])

@spec flow(map(), list(), Keyword.t()) :: Enumerable.t()

start()

@spec start() :: :ok

start(opts)

@spec start(list()) :: :ok

started?()

@spec started?() :: true | false

stop()

@spec stop() :: :ok | {:exit, {atom(), any()}}

stream(stream, opts \\ [debug: false])

@spec stream(Enumerable.t(), Keyword.t()) :: Enumerable.t()