runner

Classes

RunResultStreaming(step_history, output, ...)

Runner(agent, **kwargs)

A runner class that executes an Agent instance with multi-step execution.

class Runner(agent: Agent, **kwargs)[source]

Bases: Component

A runner class that executes an Agent instance with multi-step execution.

It internally maintains a planner LLM and an executor and adds a LLM call to the executor as a tool for the planner.

The output to the planner agent call is expected to be a Function object. The planner iterates through at most max_steps unless the planner sets the action to “finish” then the planner returns the final response.

If the user optionally specifies the output_type then the Runner parses the Function object to the output_type.

planner

The agent instance to execute

Type:

Agent

config

Configuration for the runner

Type:

RunnerConfig

max_steps

Maximum number of steps to execute

Type:

int

call(prompt_kwargs: Dict[str, Any], model_kwargs: Dict[str, Any] | None = None, use_cache: bool | None = None, id: str | None = None) Tuple[List[StepOutput], T][source]

Execute the planner synchronously for multiple steps with function calling support.

At the last step the action should be set to “finish” instead which terminates the sequence

Parameters:
  • prompt_kwargs – Dictionary of prompt arguments for the generator

  • model_kwargs – Optional model parameters to override defaults

  • use_cache – Whether to use cached results if available

  • id – Optional unique identifier for the request

Returns:

  • List of step history (StepOutput objects)

  • Final processed output of type specified in self.answer_data_type

Return type:

Tuple containing

async acall(prompt_kwargs: Dict[str, Any], model_kwargs: Dict[str, Any] | None = None, use_cache: bool | None = None, id: str | None = None) Tuple[List[GeneratorOutput], T][source]

Execute the planner asynchronously for multiple steps with function calling support.

At the last step the action should be set to “finish” instead which terminates the sequence

Parameters:
  • prompt_kwargs – Dictionary of prompt arguments for the generator

  • model_kwargs – Optional model parameters to override defaults

  • use_cache – Whether to use cached results if available

  • id – Optional unique identifier for the request

Returns:

  • List of step history (GeneratorOutput objects)

  • Final processed output

Return type:

Tuple containing

astream(prompt_kwargs: Dict[str, Any], model_kwargs: Dict[str, Any] | None = None, use_cache: bool | None = None, id: str | None = None)[source]
async impl_astream(prompt_kwargs: Dict[str, Any], model_kwargs: Dict[str, Any] | None = None, use_cache: bool | None = None, id: str | None = None) Tuple[List[GeneratorOutput], T][source]

Execute the planner asynchronously for multiple steps with function calling support.

At the last step the action should be set to “finish” instead which terminates the sequence

Parameters:
  • prompt_kwargs – Dictionary of prompt arguments for the generator

  • model_kwargs – Optional model parameters to override defaults

  • use_cache – Whether to use cached results if available

  • id – Optional unique identifier for the request

Returns:

  • List of step history (GeneratorOutput objects)

  • Final processed output

Return type:

Tuple containing