Skip to main content

Function: governTool()

governTool<TInput, TOutput>(tool, policy, governance): ITool<TInput, TOutput>

Defined in: packages/agentos/src/safety/runtime/GovernedTool.ts:205

The tool as a governed tool. A call runs, in order: its arguments' shape and the policy's own functions; its evidence against the host's store and rule book; the audit record's first half; one unit under every limit; the action (or, in a dry run, the answer the tool would give); the audit record's second half. Every refusal answers { success: false, error, details: { governance: { outcome, code, recordId } } } with a fixed sentence.

Type Parameters​

TInput​

TInput extends object

TOutput​

TOutput

Parameters​

tool​

ITool<TInput, TOutput>

The tool to govern. Its execute() receives the caller's context with governedAction added.

policy​

GovernedToolPolicy<TInput>

The action's name, its target, its limits and its evidence rule.

governance​

ActionGovernance

The actor, the mode, the limiter, the store, the rule book and the audit sink.

Returns​

ITool<TInput, TOutput>

A tool with the same name and members, hasSideEffects: true, and evidence required in its input.

Throws​

TypeError when the action name or a rule id is not a word of at most 19 characters, or no limit is given.