---
title: "Comment by Kartik N V J K on \"Day 00: Learn AI agents by building one, in 30 days\" | Hashnode"
description: "Building cartographer's loop by hand in forty lines of raw HTTP, before any SDK, is the approach I wish more guides took. When I hand-rolled mine, the detail th"
url: "https://hashnode.com/posts/pilot-thirty-days-one-agent/6ac4990972f4e3cdcb5f87f2/comment/6ac695995f0354844ab4418b"
---

[Discussion](https://hashnode.com/posts/pilot-thirty-days-one-agent/6ac4990972f4e3cdcb5f87f2)

Comment [Day 00: Learn AI agents by building one, in 30 days](https://hashnode.com/posts/pilot-thirty-days-one-agent/6ac4990972f4e3cdcb5f87f2)

[Kartik N V J K](https://hashnode.com/@kartik-nvj)

[Oct 7](https://hashnode.com/posts/pilot-thirty-days-one-agent/6ac4990972f4e3cdcb5f87f2/comment/6ac695995f0354844ab4418b)

Building cartographer's loop by hand in forty lines of raw HTTP, before any SDK, is the approach I wish more guides took. When I hand-rolled mine, the detail that clicked was the stop-reason field: a truncated answer and a finished one look identical until you check it yourself. Do you handle tool-call failures in the week-one loop, or defer them to the week-four hardening part?

[Harshavardhan Katkam](https://hashnode.com/@harshakatkam)

[Oct 8](https://hashnode.com/posts/pilot-thirty-days-one-agent/6ac4990972f4e3cdcb5f87f2/comment/6ac695995f0354844ab4418b#reply-6ac73ddf23ed085b3a0a6c23)

Thanks, Kartik. The stop-reason trap is a good one; a truncated answer that looks finished is exactly the kind of bug the series is about.

Tool-call failures are handled in week one, not deferred. On day 06 a bad call doesn't crash the loop: an invented tool name, arguments cut off mid-JSON, or a wrong parameter go back to the model as the tool's result, an error message listing what's valid, so it can correct itself next turn. The loop is also capped at a fixed number of turns, so a model that keeps calling tools can't run forever.

Week four's hardening (day 28) is about the failures that don't raise anything: a run that finishes cleanly with a map that's quietly wrong.

On truncation: day 05 sets max\_tokens so a cut-off answer surfaces as malformed JSON rather than passing as finished. You've convinced me it's worth checking finish\_reason explicitly as well.
