The prompt your SDK sends is not the prompt you wrote A tool called "agenttap" created by a developer who discovered that SDKs often modify prompts before sending them to AI APIs, causing discrepancies between what developers think they're sending and what actually reaches the API. Agenttap is an httpx transport layer that intercepts outbound HTTP requests, captures the actual JSON payload sent over the wire, and allows developers to replay, diff, and debug these requests to catch unintended modifications like content normalization or leaked metadata. The tool works with any SDK that uses httpx (including Anthropic and OpenAI), adds approximately 0.4ms overhead per call, and includes features like a ring buffer for the last 500 records, response redaction, and disk persistence. A reply from Claude came back nonsense. The system prompt looked fine in my code. The messages looked fine in my logs. So I added a print messages right before client.messages.create ... . Still fine. I was looking in the wrong place. The SDK was building the request body. What hit the wire was not what I was printing. So I wrote a httpx transport that intercepts the outbound request, dumps the actual JSON, and lets me diff what I think I sent against what I actually sent. I called it agenttap . Here is the captured request for a call I thought was a clean two-turn conversation: { "model": "claude-opus-4-7", "max tokens": 1024, "system": "You are a careful code reviewer.", "messages": { "role": "user", "content": {"type": "text", "text": "Review this diff:\n\n diff\n+ foo\n "} }, { "role": "assistant", "content": "Looks fine to me." }, { "role": "user", "content": "What about edge cases?" } , "metadata": {"user id": "u 8821"} } Three things I did not write: {"type": "text", "text": ...} block. My code passed a plain string. The SDK normalized it.metadata.user id was leaking from a default I set in the client constructor six commits ago and forgot.None of these would have shown up in logs of my own variables. They only show up at the wire. pip install agenttap . Then: import httpx from agenttap import TapTransport from anthropic import Anthropic tap = TapTransport wrap=httpx.HTTPTransport client = Anthropic http client=httpx.Client transport=tap client.messages.create model="claude-opus-4-7", max tokens=256, messages= {"role": "user", "content": "hi"} , for record in tap.records: print record.request json print record.response status, record.duration ms, "ms" The transport sits underneath the SDK. It does not know or care that this is Anthropic. It works the same way with OpenAI's Python SDK, with the Google client, with anything that ends up calling httpx. It captures four things per call: authorization and x-api-key redacted to .The reason I built this was not just to look. I wanted to replay. from agenttap import replay Pin a captured request as a fixture tap.save "fixtures/review call.json" Later, replay the exact bytes resp = replay "fixtures/review call.json", api key=os.environ "ANTHROPIC API KEY" And diff two recordings: from agenttap import diff records a = tap.records 0 b = tap.records 1 print diff records a, b - messages 0 .content 0 .text: "Review this diff:..." + messages 0 .content 0 .text: "Review this PR:..." - metadata.user id: "u 8821" + metadata.user id: "u 4410" That diff caught a regression last week where a prompt template change added a stray newline. The output still looked plausible, but the deterministic eval drifted. The wire diff showed me the exact byte. Overhead per call when capturing in memory: about 0.4 ms on my laptop for a 2 KB body. The transport buffers the response body so streaming is slightly different. If you want to keep streaming responses streaming, pass capture response body=False and only the request side is recorded. Default ring buffer holds the last 500 records. You can flush to disk with tap.save all dir="taps/" and rotate. A few honest limits. claude-stream-rs or wire a separate handler.TapTransport redact headers= "x-my-auth" .If you are running agents in production and you have never looked at the literal JSON that left your process, do it once. You will find something. Repo: https://github.com/MukundaKatta/agenttap PyPI: pip install agenttap This is one of a small set of focused libraries I publish for AI agent plumbing snapshots, budgets, drift, repair . Built piece by piece from real incidents.