Is your middleware request related to a problem? Please describe.
Production AI-native applications need immutable audit trails for compliance, debugging, and security forensics. The existing callback mechanism in Intercept allows ad-hoc logging, but there is no standardized, append-only audit layer across all middleware actions.
Proposed solution
Implement an AuditLogger middleware that is a pass-through (does not modify the prompt) and writes structured audit records for every intercepted prompt/response cycle.
API Design
// In an agent's middleware stack
public function middleware(): array
{
return [
new PromptInjectionGuard,
new PIIRedaction,
new AuditLogger(storage: 'database'), // or 'file'.
];
}
Configuration
'audit' => [
'driver' => env('INTERCEPT_AUDIT_DRIVER', 'database'), // database|file
'table' => 'intercept_audits',
'connection' => null,
'prune_days' => 90,
],
Schema
| Column |
Type |
Description |
id |
bigint |
PK |
agent |
string |
Agent class name |
middleware |
json |
Which middleware ran |
prompt_hash |
string |
xxh3 of prompt payload |
response_hash |
string |
xxh3 of response payload |
action_taken |
string |
blocked|redacted|allowed |
user_id |
nullable |
Authenticated user |
ip_address |
string |
Request IP |
duration_ms |
int |
Round-trip time |
created_at |
timestamp |
|
Describe the middleware's supported actions you'd like**
N/A
Additional context
This need is highlighted in production guides for Laravel AI SDK middleware, which recommend audit trails as a core production requirement alongside input validation.
Is your middleware request related to a problem? Please describe.
Production AI-native applications need immutable audit trails for compliance, debugging, and security forensics. The existing
callbackmechanism in Intercept allows ad-hoc logging, but there is no standardized, append-only audit layer across all middleware actions.Proposed solution
Implement an
AuditLoggermiddleware that is a pass-through (does not modify the prompt) and writes structured audit records for every intercepted prompt/response cycle.API Design
Configuration
Schema
idagentmiddlewareprompt_hashresponse_hashaction_takenuser_idip_addressduration_mscreated_atDescribe the middleware's supported actions you'd like**
N/A
Additional context
This need is highlighted in production guides for Laravel AI SDK middleware, which recommend audit trails as a core production requirement alongside input validation.