Exploring My Own Go Agent From Scratch
Ever since agents made it into the mainstream, I’ve been really interested in how they work. I’ve always wanted my own personal Jarvis, and now I feel like I have the chance to build one myself. At its score, it’s mechanics: a loop that observes input, decides what to do, acts, and repeats. At scale, things get much more complex, especially for user-facing products like ChatGPT or other AI coding assistants. What lies in between is a lot of lessons, techniques, and mechanics.
RoundTrip Logging Within Go’s http.Client
Ok, so let’s say you have an HTTP client where you need to get information from the request and response calls for logging or debugging reasons. One way to do this is to create a custom RoundTripper to handle said logging.
What is a RoundTripper?
A RoundTripper is an interface that implements the RoundTrip function which makes the HTTP request and response on behalf of the http.Client, within the client’s Do() function. There is a field on the client called Transport that holds the implementation. Go will use the default version if no custom RoundTripper is provided.