Skip to content

[New Plugin] NeuralTrust TrustGuard - #1772

Open
albertbausili wants to merge 2 commits into
Portkey-AI:mainfrom
albertbausili:feat/neuraltrust-guardrail
Open

albertbausili wants to merge 2 commits into
Portkey-AI:mainfrom
albertbausili:feat/neuraltrust-guardrail

Conversation

@albertbausili

@albertbausili albertbausili commented Aug 18, 2026

Copy link
Copy Markdown

Summary

  • Adds the neuraltrust.evaluate guardrail (issue [Feature] NeuralTrust TrustGuard #1771) so Portkey can send chat, completion, and Anthropic Messages traffic to TrustGuard POST /v1/evaluate.
  • Maps TrustGuard allow / block / report / transform onto Portkey verdicts. Transform writes back messages, completion prompt, or Anthropic system + tool_use. Block with hook deny: true is HTTP 446.
  • Fails closed by default (verdict: false, error: null) so an unreachable TrustGuard cannot be forgiven. unreachableFallback: fail_open restores house style for connect / timeout / 502 / 504 only.
  • Registers the handler in plugins/index.ts and lists neuraltrust in plugins_enabled. Credentials stay on the check (apiKey, optional collectorKey / apiBase).

Description:

  • New partner plugin: plugins/neuraltrust/ (manifest, handler, payload codec, tests, README)
  • Additive registration in plugins/index.ts
  • neuraltrust added to conf.json / conf.example.json plugins_enabled

Documentation:

Tests Run/Test cases added:

  • npx jest plugins/neuraltrust — 60 mocked tests (payload, transforms, fail-closed matrix, HTTP errors) plus optional live suite if .creds.json is present
  • npx prettier --check on the plugin files

Type of Change:

  • New feature (non-breaking change which adds functionality)

Test plan

  • npx jest plugins/neuraltrust (60/60, including the optional live TrustGuard call)
  • Before-request deny: true + TrustGuard block returns HTTP 446 and does not call the provider
  • allow / report still reach the model; transform redacts chat messages and completion prompt
  • Anthropic system and tool_use are preserved on extract/apply (unit coverage; not a live Anthropic provider run)
  • Missing apiKey and unreachable TrustGuard fail closed unless unreachableFallback is fail_open

Register neuraltrust.evaluate so Portkey can send chat, completion, and Anthropic Messages traffic to TrustGuard with fail-closed defaults.
albertbausili added a commit to NeuralTrust/docs that referenced this pull request Sep 2, 2026
Portkey now has an in-gateway plugin, `neuraltrust.evaluate`, registered on both
before_request_hooks and after_request_hooks. Unlike the BYOG webhook the page
documented, it holds the request body, so it consumes transformed_payload and is
the second gateway besides TrustGate that can redact.

It is contributed in Portkey-AI/gateway#1772 (issue #1771) and not yet in a
Portkey release, so the webhook stays as "Before the native plugin ships" — it is
the only path that works on Portkey Cloud today.

Coverage splits Portkey out of the boolean-verdict gateway rows it shared with
Kong, Apigee and Azure APIM, into LiteLLM's shape: redact conditional on both
surfaces, tool-level conditional throughout, since tool declarations and
tool_calls reach the payload where Portkey populates them and a transformed tool
call is written back request-level.

The fail-closed behaviour is the part worth documenting carefully, because the
plugin deliberately disagrees with the gateway. Portkey passes a check when it
returns a verdict OR when it errored and failOnError is unset, and failOnError
defaults to false — so an unreachable guardrail reported as an error would be
forgiven and traffic would flow uninspected. The plugin returns verdict:false
with error:null instead, which the engine cannot forgive, and reserves the
error-shaped result for unreachableFallback: fail_open.

Verified end to end against a locally built gateway: 446 with the provider never
called on a forced auth failure and on an unreachable endpoint, a masked payload
arriving at the provider from the before-hook, and a masked response reaching the
caller from the after-hook. Also documents two traps found while doing it —
`npm run build-plugins` drops every plugin missing from conf.json, and a streamed
response reaches the after-hook with no parsed body, so the output side is not
inspected at all rather than inspected late.
The plugin README and manifest carried no route to the fuller documentation, so
a reviewer or an operator configuring the guardrail had only this directory to go
on.

`apiKey.description` renders in the Portkey UI, and it did not say where the key
comes from. Pangea, Patronus, Qualifire, WalledAI and Lasso all answer that in
the same field, so this follows them rather than inventing a place for it.

README gains the setup guide and the endpoint contract, next to the paragraph
that describes the check.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant