My agent builds Google Forms from a sentence. Three things I got badly wrong.
I ship a Chrome extension where you type "make me a 10-question onboarding survey" and an agent writes the whole thing into Google Forms through the Forms API. Three things I got wrong building it, each of which cost real money before I noticed.
- Strict schema validation let a stuck model burn my budget.
My tool schema says requests is an array. On long batches the model would send the whole thing as a JSON string instead. I rejected it, which was correct, and which was also the mistake. The model can't see why it got rejected, so it rewrites the same payload smaller and smaller. One "add 20 questions" turn spent nine rounds and about 150k tokens before it gave up and told the user the API was broken.
Two fixes. Parse the string if it's a string, since that's unambiguous and costs nothing. And when you do reject something, name the mistake the model is actually making rather than handing back the parser error. "Expected double-quoted property name at position 827" tells it nothing it can act on. "Check that location sits INSIDE createItem next to item" tells it everything.
- A round cap is not a circuit breaker.
I had a max-rounds limit and it was far too loose to catch a model that's stuck. Nothing about the fourth identical failure is more informative than the third. I now stop after 3 consecutive tool failures, reset by any success, so a long correct run never gets punished. The final round tells the model it's the final round, so it explains itself to the user instead of dying silently.
- Retrying failed requests is usually wrong, with exactly one exception.
Never retry an HTTP error. The model already ran, you already paid, and you'll double-bill. But fetch rejecting with a TypeError means no response headers arrived at all, so the request never reached the server and nothing was billed. That single case is safe to retry, and it's the one that matters, because it's what a dropped connection looks like to your user.
Happy to go deeper on any of it.