Skip to content

Commit 2fb55f9

Browse files
docs: Add configurable security policy documentation
Add documentation for custom security policy templates that allow users to define organization-specific risk assessment guidelines. Relates to OpenHands/software-agent-sdk#427
1 parent 4954bed commit 2fb55f9

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

sdk/guides/security.mdx

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,55 @@ agent = Agent(llm=llm, tools=tools, security_analyzer=security_analyzer)
442442

443443
For more details on the base class implementation, see the [source code](https://github.com/OpenHands/software-agent-sdk/blob/main/openhands-sdk/openhands/sdk/security/analyzer.py).
444444

445+
---
446+
447+
## Configurable Security Policy
448+
449+
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.
450+
451+
<Note>
452+
Full configurable security policy example: [examples/01_standalone_sdk/28_configurable_security_policy.py](https://github.com/OpenHands/software-agent-sdk/blob/main/examples/01_standalone_sdk/28_configurable_security_policy.py)
453+
</Note>
454+
455+
### Security Policy Example
456+
457+
Define custom security risk guidelines for your agent:
458+
459+
```python icon="python" expandable examples/01_standalone_sdk/28_configurable_security_policy.py
460+
```
461+
462+
```bash Running the Example
463+
export LLM_API_KEY="your-api-key"
464+
cd agent-sdk
465+
uv run python examples/01_standalone_sdk/28_configurable_security_policy.py
466+
```
467+
468+
### Using Custom Security Policies
469+
470+
You can provide a custom security policy template when creating an agent:
471+
472+
```python highlight={10-11}
473+
from openhands.sdk import Agent, LLM
474+
from pathlib import Path
475+
476+
llm = LLM(
477+
usage_id="agent",
478+
model="anthropic/claude-sonnet-4-5-20250929",
479+
api_key=SecretStr(api_key),
480+
)
481+
482+
# Provide a custom security policy template file
483+
agent = Agent(llm=llm, tools=tools, security_policy_filename="my_security_policy.j2")
484+
```
485+
486+
Custom security policies allow you to:
487+
- Define organization-specific risk assessment guidelines
488+
- Set custom thresholds for security risk levels
489+
- Add domain-specific security rules
490+
- Tailor risk evaluation to your use case
491+
492+
The security policy is provided as a Jinja2 template that gets rendered into the agent's system prompt, guiding how it evaluates the security risk of its actions.
493+
445494
## Next Steps
446495

447496
- **[Custom Tools](/sdk/guides/custom-tools)** - Build secure custom tools

0 commit comments

Comments
 (0)