tools are the model’s action space.
define a tool
from benchmax.envs.base_env import ToolDefinition
search_tool = ToolDefinition(
name="search_corpus",
description="Search the corpus using BM25 with optional filters.",
input_schema={
"type": "object",
"properties": {
"query": {"type": "string"},
"limit": {"type": "integer"},
},
"required": ["query"],
},
)
implement and register
self._tools = {"search_corpus": (search_tool, self._search_impl)}
async def list_tools(self):
return [defn for defn, _ in self._tools.values()]
async def run_tool(self, rollout_id: str, tool_name: str, **tool_args):
_, impl = self._tools[tool_name]
return await impl(**tool_args)
notes
input_schemashould be explicit and stable.- output should be parseable and consistent.
- keep tool names aligned between schema and implementation.