"""
ExplainerAgent - explains theory using chat-model.
"""

import logging
from typing import List, Any, Optional
from .base_agent import BaseAgent, AgentState
from prompts import get_prompts

logger = logging.getLogger(__name__)

class ExplainerAgent(BaseAgent):
    def __init__(self):
        super().__init__("Explainer", "stub", mode=0, history_limit=50)

    def _get_system_prompt(self, subject_id: int, state: Optional[AgentState] = None) -> str:
        explainer_prompt, _, plain_prompt = get_prompts(subject_id)
        if state and getattr(state, "plain_text_mode", False):
            res = plain_prompt or explainer_prompt or "Поясни материал."
            # Ensure TG_PLAIN_TEXT_SUFFIX is present for Telegram plain text mode
            from prompts.tg_suffix import TG_PLAIN_TEXT_SUFFIX
            if TG_PLAIN_TEXT_SUFFIX not in res:
                res += TG_PLAIN_TEXT_SUFFIX
            return res
        return explainer_prompt or "Поясни материал."

    def _get_tools(self) -> List[Any]:
        """
        Get tools available to this agent.
        ExplainerAgent does not use any tools directly, so it returns an empty list.
        """
        return self._get_gemini_tools()

    def _get_gemini_tools(self) -> List[Any]:
        """No tools needed for Explainer agent"""
        return []

    def _process_function_call(self, function_call, state: AgentState) -> Any:
        """No function calls expected for Explainer agent"""
        return None 