Find Related products on Amazon

Shop on Amazon

The Unreasonable Effectiveness of an LLM Agent Loop with Tool Use

Published on: 2025-07-07 12:33:44

The Unreasonable Effectiveness of an LLM Agent Loop with Tool Use 2025-05-15 by Philip Zeyliger My co-workers and I have been working on an AI Programming Assistant called Sketch for the last few months. The thing I've been most surprised by is how shockingly simple the main loop of using an LLM with tool use is: def loop(llm): msg = user_input() while True: output, tool_calls = llm(msg) print("Agent: ", output) if tool_calls: msg = [ handle_tool_call(tc) for tc in tool_calls ] else: msg = user_input() There's some pomp and circumstance to make the above work (here's the full script) ), but the core idea is the above 9 lines. Here, llm() is a function that sends the system prompt, the conversation so far, and the next message to the LLM API. Tool use is the fancy term for "the LLM returns some output that corresponds to a schema," and, in the full script, we tell the LLM (in its system prompt and tool description prompts) that it has access to bash . With just that one very gener ... Read full article.