package dev.sonpx.loyalty.agent.core.config;

import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * Externalized configuration for Agent behavior.
 */
@Getter
@Setter
@Configuration
@ConfigurationProperties(prefix = "agent")
public class AgentProperties {

    /** Maximum number of tool call iterations per request (prevents infinite loops) */
    private int maxIterations = 10;

    /** Timeout in seconds for the entire request processing */
    private int timeoutSeconds = 60;

    /** Maximum characters for a single tool result before truncation */
    private int maxToolResultChars = 4000;

    /** Maximum tokens to keep in chat memory */
    private int maxMemoryTokens = 8000;

    /** Characters per token estimate for Vietnamese text */
    private int charsPerToken = 2;

    /** Agent-specific model routing. Defaults preserve the existing single-model setup. */
    private Models models = new Models();

    @Getter
    @Setter
    public static class Models {
        private Model chat = Model.fast();
        private Model query = Model.strong();
        private Model creator = Model.creator();
    }

    @Getter
    @Setter
    public static class Model {
        private String baseUrl = "http://192.168.99.10:11434";
        private String model = "qwen3.5:4b";
        private Double temperature = 0.3;
        private Integer numCtx = 32768;
        private boolean disableThinking;

        static Model fast() {
            Model config = new Model();
            config.model = "qwen3.5:4b";
            config.temperature = 0.7;
            config.disableThinking = true;
            return config;
        }

        static Model strong() {
            return new Model();
        }

        static Model creator() {
            Model config = new Model();
            config.temperature = 0.2;
            return config;
        }
    }
}
