inspect_ai.approval

Approvers

auto_approver

Automatically apply a decision to tool calls.

@approver(name="auto")
def auto_approver(decision: ApprovalDecision = "approve") -> Approver
decision ApprovalDecision

Decision to apply.

human_approver

Interactive human approver.

@approver(name="human")
def human_approver(
    choices: list[ApprovalDecision] = ["approve", "reject", "terminate"],
) -> Approver
choices list[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,
        state: TaskState | None = None,
    ) -> Approval
message str

Message genreated by the model along with the tool call.

call ToolCall

The tool call to be approved.

view ToolCallView

Custom rendering of tool context and call.

state TaskState | None

The current task state, if available.

Approval

Approval details (decision, explanation, etc.)

class Approval(BaseModel)

Attributes

decision ApprovalDecision

Approval decision.

modified ToolCall | None

Modified tool call for decision ‘modify’.

explanation str | 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 ApprovalPolicy

Attributes

approver Approver

Approver for policy.

tools str | 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
*args Any

Function returning Approver targeted by plain approver decorator without attributes (e.g. @approver)

name str | 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.

**attribs Any

Additional approver attributes.