The loop
- Goal. You give the task: "Fix the failing test in
utils.py." - Think and choose. The model reads the context and picks an action, often a tool call.
- Act. The program runs the tool and captures the output.
- Observe. The output is added to the conversation.
- Repeat until the model says it's done or a step limit is hit.
What makes agents work well
- A model with solid tool calling. Some agents need it to work at all.
- Good tools. Small, well-described tools with clear errors.
- Feedback. Tests, linters and type checkers give the agent a way to check its own work.
- Guardrails. Ask before risky actions, like deleting files, running shell commands or spending money.
Cost and context
Each step re-sends the conversation, so input tokens grow fast over a long task. On luv13 input and output cost the same per token (see Pricing), so the total token count is what drives cost. Watch usage and cap the number of steps. See Conversation History.
Example
This is one step of an agent loop: the model gets a tool and decides whether to call it.
curl https://api.luv13.ai/v1/chat/completions \
-H "Authorization: Bearer $LUV13_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "luv13/glm-5.3-flash",
"messages": [{"role": "user", "content": "How many files are in the src folder?"}],
"tools": [{
"type": "function",
"function": {
"name": "list_files",
"description": "List files in a folder.",
"parameters": {"type": "object", "properties": {"path": {"type": "string"}}, "required": ["path"]}
}
}]
}'Your program would run list_files, send the result back, and call the API again. See Tool Calling on luv13 for what luv13 supports.
