Confirmation Policy
A ready-to-run example is available here!Confirmation policy controls whether actions require user approval before execution. They provide a simple way to ensure safe agent operation by requiring explicit permission for actions.
Setting Confirmation Policy
Set the confirmation policy on your conversation:AlwaysConfirm()- Require approval for all actionsNeverConfirm()- Execute all actions without approvalConfirmRisky()- Only require approval for risky actions (requires security analyzer)
Custom Confirmation Handler
Implement your approval logic by checking conversation status:Rejecting Actions
Provide feedback when rejecting to help the agent try a different approach:Ready-to-run Example Confirmation
Full confirmation example: examples/01_standalone_sdk/04_confirmation_mode_example.py
examples/01_standalone_sdk/04_confirmation_mode_example.py
The model name should follow the LiteLLM convention:
provider/model_name (e.g., anthropic/claude-sonnet-4-5-20250929, openai/gpt-4o).
The LLM_API_KEY should be the API key for your chosen provider.Security Analyzer
Security analyzer evaluates the risk of agent actions before execution, helping protect against potentially dangerous operations. They analyze each action and assign a security risk level:- LOW - Safe operations with minimal security impact
- MEDIUM - Moderate security impact, review recommended
- HIGH - Significant security impact, requires confirmation
- UNKNOWN - Risk level could not be determined
ConfirmRisky()) to determine whether user approval is needed before executing an action. This provides an additional layer of safety for autonomous agent operations.
LLM Security Analyzer
A ready-to-run example is available here!The LLMSecurityAnalyzer is the default implementation provided in the agent-sdk. It leverages the LLM’s understanding of action context to provide lightweight security analysis. The LLM can annotate actions with security risk levels during generation, which the analyzer then uses to make security decisions.
Security Analyzer Configuration
Create an LLM-based security analyzer to review actions before execution:- Reviews each action before execution
- Flags potentially dangerous operations
- Can be configured with custom security policy
- Uses a separate LLM to avoid conflicts with the main agent
Ready-to-run Example Security Analyzer
Full security analyzer example: examples/01_standalone_sdk/16_llm_security_analyzer.py
examples/01_standalone_sdk/16_llm_security_analyzer.py
The model name should follow the LiteLLM convention:
provider/model_name (e.g., anthropic/claude-sonnet-4-5-20250929, openai/gpt-4o).
The LLM_API_KEY should be the API key for your chosen provider.Custom Security Analyzer Implementation
You can extend the security analyzer functionality by creating your own implementation that inherits from the SecurityAnalyzerBase class. This allows you to implement custom security logic tailored to your specific requirements.Creating a Custom Analyzer
To create a custom security analyzer, inherit fromSecurityAnalyzerBase and implement the security_risk() method:
Configurable Security Policy
A ready-to-run example is available here!Agents use security policies to guide their risk assessment of actions. The SDK provides a default security policy template, but you can customize it to match your specific security requirements and guidelines.
Using Custom Security Policies
You can provide a custom security policy template when creating an agent:- Define organization-specific risk assessment guidelines
- Set custom thresholds for security risk levels
- Add domain-specific security rules
- Tailor risk evaluation to your use case
Ready-to-run Example Security Policy
Full configurable security policy example: examples/01_standalone_sdk/32_configurable_security_policy.py
examples/01_standalone_sdk/32_configurable_security_policy.py
The model name should follow the LiteLLM convention:
provider/model_name (e.g., anthropic/claude-sonnet-4-5-20250929, openai/gpt-4o).
The LLM_API_KEY should be the API key for your chosen provider.Next Steps
- Custom Tools - Build secure custom tools
- Custom Secrets - Secure credential management

