from sympy import symbols, Eq, solve, sympify class SolveEquationTool: name = "solve_equation" description = "Solves a basic equation for x. Format: '2*x + 3 = 7'" def __call__(self, equation: str) -> str: x = symbols('x') try: if "=" not in equation: return "Error: Equation must contain '=' sign. E.g., '2*x + 3 = 7'" lhs, rhs = equation.split("=") eq = Eq(sympify(lhs), sympify(rhs)) sol = solve(eq, x) return f"x = {sol}" except Exception as e: return f"Error: {str(e)}" class ExplainSolutionTool: name = "explain_solution" description = "Provides a hardcoded explanation for a known equation." def __call__(self, problem: str) -> str: if "2*x + 3 = 7" in problem.replace(" ", ""): return "Step 1: Subtract 3 → 2x = 4\nStep 2: Divide by 2 → x = 2" return "This agent currently only explains '2*x + 3 = 7'. Extend this for more coverage."