MCPcopy Create free account
hub / github.com/Noumena-Network/code / _run_tool

Function _run_tool

src/tools/REPLTool/kernel.py:48–80  ·  view source on GitHub ↗
(exec_id, tool_name, args)

Source from the content-addressed store, hash-verified

46
47
48async def _run_tool(exec_id, tool_name, args):
49 global tool_counter
50
51 if not isinstance(tool_name, str) or not tool_name:
52 raise RuntimeError("codex.tool expects a tool name string")
53
54 tool_id = f"{exec_id}-tool-{tool_counter}"
55 tool_counter += 1
56
57 arguments_json = "{}"
58 if isinstance(args, str):
59 arguments_json = args
60 elif args is not None:
61 arguments_json = json.dumps(args)
62
63 loop = asyncio.get_running_loop()
64 future = loop.create_future()
65 pending_tool[tool_id] = future
66
67 _send(
68 {
69 "type": "run_tool",
70 "id": tool_id,
71 "exec_id": exec_id,
72 "tool_name": tool_name,
73 "arguments": arguments_json,
74 }
75 )
76
77 result = await future
78 if not result.get("ok"):
79 raise RuntimeError(result.get("error") or "tool failed")
80 return result.get("response")
81
82
83async def _handle_exec(message):

Callers 1

_toolFunction · 0.70

Calls 2

_sendFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected