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.
skip 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.4

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.4
File Size Uploaded Provenance
strands_neuraltrust-0.1.4.tar.gz 204.3 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 238.3 kB

Release files / strands_neuraltrust-0.1.4.tar.gz

Download URL strands_neuraltrust-0.1.4.tar.gz
Size 204.3 kB
Tags Source
SHA-256 checksum
How to use checksums
cd1a708b0f0a569cc0fb2d85b46efdb9ad8365bd835846934cd9c294cfcf29aa
BLAKE2b-256 checksum
How to use checksums
80b3702096b2db7c56b7356368140b232ccf46abe7bce99e877d496fc40b9c6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","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.4-py3-none-any.whl

Download URL strands_neuraltrust-0.1.4-py3-none-any.whl
Size 34.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5dc95167750ca39cc3700d69fa6ea9a8a9d82652d64e5467298a3a06b1fbf39c
BLAKE2b-256 checksum
How to use checksums
50a87b80a95631481f08b9569234b4271ef67e9972a6c29329faaa913bedc269
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","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.4

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