Coverage for /home/admin/Documents/AI/applications/lexigram-dev/lexigram/experimental/ai/lexigram-ai-agents/src/lexigram/ai/agents/config.py: 100%

18 statements  

« prev     ^ index     » next       coverage.py v7.15.4, created at 2026-08-25 07:19 +0800

1"""Agent configuration for the Lexigram framework.""" 

2 

3from __future__ import annotations 

4 

5from typing import ClassVar, cast 

6 

7from lexigram.ai.agents import constants as const 

8from lexigram.config.base import BaseConfig 

9from lexigram.validation import ConfigDict, Field 

10 

11ENV_PREFIX: str = const.ENV_PREFIX 

12ENV_NESTED_DELIMITER: str = const.ENV_NESTED_DELIMITER 

13 

14 

15class AgentConfig(BaseConfig): 

16 """Configuration for the agent system. 

17 

18 Attributes: 

19 max_iterations: Maximum reasoning iterations per execution. 

20 default_temperature: Default temperature for LLM calls. 

21 default_max_tokens: Default max tokens for LLM responses. 

22 tool_max_retries: Maximum retry attempts for transient tool errors. 

23 enable_tracing: Enable OpenTelemetry tracing. 

24 enable_metrics: Enable Prometheus metrics. 

25 

26 Example: 

27 >>> config = AgentConfig( 

28 ... max_iterations=10, 

29 ... default_temperature=0.7 

30 ... ) 

31 """ 

32 

33 config_section: ClassVar[str] = "ai_agents" 

34 

35 model_config: ClassVar[ConfigDict] = cast( 

36 "ConfigDict", 

37 { 

38 "env_prefix": ENV_PREFIX, 

39 "env_nested_delimiter": ENV_NESTED_DELIMITER, 

40 "extra": "ignore", 

41 }, 

42 ) 

43 

44 enabled: bool = Field(default=True, description="Enable the AI agents subsystem") 

45 

46 max_iterations: int = Field( 

47 default=10, 

48 ge=1, 

49 description="Maximum reasoning iterations per execution", 

50 ) 

51 

52 default_temperature: float = Field( 

53 default=0.7, 

54 ge=0.0, 

55 le=2.0, 

56 description="Default temperature for LLM calls", 

57 ) 

58 

59 default_max_tokens: int = Field( 

60 default=2048, 

61 ge=1, 

62 description="Default max tokens for LLM responses", 

63 ) 

64 

65 tool_max_retries: int = Field( 

66 default=3, 

67 ge=1, 

68 description=( 

69 "Number of retries for transient tool execution errors " 

70 "(ConnectionError, TimeoutError, OSError)" 

71 ), 

72 ) 

73 

74 enable_tracing: bool = Field( 

75 default=True, 

76 description="Enable OpenTelemetry tracing", 

77 ) 

78 

79 enable_metrics: bool = Field( 

80 default=True, 

81 description="Enable Prometheus metrics", 

82 ) 

83 

84 

85__all__ = ["ENV_PREFIX", "AgentConfig"]