HiddenLayer MSFT Agent Framework Guardrails
HiddenLayer MSFT Agent Framework Guardrails provides AI safety middleware for the Azure Agent Framework, enabling real-time detection and mitigation of malicious inputs, prompt injections, and unsafe AI agent behaviors.
Features
- Input Scanning: Analyze user messages for prompt injections and malicious content
- Output Filtering: Monitor and filter AI-generated responses
- Redaction Support: Automatically redact sensitive or unsafe content
- Streaming Compatible: Works with both streaming and non-streaming responses
- Easy Integration: Simple middleware integration with Azure Agent Framework
Installation
pip install hiddenlayer-msft-agent-framework-guardrails
Configuration
Set the following environment variables:
# Required: Your HiddenLayer API credentials
export HIDDENLAYER_API_ID="your-api-id"
export HIDDENLAYER_API_KEY="your-api-key"
# Optional: Project-specific configuration
export HIDDENLAYER_PROJECT_ID="your-project-id"
export HIDDENLAYER_REQUESTER_ID="your-app-name"
Usage
Basic Example
import asyncio
from agent_framework.openai import OpenAIChatClient
from hiddenlayer_msft_agent_framework_guardrails.middleware import (
HiddenlayerChatMiddleware,
HiddenLayerParams,
)
# Configure HiddenLayer parameters
params = HiddenLayerParams(model="gpt-4o-mini")
async def main():
# Create agent with HiddenLayer guardrails
agent = OpenAIChatClient().as_agent(
name="MyAgent",
model="gpt-4o-mini",
instructions="You are a helpful assistant.",
middleware=[
HiddenlayerChatMiddleware(params),
],
)
# Run query
query = "Hello!"
print(f"User: {query}")
result = await agent.run(query)
print(f"Result: {result}")
if __name__ == "__main__":
asyncio.run(main())
Advanced Examples
Streaming Responses
async def streaming_example():
agent = OpenAIChatClient().as_agent(
name="MyAgent",
instructions="You are a helpful assistant.",
middleware=[
HiddenlayerChatMiddleware(params),
],
)
query = "Hello!"
print(f"User: {query}")
print("Agent: ", end="", flush=True)
async for chunk in agent.run(query, stream=True):
if chunk.text:
print(chunk.text, end="", flush=True)
print()
Capability Matrix
| Alert | Block | Redact | |
|---|---|---|---|
| Input Guardrails | ✅ | ✅ | ✅ |
| Output Guardrails | ✅ | ✅ | ✅ |
| Streaming Output Guardrails | ✅ | ❌ | ❌ |
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Support
For issues, questions, or contributions:
- GitHub Issues: Report a bug or request a feature
- Email: sdks@hiddenlayer.com
Related Projects
Metadata
Release files for hiddenlayer-msft-agent-framework-guardrails 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hiddenlayer_msft_agent_framework_guardrails-0.1.0.tar.gz | 7.3 kB | With provenance |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hiddenlayer_msft_agent_framework_guardrails-0.1.0-py3-none-any.whl | Python 3 | none | any |
Total release size: 15.9 kB
Security for hiddenlayer-msft-agent-framework-guardrails 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.