Feature/resilience#162
Merged
Merged
Conversation
Owner
|
@Gabegi very cool! I'll see about getting this into the sdk in the next day or so. Very much appreciated. Really like the README writeup. |
This was
linked to
issues
Oct 24, 2025
This was referenced May 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hey! Sorry for the delay on this one, been swamped with other stuff.
What's this PR about?
Adds
IRequestInterceptorsupport so you can hook into the HTTP pipeline for custom retry logic, logging, metrics, etc. - without pulling in heavy dependencies or setting up DI.Why though?
Sometimes you just want to add some retry logic or log requests without having to wire up
Microsoft.Extensions.Http.Resilienceor spin up a whole DI container. This gives you a simple, lightweight way to intercept HTTP calls.What's in here?
Core changes:
IRequestInterceptorinterface with proper cancellation token supportrequestInterceptorparam toAnthropicClient(fully backward compatible)BaseEndpoint's HTTP pipelineExample implementations (ready to use or customize):
RetryInterceptor- exponential backoff, respectsRetry-Afterheaders, handles 408/429/5xx errorsLoggingInterceptor- logs requests/responses with timing, correlation IDs, and sensible size limitsDocs:
Quick example
Backward compatibility?
✅ Yep, totally backward compatible. The interceptor is optional - if you don't use it, everything works exactly like before.
Testing