Skip to main content

HiddenLayer MSFT Agent Framework Guardrails

License Python 3.10+

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 :white_check_mark: :white_check_mark: :white_check_mark:
Output Guardrails :white_check_mark: :white_check_mark: :white_check_mark:
Streaming Output Guardrails :white_check_mark: :x: :x:

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Support

For issues, questions, or contributions:

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)

Source distribution for hiddenlayer-msft-agent-framework-guardrails 0.1.0
File Size Uploaded
hiddenlayer_msft_agent_framework_guardrails-0.1.0.tar.gz 7.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hiddenlayer-msft-agent-framework-guardrails 0.1.0
File Interpreter ABI Platform
hiddenlayer_msft_agent_framework_guardrails-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.9 kB

Release files / hiddenlayer_msft_agent_framework_guardrails-0.1.0.tar.gz

Download URL hiddenlayer_msft_agent_framework_guardrails-0.1.0.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
75abce4fa90170dd5a0335d95cbb512615e4b811e50b2780dd691c941cbf0943
BLAKE2b-256 checksum
How to use checksums
ccc73e6599111002908606614a887be0908444a9dda8f90614a450713a59d98b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 10, 2026.

Transparency log

Release files / hiddenlayer_msft_agent_framework_guardrails-0.1.0-py3-none-any.whl

Download URL hiddenlayer_msft_agent_framework_guardrails-0.1.0-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ae693d9f1054c9d05f635636c2071ec39bc6cadff8caa21bb29c1cc6cb5d5eec
BLAKE2b-256 checksum
How to use checksums
ab78009bd1e9f4bc653021b399518fdd36785c753bc9cfb8b34ab10985c4aa48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 10, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page