Dear Past Me: Three Agent Loop Mistakes That Cost a Day
Описание и применение
Агент, использующий LLM для ревью кода, может потерять день из‑за бесконечных вызовов инструментов, неверной обработки отсутствующих файлов и разрезанных JSON‑объектов. Внедрение бюджета цикла, подробных сообщений об ошибках и строгой проверки JSON позволяет остановить цикл и избежать лишних шагов.
Задача
An LLM-powered review agent can waste a day due to unbounded tool calls, missing file handling, and partial JSON parsing.
Результат
The agent loop now stops after a defined number of steps or tool calls, avoids retrying missing files, and only processes complete JSON tool calls, saving time and preventing infinite loops.
Рабочий процесс
- 1. Set a hard budget: cap maxSteps and maxToolCalls. 2. Track and abort on repeated identical tool calls. 3. Log each step as a structured event. 4. Return detailed missing file results with path, cwd, and retry hint. 5. Buffer tokens until stream signals done before parsing. 6. Validate tool call payloads against a schema and allowed set. 7. Reject or abort on schema violations or partial JSON.
Доказательства
Set a hard budget before the first call.
Return the path, the cwd, and a stop hint.
- Дата записи: 2026-09-09T18:01:40.860Z