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

Function _run_tool

rust/py_repl_host/assets/kernel.py:57–89  ·  view source on GitHub ↗
(exec_id, tool_name, args)

Source from the content-addressed store, hash-verified

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

Callers 1

_toolFunction · 0.70

Calls 2

_sendFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected