Runnable notebooks showing how to integrate HiddenLayer AI Runtime Security into an agentic system, one per supported payload format, using the HiddenLayer Python SDK.
For the concept, see
runtime-security-agent-signals-walkthrough.md:
a data-flow diagram and walkthrough of the four boundaries, the per-message
signals, and the self-correction pattern.
python3 -m venv .venv && source .venv/bin/activate
pip install hiddenlayer-sdk python-dotenv jupyter
cat > .env <<'ENV'
HIDDENLAYER_CLIENT_ID=your-client-id
HIDDENLAYER_CLIENT_SECRET=your-client-secret
ENV
jupyter labGet credentials from the HiddenLayer console (Settings, API Keys). Each notebook runs top to bottom with no LLM provider configured.
Beta endpoint; the SDK emits a
BetaWarning.
Call client.runtime.evaluate_interaction() at each boundary where content
enters the model's context window (user prompt, tool call, tool result, final
answer). The arguments, all recommended for proper functionality:
interaction: the native provider payload you send to or receive from the modelmetadata:model,provider,requester_id,external_session_idhl_project_id: the project whose policy evaluates the interactionHL-Runtime-Session-Idheader: the same value across the run, so HiddenLayer groups the turns into one session
Each returned message carries analysis.signals (prompt_injection,
personally_identifiable_information, code, denial_of_service, guardrails,
url, language). Use the signals to decide what your agent does.
The notebook payloads are hardcoded so they run without an LLM provider. In your
agent you already build these payloads to call the model; to integrate, pass
those same payloads to evaluate_interaction at the matching boundaries. The SDK
call does not change, and the agent framework is your choice.
The notebooks show two ways to act on a detection:
- Self-correction: when a signal fires on untrusted input, withhold the flagged content and forward a short security notice built from the signals, so the model self-corrects without ever seeing it and the agent keeps running.
- Policy enforcement: craft HiddenLayer policy rules against these signals;
when a rule matches, the decision comes back on
outcome, so enforcement happens in the platform rather than your agent code.