Add a Planner#
A planner receives prompts, chooses tools, and consumes their results. To add one, subclass Planner, implement solve, and expose it through the construction path and CLI choices.
The following interface sketch omits model requests and the tool loop; it is not a runnable implementation. See rpent/planner/api_loop.py for a complete backend.
# rpent/planner/my_planner.py
from rpent.planner.base import Planner, PlannerResult
class MyPlanner(Planner):
def solve(
self,
*,
system_prompt,
user_message,
toolkit,
max_turns,
input_queue=None,
dashboard_interaction=None,
):
tools = toolkit.list_tools()
# Call the model with system_prompt, user_message, and tools.
# Execute each tool call through this interface:
tool_result = toolkit.execute_tool(tool_name, arguments)
...
return PlannerResult(
finish_result=finish_result,
messages=messages,
stats=stats,
error=error,
)
Any planner must:
Accept the rendered
system_promptanduser_message.Read each tool’s
name,description, andinput_schemafromtoolkit.list_tools()and execute tools withtoolkit.execute_tool(name, arguments).Convert
ToolResult.to_text()and PNG bytes inToolResult.imagesto the format expected by the model SDK.Detect
ToolResult.data.get("_finish")and stop according tomax_turnsand any other limits.Return a
PlannerResultcontaining the finish state, messages, statistics, and an optional error.
Because the RPent tool schemas and prompt-rendering path stay the same, adding a planner does not require changes to tools or environment servers. See Architecture and Execution for the interface, and Add an Action Primitive if you want to expose new tools to your custom planner.
Wire and Validate the Planner#
Add a construction branch in rpent/planner/base.py:build_planner and a CLI choice in rpent/cli/main.py. If the planner supports Dashboard selection or connection diagnostics, wire those entry points and rpent/planner/check.py as well.
Verify tool dispatch, text and image results, finish, turn limits, errors, and the interruption and interaction paths you support. Reuse test patterns in tests/unit_tests/rpent/planner/. Validate real model connectivity separately.