Skip to main content

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.

Metadata

Release files for strands-neuraltrust 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for strands-neuraltrust 0.1.2
File Size Uploaded Provenance
strands_neuraltrust-0.1.2.tar.gz 203.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for strands-neuraltrust 0.1.2
File Interpreter ABI Platform
strands_neuraltrust-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 237.6 kB

Release files / strands_neuraltrust-0.1.2.tar.gz

Download URL strands_neuraltrust-0.1.2.tar.gz
Size 203.7 kB
Tags Source
SHA-256 checksum
How to use checksums
61ac7714b880a776b95d3dd711994fbeabd19a5b675c635d8e7fde5c744f74c6
BLAKE2b-256 checksum
How to use checksums
bc3ab07d05ac77463e0804f1f4be5cec49e5f9fa9e70144902c2f0541dca4550
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","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}

Release files / strands_neuraltrust-0.1.2-py3-none-any.whl

Download URL strands_neuraltrust-0.1.2-py3-none-any.whl
Size 33.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db52d6c267b2270ac26ef6a5ff28102d5c27f9bfa6ffea369fa765ec30f5baf1
BLAKE2b-256 checksum
How to use checksums
504d308feec62cf8a4b252f435d4fd6460f413f926d18b4efb6af932b0cd3feb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","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}

Security for strands-neuraltrust 0.1.2

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.

No provenance found

None of the files in this release were 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.

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