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

import dev.sonpx.loyalty.agent.domain.ChatRequest;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

/**
 * Chooses the stable key used by memory and workflow state.
 * Requires explicit conversationId from ChatRequest.
 */
@Component
public class ConversationKeyResolver {

    public String resolve(ChatRequest request, String connectionSessionId) {
        if (request != null && StringUtils.hasText(request.conversationId())) {
            return request.conversationId();
        }
        throw new IllegalArgumentException("conversationId is required in ChatRequest");
    }
}
