Add tool payload firewall guardrail#1669
Open
RitwijParmar wants to merge 1 commit into
Open
Conversation
Signed-off-by: Ritwij Aryan Parmar <ritwij.aryan.parmar@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a concrete first-pass implementation for the agent tool-argument policy idea discussed in #1654:
tool-payload-firewallguardrail plugin for OpenAI-compatibletool_callshook_resultsfindings that can be used in eval/replay pipelinesThis is intentionally a lightweight local baseline rather than a full OPA/Rego runtime. My goal is to make the policy surface testable inside Portkey first, then leave room to evolve the same hook into Rego-backed validation if maintainers want that direction.
Why
Agent systems often cross the model boundary through tool calls: CRM writes, refunds, email sends, DB updates, and internal admin APIs. Prompt/response guardrails help, but they do not give teams a deterministic structural check over the tool-call arguments that an agent is about to execute.
This gives Portkey a gateway-native place to express policies like:
customer.ssnor*.api_keyanywhere inside tool argumentsVerification
npx jest plugins/tool-payload-firewall/scan.test.ts --runInBandnpx tsc --noEmit --pretty false --skipLibCheck plugins/tool-payload-firewall/scan.ts plugins/tool-payload-firewall/scan.test.tsnpm run build && node start-test.jssuccessfullyNote: repo-wide build currently emits existing TypeScript warnings in
src/providers/bytez/api.tsandsrc/providers/open-ai-base/index.ts; this patch does not touch those files.AI disclosure
I used an AI coding assistant to help draft and test this contribution. I reviewed the implementation before opening the PR.
Refs #1654