File size: 1,600 Bytes
3370983
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# src/core/configs/agent.py
from typing import List, Optional
from langchain_core.tools import BaseTool
from pydantic import BaseModel, Field, ConfigDict
from src.backend.core.configs.model import ModelConfig


class AgentConfig(BaseModel):
    """
    Configuration schema for initializing LangGraph agents.

    Notes:
        Pydantic setting ``model_config = ConfigDict(arbitrary_types_allowed=True)``
        allows this model to include arbitrary Python objects such as LangChain
        tools or runtime components that are not JSON-serializable or Pydantic
        models. These objects (e.g., `BaseTool` instances) are accepted as-is
        without validation or serialization, while all standard fields
        (strings, numbers, nested Pydantic models) remain fully validated.
    """
    model_config = ConfigDict(
        arbitrary_types_allowed=True
    )
    name: str = Field(
        ...,
        description="Unique name of the agent."
    )
    description: str = Field(
        ...,
        description="Short description of what the agent does."
    )
    model_config: ModelConfig = Field(
        ...,
        description="Configuration of the underlying LLM model."
    )
    tools: Optional[List[BaseTool]] = Field(
        default_factory=list,
        description="List of tools available to the agent."
    )
    system_prompt: str = Field(
        default="",
        description="System prompt to condition the agent's behavior."
    )
    max_iterations: Optional[int] = Field(
        default=None,
        description="Optional limit on reasoning iterations."
    )