plexus.cli.procedure.lua_dsl.primitives.tool module
Tool Primitive - Tool call tracking and result access.
Provides: - Tool.called(name) - Check if tool was called - Tool.last_result(name) - Get last result from named tool - Tool.last_call(name) - Get full call info
- class plexus.cli.procedure.lua_dsl.primitives.tool.ToolCall(name: str, args: Dict[str, Any], result: Any)
Bases:
objectRepresents a single tool call with arguments and result.
- __init__(name: str, args: Dict[str, Any], result: Any)
- to_dict() Dict[str, Any]
Convert to dictionary for Lua access.
- class plexus.cli.procedure.lua_dsl.primitives.tool.ToolPrimitive
Bases:
objectTracks tool calls and provides access to results.
Maintains a history of tool calls and their results, allowing Lua code to check what tools were used and access their outputs.
Initialize tool tracking.
- __init__()
Initialize tool tracking.
- called(tool_name: str) bool
Check if a tool was called at least once.
- Args:
tool_name: Name of the tool to check
- Returns:
True if the tool was called
- Example (Lua):
- if Tool.called(“done”) then
Log.info(“Done tool was called”)
end
- get_all_calls() List[ToolCall]
Get all tool calls (for debugging/logging).
- Returns:
List of all ToolCall objects
- get_call_count(tool_name: str | None = None) int
Get the number of times a tool was called.
- Args:
tool_name: Name of tool (or None for total count)
- Returns:
Number of calls
- last_call(tool_name: str) Dict[str, Any] | None
Get full information about the last call to a tool.
- Args:
tool_name: Name of the tool
- Returns:
Dictionary with ‘name’, ‘args’, ‘result’ or None if never called
- Example (Lua):
local call = Tool.last_call(“search”) if call then
Log.info(“Search was called with: “ .. call.args.query) Log.info(“Result: “ .. call.result)
end
- last_result(tool_name: str) Any
Get the last result from a named tool.
- Args:
tool_name: Name of the tool
- Returns:
Last result from the tool, or None if never called
- Example (Lua):
local result = Tool.last_result(“search”) if result then
Log.info(“Search found: “ .. result)
end
- record_call(tool_name: str, args: Dict[str, Any], result: Any) None
Record a tool call (called by runtime after tool execution).
- Args:
tool_name: Name of the tool args: Arguments passed to the tool result: Result returned by the tool
Note: This is called internally by the runtime, not from Lua
- reset() None
Reset tool tracking (mainly for testing).