"""Feedback tool."""

from __future__ import annotations

from ims_mcp.context import CallContext
from ims_mcp.services.feedback import FeedbackService


async def submit_feedback(
    call_ctx: CallContext,
    feedback_service: FeedbackService,
    request_mode: str,
    feedback: dict,
) -> str:
    required = {"summary", "root_cause", "prompt_suggestions", "context"}
    missing = [key for key in required if key not in feedback]
    if missing:
        return f"Error: feedback is missing required keys: {', '.join(sorted(missing))}"
    return feedback_service.submit(request_mode=request_mode, feedback=feedback, call_ctx=call_ctx)
