Coverage for /home/admin/Documents/AI/applications/lexigram-dev/lexigram/experimental/ai/lexigram-ai-agents/src/lexigram/ai/agents/strategies/base.py: 100%
7 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-25 07:19 +0800
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-25 07:19 +0800
1"""Base strategy class for agent reasoning strategies."""
3from __future__ import annotations
5from abc import ABC, abstractmethod
6from typing import TYPE_CHECKING, Any
8from lexigram.contracts.ai.agents import StrategyProtocol, ToolProtocol
10if TYPE_CHECKING:
11 from lexigram.contracts.ai.agents import AgentError, AgentResponse
12 from lexigram.contracts.ai.llm import LLMClientProtocol
13 from lexigram.result import Result
16class AbstractStrategy(ABC, StrategyProtocol):
17 """Base class for agent reasoning strategies.
19 Strategies implement the reasoning loop that drives an agent's behavior.
20 """
22 @abstractmethod
23 async def execute(
24 self,
25 message: str,
26 tools: list[ToolProtocol],
27 history: list[dict[str, Any]],
28 llm: LLMClientProtocol,
29 **kwargs: Any,
30 ) -> Result[AgentResponse, AgentError]:
31 """Execute the reasoning strategy.
33 Args:
34 message: The user's input message.
35 tools: Tools available to the agent.
36 history: Conversation history as ChatMessage objects.
37 llm: LLM client implementing LLMClientProtocol.
38 **kwargs: Additional strategy-specific parameters.
40 Returns:
41 Ok(AgentResponse) on success, Err(AgentError) on failure.
42 """