mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-16 09:40:30 +08:00
- 22 unit test files added/modified across all core modules - Fix jsonschema ValidationError import in test_tool - Coverage increased from 23% to ~35% overall
23 lines
692 B
Python
23 lines
692 B
Python
from typing import Any, Generic
|
|
|
|
from pydantic import Field
|
|
from pydantic.dataclasses import dataclass
|
|
from typing_extensions import TypeVar
|
|
|
|
from .message import Message
|
|
|
|
TContext = TypeVar("TContext", default=Any)
|
|
|
|
|
|
@dataclass
|
|
class ContextWrapper(Generic[TContext]):
|
|
"""A context for running an agent, which can be used to pass additional data or state."""
|
|
|
|
context: TContext | None = None
|
|
messages: list[Message] = Field(default_factory=list)
|
|
"""This field stores the llm message context for the agent run, agent runners will maintain this field automatically."""
|
|
tool_call_timeout: int = 120 # Default tool call timeout in seconds
|
|
|
|
|
|
NoContext = ContextWrapper[None]
|