The Unreasonable Effectiveness of an LLM Agent Loop with Tool Use
philz.dev·7h
💬Prompt Engineering
Preview
Report Post
  • May 15, 2025

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 …

Similar Posts

Loading similar posts...