File size: 1,148 Bytes
e266561
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
validate_node.py — Returns a success response when the user's reasoning is correct.
No LLM call — purely deterministic.
"""

from agent.models import AgentState
from agent.memory import load_profile, update_profile, persist_profile


def validate_solution(state: AgentState) -> dict:
    """Validates that the user's approach is correct and returns a success response."""
    session_id = state.get("session_id", "anonymous")

    # Mark as solved in the user's profile
    try:
        profile = load_profile(session_id)
        profile = update_profile(
            profile,
            topic=state.get("problem_topic", "unknown"),
            gap_magnitude=0,
            solved=True,
        )
        persist_profile(profile)
    except Exception as e:
        print(f"[validate_node] Memory error: {e}")

    return {
        "final_response": {
            "hint": (
                "✅ Great job! Your reasoning is sound and your approach is optimal. "
                "You can proceed to implementation or explore further optimizations."
            ),
            "type":  "Validation",
            "score": 100,
        }
    }