LLM agent loop template

How a tool-using agent plans, calls tools, observes results and updates memory until the goal is met, with guardrails.

Use this templateFree, opens in your browser. No sign-up.

LLM agent loop template
Tools
Memory
Guardrails
User goal
LLM: plan the next step from goal + memory
Goal met?
Final answer to the user
Pick a tool + arguments (tool call)
Run the tool (sandboxed)
Observe result or error
Update memory / scratchpad
search_docs(query)
run_sql(query), read-only
create_ticket(title, body)
http_get(url) on an allow-list
Short-term: conversation + scratchpad
Long-term: vector store of past tasks
Summarize when context is 80% full
Max 15 steps or $0.50 per task
Human approval before any write action
Trace every tool call and result
LLM agent loop
yes
no
loop
The LLM agent loop template as it opens in Kelvo: 8 boxes, 1 decision among them, 10 sticky notes and 8 links, in 3 sections.

What's on the board

Tools
search_docs(query) · run_sql(query), read-only · create_ticket(title, body) · http_get(url) on an allow-list
Memory
Short-term: conversation + scratchpad · Long-term: vector store of past tasks · Summarize when context is 80% full
Guardrails
Max 15 steps or $0.50 per task · Human approval before any write action · Trace every tool call and result

Also on the board

  • User goal
  • LLM: plan the next step from goal + memory
  • Goal met?
  • Final answer to the user
  • Pick a tool + arguments (tool call)
  • Run the tool (sandboxed)
  • Observe result or error
  • Update memory / scratchpad

How to use this template

  1. Click Use this template. It opens in the Kelvo app as a new board, saved in your browser.
  2. Double-click any box to change its text. Replace the examples with your own content.
  3. Sketch, then convert. Draw boxes and arrows with the pen, select the strokes and click Convert sketch: they become real boxes and links.
  4. Ask Kelvo right on the board (Pro). With Pro, type @kelvo and what you want in any box or text, for example “@kelvo add error handling”, and press Enter. The change is made there and the request disappears; ⌘Z undoes it.
  5. Keep the prompt next to the diagram. Add a code block from the Insert (+) menu for prompts, schemas or config, right beside the boxes they belong to.

Good for

  • ai
  • llm
  • agents
  • tool calling
  • architecture
  • Explaining an LLM feature's architecture to engineers and stakeholders
  • Deciding between prompting, retrieval and fine-tuning
  • Planning evaluations and risks before launch

Related templates

  • LLM application architecture template previewLLM application architecture

    Production building blocks around a model: gateway, guardrails, orchestrator, cache, vector DB, tools and observability.

  • Multi-agent orchestration template previewMulti-agent orchestration

    An orchestrator agent splits a goal across specialist agents with their own tools, then a reviewer agent checks the result.

  • RAG pipeline template previewRAG pipeline

    Retrieval-augmented generation end to end: ingest and embed documents offline, then retrieve, rerank and answer with citations.

  • Prompt design canvas template previewPrompt design canvas

    Design a production prompt piece by piece — role, context, task, constraints, examples, output format — plus test cases.

  • AWS three-tier web app template previewAWS three-tier web app

    A highly available web app on AWS: DNS and CDN, load balancer, auto-scaled app servers and Multi-AZ database in a VPC.

  • C4 system context diagram template previewC4 system context diagram

    C4 level 1: the system in scope, the people who use it and the external systems it depends on, with a legend.

All ai and machine learning diagram templates · All templates

Use the LLM agent loop template