feat: introduce Reject variant of AskForApproval

This commit is contained in:
Michael Bolin
2026-02-17 21:06:37 -08:00
parent 31cbebd3c2
commit 7276d70d36
34 changed files with 1193 additions and 94 deletions
+13
View File
@@ -255,6 +255,19 @@ impl DeveloperInstructions {
None => APPROVAL_POLICY_ON_REQUEST_RULE.to_string(),
}
}
AskForApproval::Reject {
sandbox_approval,
rules,
mcp_elicitations,
} => {
format!(
"Approval policy is `reject`.\n\
- `sandbox_approval`: {sandbox_approval}\n\
- `rules`: {rules}\n\
- `mcp_elicitations`: {mcp_elicitations}\n\
When a category is `true`, requests in that category are auto-rejected instead of prompting the user."
)
}
};
DeveloperInstructions::new(text)
+49
View File
@@ -377,11 +377,60 @@ pub enum AskForApproval {
#[default]
OnRequest,
/// Fine-grained rejection controls for approval prompts.
///
/// When a field is `true`, prompts of that category are automatically
/// rejected instead of shown to the user.
Reject {
/// Reject approval prompts related to sandbox escalation.
sandbox_approval: bool,
/// Reject prompts triggered by execpolicy `prompt` rules.
rules: bool,
/// Reject MCP elicitation prompts.
mcp_elicitations: bool,
},
/// Never ask the user to approve commands. Failures are immediately returned
/// to the model, and never escalated to the user for approval.
Never,
}
impl AskForApproval {
/// Backward-compatible defaults for `approval_policy = "reject"` in
/// `config.toml`.
pub const fn reject_defaults() -> Self {
Self::Reject {
sandbox_approval: true,
rules: false,
mcp_elicitations: false,
}
}
pub const fn rejects_sandbox_approval(self) -> bool {
matches!(
self,
Self::Reject {
sandbox_approval: true,
..
}
)
}
pub const fn rejects_rules_approval(self) -> bool {
matches!(self, Self::Reject { rules: true, .. })
}
pub const fn rejects_mcp_elicitations(self) -> bool {
matches!(
self,
Self::Reject {
mcp_elicitations: true,
..
}
)
}
}
/// Represents whether outbound network access is available to the agent.
#[derive(
Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Display, Default, JsonSchema, TS,