LLMs & Generative AI
Tool Calling & Agents
Tool calling lets a model request typed external operations. An agent is an application loop that lets the model plan, call tools, observe results, update state, and continue until done or stopped.
- Tools are typed capabilities exposed by your application
- The model should not own authorization
- Agents are control loops
- Long-horizon agents need budgets
- Agent evals measure task completion
state = initial_task
while not state.done and budget.remaining():
step = model.plan(state, available_tools)
if step.kind == "tool_call":
args = validate_schema(step.args)
authorize(user, step.tool, args)
result = run_tool(step.tool, args)
state = state.with_observation(result)
else:
return validate_answer(step.answer)| Concern | Application responsibility |
|---|---|
| Schema | Validate types, required fields, ranges |
| Authorization | Check user/session/tenant permissions |
| Side effects | Confirm risky actions, make idempotent |
| Observability | Log tool name, args summary, result, cost |
| Failure | Handle timeouts, retries, partial results |