inspect_ai.approval
Approvers
auto_approver
Automatically apply a decision to tool calls.
@approver(name="auto")
def auto_approver(decision: ApprovalDecision = "approve") -> ApproverdecisionApprovalDecision-
Decision to apply.
human_approver
Interactive human approver.
@approver(name="human")
def human_approver(
choices: list[ApprovalDecision] = ["approve", "reject", "terminate"],
) -> Approverchoiceslist[ApprovalDecision]-
Choices to present to human.
Types
Approver
Approve or reject a tool call.
class Approver(Protocol):
async def __call__(
self,
message: str,
call: ToolCall,
view: ToolCallView,
history: list[ChatMessage],
) -> Approvalmessagestr-
Message genreated by the model along with the tool call.
callToolCall-
The tool call to be approved.
viewToolCallView-
Custom rendering of tool context and call.
historylist[ChatMessage]-
The current conversation history.
Approval
Approval details (decision, explanation, etc.)
class Approval(BaseModel)Attributes
decisionApprovalDecision-
Approval decision.
modifiedToolCall | None-
Modified tool call for decision ‘modify’.
explanationstr | None-
Explanation for decision.
ApprovalDecision
Represents the possible decisions in an approval.
ApprovalDecision = Literal["approve", "modify", "reject", "terminate", "escalate"]ApprovalPolicy
Policy mapping approvers to tools.
@dataclass
class ApprovalPolicyAttributes
approverApprover-
Approver for policy.
toolsstr | list[str]-
Tools to use this approver for (can be full tool names or globs).
Decorator
approver
Decorator for registering approvers.
def approver(*args: Any, name: str | None = None, **attribs: Any) -> Any*argsAny-
Function returning Approver targeted by plain approver decorator without attributes (e.g.
@approver) namestr | None-
Optional name for approver. If the decorator has no name argument then the name of the function will be used to automatically assign a name.
**attribsAny-
Additional approver attributes.