Agent class
TheAgent class is the core class in Agenite that orchestrates interactions between LLMs and tools.
Constructor
Parameters
name(required): Unique identifier for the agentprovider(required): LLM provider instancetools: Array of tools available to the agentinstructions: System instructions for the agent (default: “You are a helpful assistant.”)description: Description of the agent’s purposeagents: Sub-agents that can be called by this agentstateReducer: Custom state management functionsinitialState: Initial agent statesteps: Custom execution stepsstartStep: First step to execute (default: “agenite.llm-call”)middlewares: Array of middleware functions to modify agent behaviorextensions: Additional custom functionality
Methods
execute
Execute the agent with a set of inputs.Parameters
input(required): Input state, typically containing messagesoptions: Additional execution optionsstream: Enable streaming responsescontext: Additional execution contextparentExecution: Context from a parent execution (for nested agents)
Returns
Returns the final state object containing:messages: Array of messages from the conversationtokenUsage: Token usage statistics- Additional properties from the state
iterate
Get an iterator for streaming responses.Parameters
Same asexecute
Returns
An AsyncGenerator that yields various events during execution:State and Messages
State Structure
The agent maintains state which typically includes at minimum:Message Structure
Messages follow the structure defined in the LLM package:Step Interface
Custom steps implement the Step interface:Middleware Interface
Middlewares wrap the generator function:Examples
Basic usage
With custom state
With middleware
With custom steps
Next steps
- Learn about the Tool API
- Explore provider APIs
- Read about middleware

