Skip to content
docsv0.19.1

GatedToolCalls

Tool calls through a gate: consult, execute through the registry, record. This is the one place a tool is called on behalf of an actor that must be governed — a model, a recipe, a sequence. Every caller extends it or holds one: a model gateway adds what it removed from the table, a governed door adds the consent it collected (greenhouse decisions/0225). Extensions separate three facts: {@see self::hidden()} controls catalogue visibility, {@see self::withdrawn()} forbids execution, and {@see self::optionRemoved()} marks a gate refusal against historical withdrawal. Nothing here knows what a session or a model is.

GatedToolCalls::__construct()

public function __construct(Milpa\ToolRuntime\ToolRegistry $registry, ?Milpa\ToolRuntime\Gate\ToolCallGate $gate = null, ?Milpa\ToolRuntime\Gate\ToolCallRecorder $recorder = null):

Calls through `$registry`, asking `$gate` before each one and telling `$recorder` after — both optional.

Parameters

Parameters of __construct()
NameTypeDescription
$registryMilpa\ToolRuntime\ToolRegistry
$gate?Milpa\ToolRuntime\Gate\ToolCallGate
$recorder?Milpa\ToolRuntime\Gate\ToolCallRecorder

GatedToolCalls::setContext()

public function setContext(Milpa\ToolRuntime\Contracts\ToolContext $context): void

The context every call from now on carries to the registry (who, on which channel).

Parameters

Parameters of setContext()
NameTypeDescription
$contextMilpa\ToolRuntime\Contracts\ToolContext

GatedToolCalls::callToolWithBudget()

public function callToolWithBudget(string $name, array $args, Milpa\ToolRuntime\Contracts\ResultBudget $budget): ?mixed

Scope a transport budget to one synchronous call, preserving subclass dispatch and gates. The overlay is applied after an extension has supplied the actual caller's context.

Parameters

Parameters of callToolWithBudget()
NameTypeDescription
$namestring
$argsarray<string, mixed>
$budgetMilpa\ToolRuntime\Contracts\ResultBudget

GatedToolCalls::getToolSummaries()

public function getToolSummaries(): array

The registry's tool summaries, minus what {@see self::hidden()} takes away.

GatedToolCalls::callTool()

public function callTool(string $name, array $args): ?mixed

Call one tool: scopes, active withdrawal, gate, registry, then recorder.

Parameters

Parameters of callTool()
NameTypeDescription
$namestring
$argsarray<string, mixed>

Throws

ToolCallRefused when an active withdrawal or the gate refuses

\Exception when the tool itself failed, with the tool's own error