> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction

> Guide to extending LLMs with tool calling, comparing deterministic workflows and autonomous agents, and practical tips for building safe, instrumented tool-enabled AI applications

Welcome to this section on tools and workflows for large language models (LLMs).

Now that you understand how LLMs work under the hood, the next question is: how do we make them act? By default, LLMs generate text. When you give them tools—abilities like web search, database queries, API calls, or code execution—they become capable of real-world actions. In this lesson you'll learn the fundamentals of tool calling and build a simple tool-enabled application.

We'll also zoom out to the architectural level. Not every AI system needs to be an autonomous agent. Often a deterministic, predictable workflow is the better choice. This section explains the practical differences between AI workflows and AI agents, and when to select each design.

<Callout icon="lightbulb" color="#1CB2FE">
  Tool calling bridges LLM reasoning and real-world actions. Use it to extend models with controlled capabilities such as retrieving up-to-date data, performing calculations, or executing side-effecting tasks.
</Callout>

## Why tool calling matters

Tool calling transforms text-only models into systems that can:

* Query remote data sources (databases, vector stores).
* Retrieve live information (web search, news feeds).
* Integrate with third-party APIs (payment, booking, analytics).
* Execute code or scripts to perform computations or modify state.

This makes LLMs practical for applications like customer support assistants, automation pipelines, and data-enrichment tasks.

## Building a basic tool-calling application (high level)

A minimal tool-enabled app typically follows these steps:

1. Define the available tools
   * Each tool is an interface the model can call (e.g., `searchWeb(query)`, `queryDB(sql)`, `runScript(payload)`).
2. Provide tool descriptions to the model
   * Describe inputs, outputs, and when to use each tool.
3. Let the model decide between generating text and calling a tool
   * The model outputs a tool invocation or plain text.
4. Execute the tool and return results to the model
   * The tool runs in your environment; results are fed back into the model for further reasoning.
5. Repeat as needed until the task is complete

These steps let you keep control over permissions, logging, and failure handling while leveraging the model’s reasoning to orchestrate actions.

<Callout icon="warning" color="#FF6B6B">
  Always validate and sanitize inputs and outputs when executing tools. Tool calls can have side effects (database writes, payments, etc.), so use authentication, input filtering, and audit logs.
</Callout>

## Typical architecture patterns

* Model + Tool Executor: The model decides which tool to call; a secure executor runs the tool and returns results.
* Orchestrator Workflow: Deterministic pipelines call the model at specific steps for generation, validation, or transformation.
* Autonomous Agent: A loop where the model plans, acts (calls tools), observes results, and replans until a goal is reached.

## Workflows vs Agents — at a glance

| Approach | Description | Best for |
| - | - | - |
| Deterministic Workflow | Predefined steps where the model is invoked at controlled points (e.g., generate email, validate, send). | Compliance-sensitive systems, predictable automation, repeatable ETL. |
| Autonomous Agent | Model iteratively plans, acts, and observes to complete open-ended goals. | Research, exploratory automation, multi-step problem solving with uncertain paths. |

## When to choose which approach

* Choose deterministic workflows when you need predictability, auditability, and clear failure modes.
* Choose agents when tasks are open-ended and benefit from the model’s planning and iterative decision-making.
* Hybrid approaches work well: use deterministic workflows for critical steps and agents for exploratory subtasks.

## Practical tips

* Start small: give the model a focused set of tools and expand as you validate behavior.
* Use detailed tool descriptions and example invocations.
* Instrument every tool call (timestamps, user, inputs, outputs) for debugging and safety.
* Provide safety gates for destructive actions (manual approval, simulated dry-runs).

## What you'll learn in this lesson

* How tool calling extends LLM capabilities (search, database queries, API calls, code execution).
* How to implement a basic tool-calling application.
* The distinction between deterministic workflows and autonomous agents.
* Guidelines to choose the right architecture for your use case.

## Links and references

* [OpenAI: Tool Use Guide](https://platform.openai.com/docs/guides/tool-use)
* [Designing Reliable LLM Systems — Best Practices](https://example.com/llm-system-design) (conceptual guide)

By the end of this lesson, you'll have a clear mental model of how to structure AI systems that combine LLM reasoning with external tools, and you'll be ready to design and implement tool-enabled AI in your projects.

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/ai-agents-for-beginner-openclaw-case-study/module/5063e430-2631-48f3-b37f-4b3dd0d5c166/lesson/6130f588-2130-425b-89d1-5acebdae806c" />
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.