"""Simple deterministic thinking helper tool."""

from __future__ import annotations

from typing import Any, Dict, List, Optional

from armorer.agent_sdk import tool


@tool(category="reasoning", verification_level="internal_support")
def think(
    thought: str,
    cycle_count: int = 1,
    system_prompt: str = "",
    tools: Optional[List[str]] = None,
    model_provider: Optional[str] = None,
    model_settings: Optional[Dict[str, Any]] = None,
    thinking_system_prompt: Optional[str] = None,
    agent: Optional[Any] = None,
) -> Dict[str, Any]:
    """
    Produce a compact multi-cycle reflection string.

    This avoids recursive agent orchestration and keeps the tool deterministic.
    """
    del system_prompt, tools, model_provider, model_settings, thinking_system_prompt, agent

    cycles = max(1, min(int(cycle_count or 1), 10))
    current = thought.strip()
    history: List[str] = []

    for idx in range(cycles):
        current = f"Cycle {idx + 1}: {current}"
        history.append(current)

    return {
        "status": "success",
        "cycles": cycles,
        "response": "\n".join(history),
    }
