strands-neuraltrust
Integrate NeuralTrust TrustGuard with Strands Agents to evaluate prompts, conversation history, model responses, tool arguments, and tool results against your policies.
Install
pip install strands-neuraltrust
or:
uv add strands-neuraltrust
Configure
Create an Application collector in NeuralTrust, assign its policy, and obtain its API key and your TrustGuard deployment URL. The API key identifies the collector; no separate collector ID or key is needed.
Set these variables before starting your application. The telemetry setting must be in place before creating any Strands agent or tracer:
export TRUSTGUARD_API_KEY='<collector-api-key>'
export TRUSTGUARD_BASE_URL='<your-trustguard-deployment-url>'
export OTEL_SEMCONV_STABILITY_OPT_IN='gen_ai_unredacted_attributes='
Pass your configured, stateless Strands Model to a guarded invocation:
import os
from strands.models import Model
from strands_neuraltrust import GuardedAgent, TrustGuardClient, TrustGuardConfig
async def answer(model: Model, prompt: str) -> str:
config = TrustGuardConfig(
api_key=os.environ["TRUSTGUARD_API_KEY"],
base_url=os.environ["TRUSTGUARD_BASE_URL"],
)
async with TrustGuardClient(config) as evaluator:
agent = GuardedAgent(model=model, client=evaluator)
result = await agent.invoke_async(prompt)
return result.text
Configure provider credentials and model selection in your application. Pass
registered Strands tools with GuardedAgent(..., tools=[your_tool]) to evaluate
their arguments before execution and their completed results before the next
model call. Tool-result checks cannot undo effects a tool has already produced.
| Setting | Purpose |
|---|---|
TrustGuardConfig.api_key |
Required collector API key. |
TrustGuardConfig.base_url |
Required HTTPS deployment root; the client appends /v1/evaluate. |
TrustGuardConfig.timeout |
Evaluation request timeout in seconds. |
GuardedAgent.session_id |
Optional session identifier for evaluation records. |
GuardedAgent.consumer_id |
Optional consumer identifier for evaluation records. |
The example reads environment variables explicitly; TrustGuardConfig does not
discover them automatically. The client context closes owned HTTP clients. For
synchronous code, use agent.invoke(prompt) inside with TrustGuardClient(config).
Keep the agent and evaluator alive together for a multi-turn conversation. Create
a new agent after any failed or cancelled invocation.
Verdicts
| TrustGuard | Integration behavior |
|---|---|
allow |
Continue with the assessed content. |
report |
Continue and record the decision. |
transform |
Apply a validated replacement to supported text or JSON. |
block |
Stop with TrustGuardBlocked. |
ask |
Stop with TrustGuardApprovalRequired; interactive resume is unsupported. |
| Evaluation failure or invalid response | Stop with a typed TrustGuardError. |
GuardedResult.text contains the accepted final text. GuardedResult.decisions
contains content-free stage and status records. Raw findings and model events
are not exposed through the result.
Agent integration
| API | Use it when |
|---|---|
GuardedAgent |
You want complete, checked text responses with sequential tools and controlled callbacks. |
TrustGuardIntervention |
You manage a native Strands Agent and its execution settings, callbacks, and telemetry. |
Both paths evaluate supported content at invocation, model, and tool boundaries. By default, each boundary uses structured and text assessments so text-oriented detectors can also inspect history, tool content, and supported JSON values. Both assessments must pass before staged changes are applied.
Streaming and failures
GuardedAgent returns completed responses through invoke and invoke_async;
it does not expose a token stream. With a native agent, intervention checks do
not prevent raw SDK callbacks or streaming consumers from seeing content before
evaluation completes.
Evaluation errors fail closed. Models and tools remain trusted application code. Configure provider logging and other telemetry sinks separately; the Strands trace setting does not redact every sink or the separate system-prompt attribute.
See the official integration guide for native-agent examples, full configuration, supported content, and security boundaries.
Develop
uv sync --locked --all-groups
uv run --locked ruff check .
uv run --locked ruff format --check .
uv run --locked mypy
uv run --locked pytest -q
Run the self-contained example without credentials or live services:
OTEL_SEMCONV_STABILITY_OPT_IN='gen_ai_unredacted_attributes=' uv run --locked python examples/offline.py
Contributions follow the NeuralTrust contribution guidelines. CI and release automation use NeuralTrust's shared workflows. Stable releases are published to PyPI; development publishing uses the internal registry when enabled.
License
Licensed under the MIT License.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file strands_neuraltrust-0.1.1.tar.gz.
File metadata
- Download URL: strands_neuraltrust-0.1.1.tar.gz
- Upload date:
- Size: 202.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.11 {"installer":{"name":"uv","version":"0.12.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62d93b6a7bfade7f181a56c8dc62cfe6da5bb1cca333d7e0b2055952d560abd5
|
|
| MD5 |
457821eeb570ea088f87e8140b76a3b8
|
|
| BLAKE2b-256 |
24ad9bc17350f521b72c2c42e52229dff237c98d7dac5ac7b79ac090badea19b
|
File details
Details for the file strands_neuraltrust-0.1.1-py3-none-any.whl.
File metadata
- Download URL: strands_neuraltrust-0.1.1-py3-none-any.whl
- Upload date:
- Size: 33.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.11 {"installer":{"name":"uv","version":"0.12.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d1121f1342e67221c60d14e465badcda39499531c4616a7973ce5a11eb82092
|
|
| MD5 |
43188469315ffc726346e15dfb8affe1
|
|
| BLAKE2b-256 |
d220f883dd117a9379dec712d00b6541f73c9700c3b85456d39b64fd3d69819b
|