cd /news/developer-tools/the-prompt-your-sdk-sends-is-not-the… · home topics developer-tools article
[ARTICLE · art-4279] src=dev.to pub= topic=developer-tools verified=true sentiment=· neutral

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.

read3 min views7 publishedMay 21, 2026

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
tap.save("fixtures/review_call.json")
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))
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.
── more in #developer-tools 4 stories · sorted by recency
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/the-prompt-your-sdk-…] indexed:0 read:3min 2026-05-21 ·