feat(agent): add opt-in content safety checks for requests, tools, and output (T32) #177
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 331 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.347
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #177"
general
weight: 0.35
yuluo-yx
Contributing to ARGI: add an opt-in content-safety pipeline for request ingress, tool arguments and results, and final output. Fixes #135.
Describe what this PR does / why we need it
PII detection on model text does not cover tool arguments, tool results, cached receipts, child results, return-direct payloads, or a secret split across streaming chunks. This PR adds an opt-in content-safety gate that applications compose onto the existing message hook, tool interceptor, and streaming interceptor. Default hooks, public APIs, and the default stream path are unchanged.
Does this pull request fix one issue?
Fixes #135
Describe how you did it
ContentSafetyGatechecks configured stages (REQUEST_INGRESS,MODEL_EGRESS,TOOL_ARGS,TOOL_RESULT,FINAL_OUTPUT,RETURN_DIRECT,CHILD_RESULT,RECEIPT) and applies allow, block, redact, or require-review. Detector timeout and failure follow the configured policy and return a structured status. Audit and logs record stage, action, reason, and detector only.ContentSafetyToolInterceptorchecks arguments before dispatch. A blocked or require-review call is not dispatched. A redacted argument is dispatched only whenContentSafetyArgumentReviewaccepts it; otherwise the transform is rejected. Results, receipts, child results, and return-direct payloads are checked before an outer interceptor can persist them.ContentSafetyModelHookapplies the same stages to user, tool, child, receipt, and assistant messages, and drops blocked assistant tool calls.ContentSafetyStreamingInterceptorwithholds an incomplete secret prefix and replaces a completed secret before release. require-review setsargi.contentSafety.reviewand does not add a new approval system.Describe how to verify it
15 tests, 0 failures: tool arguments are checked when model text is clean and a block skips dispatch; PII in arguments is checked; tool result, receipt, child result, and return-direct share the configured check; an unreviewed argument transform is rejected; require-review does not dispatch; timeout and detector failure return a structured block status; audit text omits the payload; a secret split across chunks is not emitted; safe text after a blocked secret is released; a reviewed transform is dispatched.
Special notes for reviews
No new dependencies. Core does not import Redis or Extensions. Register the tool interceptor inside result eviction (later in the interceptor list) so persisted text is already checked.