Base¶
Base agent implementation for the Arshai framework.
This module provides the foundational BaseAgent class that all other agents must extend. It provides common functionality while requiring developers to implement their own process method.
Classes¶
- class arshai.agents.base.BaseAgent(llm_client, system_prompt, **kwargs)[source]¶
-
Abstract base agent implementation.
This class provides the foundational structure for all agents. Developers must implement the process method to define their agent’s behavior.
The agent gives developers complete authority over: - Response format (streaming, structured, simple string, etc.) - Data structure returned - How to use the LLM client - Tool integration patterns - Memory management
Example
- class MyAgent(BaseAgent):
- async def process(self, input: IAgentInput) -> str:
# Simple string response result = await self.llm_client.chat(ILLMInput(
system_prompt=self.system_prompt, user_message=input.message
)) return result[‘response’]
- abstractmethod async process(input)[source]¶
Process the input and return a response.
This method MUST be implemented by subclasses. The return type is Any to give developers complete flexibility over: - Response format (streaming, non-streaming, structured, etc.) - Data types (string, dict, custom DTOs, generators, etc.) - Error handling approach
- Parameters:
input (
IAgentInput) – The input containing message and optional metadata- Returns:
Developer-defined response format
- Return type:
Any