from __future__ import annotations

from app.core.agent.processes.v1.workflow.flow_main.context import V1FlowContext
from app.core.agent.utils.workflow import WorkflowStep


class FinalizeAnswerStep(WorkflowStep[V1FlowContext]):
    step_id = "finalize_answer"
    title = "Финализация ответа"

    async def run(self, context: V1FlowContext) -> V1FlowContext:
        context.answer = context.answer.strip()
        return context

    def trace_input(self, context: V1FlowContext) -> dict[str, object]:
        return {"answer_length_before_strip": len(context.answer)}

    def trace_output(self, context: V1FlowContext) -> dict[str, object]:
        return {"answer_length": len(context.answer)}
