Skip to content

Agent loop ​

The agent loop is a workflow chat with loop:. It calls tools over many rounds until the model gives a final answer. kdeps run runs it like any other resource. The default model is local, so it needs no API key and runs offline.

text
input -> chat (loop:) -> tool rounds -> answer -> next resource

Write one ​

yaml
# workflow.yaml
apiVersion: kdeps.io/v1
kind: Workflow
metadata:
  name: assistant
  description: An agent that works on the files of this folder
  version: "1.0.0"
  targetActionId: assistant
deploy:
  input:
    sources: [interactive]   # kdeps run opens a prompt; each line is one turn
yaml
# resources/assistant.yaml
actionId: assistant
name: Assistant
chat:
  model:
    name: llama3.2:1b                  # local llamafile; set backend: for a cloud provider
  context:
    prompt: "{{ input('message') }}"
  loop:
    tools: [read_file, edit_file, list_files, search_local, bash_exec]   # empty offers every built-in tool
    maxRounds: 25                      # tool rounds per request
    session: "{{ get('session') }}"    # one stored conversation across requests

Run kdeps new my-agent --template assistant to get these two files. Then run it:

bash
cd my-agent
kdeps run workflow.yaml   # or bare: kdeps

The same chat serves an HTTP API, a bot, or a file when you change sources:. See Input sources.

What the loop adds ​

TopicPage
Built-in tool catalog and permission modesBuilt-in tools
Tool calls that a model writes as textFenced tools
Shell execution and background jobsShell execution
The subagent toolSubagents
Independent review of the answerJudge panel
One-time exceptions for a denied tool callApproval tokens
Persistent memoryPersistent memory
Skills and KDEPS.md instructionsSkills and instructions
Limits and thresholds as YAMLReactive LLM events

Every key is under the chat in the workflow. The full list is in the chat resource reference.

See also ​

kdeps has the Apache 2.0 License.