Repository navigation
Replaying recorded Anthropic SDK traffic offline, without touching your code #1923
xizhuomengcontin
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Sharing an approach for re-running code that uses this SDK without calling the API again — no changes to your source, no mocking layer.
Disclosure: I work on the tool (OrcaReplay, Apache-2.0, no paid tier).
How it works
The SDK reads
ANTHROPIC_BASE_URLfrom the environment, so a local proxy can capture the exchange with the client left exactly as written:The replay serves the verbatim recorded bytes, so the SDK's own deserialisation and SSE handling run for real rather than being bypassed — which is where hand-written fixtures usually drift.
There is a check for this SDK in my integration matrix that records against a stub origin, kills the origin, replays, and asserts the numbers, so a break shows up as a failing build.
One thing worth knowing if you proxy Anthropic-speaking tools
Not every tool that talks to the Anthropic API reads
ANTHROPIC_BASE_URL. While building harness support I found goose readsANTHROPIC_HOSTand ignoresANTHROPIC_BASE_URLentirely — a proxy addressed only by the documented variable receives nothing, and the run looks fine. Mentioning it because if you are debugging "why is my Anthropic traffic not going through my proxy", the variable name is worth checking first.Scope
Good for: deterministic re-runs, CI without API keys or spend, chasing one bad response repeatedly.
Not: a mocking library — you record a real exchange first, you cannot author one. And
egress=blockedmeans model-provider egress; the rest of the program still does real work. It is not a sandbox.Happy to answer anything about the capture.
All reactions