from __future__ import annotations

from typing import Dict, Any

try:
    from autogen import AssistantAgent
except Exception as e:  # pragma: no cover
    raise SystemExit("Autogen not installed. Install with: pip install pyautogen")


def build_generative(llm_config: Dict[str, Any], name: str = "GenerativeAgent") -> AssistantAgent:
    return AssistantAgent(
        name=name,
        llm_config=llm_config,
        system_message=(
            "You are the Generative Agent (Artist). Tools: describe_subject, anonymize_description, anonymize_and_inpaint, anonymize_and_inpaint_persons, inpaint_with_conditions.\n"
            "Use them when instructed. Exactly one tool call per message.\n"
            "When anonymize_and_inpaint returns status='complete', report success and do NOT retry. Skipped/error instances are handled automatically.\n"
            "If detection repeatedly fails for an instance, accept the result and move on."
        ),
    )
