# AI Agents With Tools — Artificial Intelligence

Source: https://www.skillbyai.com/en/artificial-intelligence/m-agents

> Language models that plan and act.

## The agent idea, returned

Modern **AI agents** wrap a language model in a loop: it reads the goal and context, decides on an action (call a tool such as search, a calculator, a database or code execution), observes the result, and continues until done. This brings back the classic agent framework from the start of this course, with an LLM as the decision-maker. Agents can automate multi-step tasks, but they also compound errors, can be manipulated by malicious content (prompt injection) and need limits: narrow tool permissions, approval for risky actions, step budgets and evaluation.

## An agent loop (sketch)

The classic perceive-decide-act cycle with an LLM. Not run here.

```python
state = {"goal": user_goal, "observations": []}
for step in range(MAX_STEPS):                      # budget: never loop forever
    action = llm_decide(state)                     # e.g. {"tool": "search", "args": {...}} or {"final": "..."}
    if "final" in action:
        return action["final"]
    if needs_approval(action):
        action = ask_human(action)                 # risky actions need a person
    result = run_tool(action)                      # tools with least privilege
    state["observations"].append(result)
return "stopped: step budget reached"
```

## Budget every loop

Limit steps, tokens and time per task; an agent without limits can run up costs or repeat mistakes.

**Quiz:** What do modern AI agents add to a language model?

- [ ] Removal of all safety limits
- [ ] A larger font
- [ ] A faster keyboard
- [x] A loop of deciding, calling tools and observing results

*Answer:* A loop of deciding, calling tools and observing results. Perceive, decide, act, with tools.
