Skip to content

AI Agents

An AI agent is a workflow step that can reason about a goal, choose tools, inspect results, and decide what to do next. It is useful when the path to the answer is not always the same.

Do not use an agent just because a workflow uses AI. Use an agent when the workflow needs decision-making. For predictable transformations, a direct LLM chain is usually simpler and easier to test.

Most agents follow the same loop:

flowchart TD
  Goal["Goal + instructions"] --> Observe["Observe available data"]
  Observe --> Decide["Decide next action"]
  Decide --> Tool{"Need a tool?"}
  Tool -->|Yes| Call["Call tool"]
  Call --> Result["Read tool result"]
  Result --> Decide
  Tool -->|No| Answer["Return final answer"]
  Decide --> Stop{"Limit reached or unsafe?"}
  Stop -->|Yes| Fallback["Stop with partial result or error"]

  style Decide fill:#e1f5fe,stroke:#0277bd
  style Stop fill:#ffebee,stroke:#c62828

The loop is powerful, but it must be bounded. Give agents clear goals, tool access, stopping conditions, and output expectations.

Use this when the model should transform known input into known output: summarize text, classify content, draft a message, or rewrite a field.

It is not really an agent loop. It is the best default for predictable AI steps.

Use an agent when:

  • The workflow does not know in advance which tool is needed.
  • The task needs multiple steps and intermediate decisions.
  • The model should inspect results before continuing.
  • The workflow can tolerate some variability.

Avoid an agent when:

  • The workflow is a fixed transformation.
  • The output must follow a strict schema and no tool choice is needed.
  • A wrong action would be expensive or destructive.
  • The task can be solved with a direct node chain.
Design questionWhy it matters
What is the exact goal?Vague goals produce wandering tool calls
What data can the agent see?Missing context leads to guesses
Which tools can it use?Too many tools increase wrong choices
When should it stop?Prevents loops and runaway execution
What should the output look like?Makes downstream nodes reliable
How will you evaluate it?Catches regressions and hallucinations
flowchart LR
  Trigger["User starts research"] --> Agent["Tools Agent"]
  Agent --> Text["Get page text"]
  Agent --> Wiki["Wikipedia Query"]
  Agent --> Http["Http Request"]
  Agent --> Final["Structured report"]

  style Agent fill:#e1f5fe,stroke:#0277bd

The agent should not be told “research this.” A stronger instruction is:

Find three source-backed facts about this company. Use page text first, then Wikipedia if the page lacks enough context. Return a short report with source URLs.

That instruction gives the agent a goal, tool preference, stopping condition, and output shape.