Jido.Runner.Chain (Jido v1.1.0-rc.2)
View SourceA runner that executes instructions sequentially with support for result chaining.
Chain Execution
Instructions are executed in sequence with the output of each instruction becoming the input for the next instruction in the chain via the merge_results option.
Features
- Sequential instruction execution
- Result chaining between instructions
- Directive accumulation
- Comprehensive error handling
Summary
Functions
Executes a chain of instructions sequentially, with optional result merging.
Types
@type chain_result() :: {:ok, Jido.Agent.t(), [Jido.Agent.Directive.t()]} | {:error, Jido.Error.t()}
Functions
@spec run(Jido.Agent.t(), chain_opts()) :: chain_result()
Executes a chain of instructions sequentially, with optional result merging.
Parameters
agent
- The agent struct containing:pending_instructions
- Queue of pending instructionsstate
- Current agent stateid
- Agent identifier
opts
- Optional keyword list of execution options::merge_results
- When true, merges each result into the next instruction's params (default: true):apply_directives?
- When true (default), applies directives during execution
Returns
{:ok, updated_agent, directives}
- Chain completed successfully with:- Final result stored in agent.result
- List of accumulated directives
{:error, error}
- Chain execution failed with error details
Examples
# Basic chain execution
{:ok, updated_agent, directives} = Chain.run(agent)
# Chain with result merging disabled
{:ok, updated_agent, directives} = Chain.run(agent, merge_results: false)
# Chain without applying directives
{:ok, updated_agent, directives} = Chain.run(agent, apply_directives?: false)