bstraehle commited on
Commit
7deefa2
·
verified ·
1 Parent(s): de34093

Update agents/tools/mcp_tools.py

Browse files
Files changed (1) hide show
  1. agents/tools/mcp_tools.py +10 -9
agents/tools/mcp_tools.py CHANGED
@@ -38,29 +38,30 @@ class MCPTools():
38
  arguments={"fen": fen}
39
  )
40
 
41
- result = raw_result
42
- print("111", result)
43
 
 
44
  if isinstance(raw_result, tuple) and len(raw_result) > 0:
45
  raw_result = raw_result[0]
46
  print("222", raw_result)
47
 
 
48
  if isinstance(raw_result, dict) and "continuation" in raw_result:
49
- print("333", result)
50
  result = raw_result["continuation"]
51
  print("333", result)
52
  elif isinstance(raw_result, str):
53
  try:
54
- print("444", raw_result)
55
  parsed = json.loads(raw_result)
56
- print("444", parsed)
57
  if isinstance(parsed, dict) and "continuation" in parsed:
58
- print("555", parsed)
59
  result = parsed["continuation"]
60
- print("555", result)
 
 
61
  except (json.JSONDecodeError, KeyError):
62
- pass
63
-
 
 
64
  print(f"🛠️ MCPTools: best_move_tool: result={result}")
65
 
66
  return result
 
38
  arguments={"fen": fen}
39
  )
40
 
41
+ print("111", raw_result)
 
42
 
43
+ # Extract from tuple if needed
44
  if isinstance(raw_result, tuple) and len(raw_result) > 0:
45
  raw_result = raw_result[0]
46
  print("222", raw_result)
47
 
48
+ # Extract continuation from dict
49
  if isinstance(raw_result, dict) and "continuation" in raw_result:
 
50
  result = raw_result["continuation"]
51
  print("333", result)
52
  elif isinstance(raw_result, str):
53
  try:
 
54
  parsed = json.loads(raw_result)
 
55
  if isinstance(parsed, dict) and "continuation" in parsed:
 
56
  result = parsed["continuation"]
57
+ print("444", result)
58
+ else:
59
+ result = raw_result
60
  except (json.JSONDecodeError, KeyError):
61
+ result = raw_result
62
+ else:
63
+ result = raw_result
64
+
65
  print(f"🛠️ MCPTools: best_move_tool: result={result}")
66
 
67
  return result