Skip to main content

Crate agenttap

Crate agenttap 

Source
Expand description

Wire-level prompt introspection for LLM SDK calls.

agenttap records the exact request/response pairs flying out to your LLM provider, with Authorization, x-api-key, and known credential patterns scrubbed by default. v0.1 provides the data types and the redactor; with the reqwest feature it also installs as a [reqwest_middleware::Middleware].

§Quick start (manual recording)

use agenttap::{Tap, Redactor};
use serde_json::json;

let tap = Tap::new();

// Record manually after each call:
let req_headers: Vec<(String, String)> = vec![
    ("authorization".into(), "Bearer sk-ant-thiseekrit1234567890".into()),
    ("content-type".into(), "application/json".into()),
];
let resp_headers: Vec<(String, String)> = Vec::new();
tap.record(
    "POST",
    "https://api.anthropic.com/v1/messages",
    req_headers,
    Some(json!({"model": "claude", "messages": [{"role": "user", "content": "hi"}]})),
    200,
    resp_headers,
    None,
    420,
);

let last = tap.last().unwrap();
assert_eq!(last.request_headers["authorization"], "***REDACTED***");

Structs§

Redactor
Scrubs sensitive headers and credential-shaped strings.
Tap
Records LLM SDK HTTP traffic with redaction.
TappedCall
One captured request/response pair, redacted.

Constants§

DEFAULT_SENSITIVE_HEADERS
Default lower-cased header names whose values are scrubbed.
DEFAULT_VALUE_PATTERNS
Default regex patterns for credential-like strings inside bodies.

Functions§

diff
Unified diff of two captured request bodies. Useful for “why did this work yesterday and not today?”