Agentic AI is a model that chooses a tool, sees the result, and takes another step until the task is done or something stops it. A chatbot never gets that far. A copilot asks you to accept the step.
The loop
Claude Code’s Agent SDK and OpenAI’s function-calling guide describe the same cycle with different tool names.
flowchart LR
prompt[Prompt plus tool list] --> decide[Model responds]
decide --> tools[Host runs tool calls]
tools --> decide
decide --> done[Text, no tool call]
- Receive. The model gets the prompt, instructions, tool definitions, and history.
- Act. It returns text, tool calls, or both. A call is a name plus arguments. The host runs it. The model does not.
- Observe. The host sends the tool output back: request, call, execute, send the output, next response.
- Repeat. The next turn can change approach because the output is now in context. Claude Code stops when a response has no tool calls, then returns the text plus usage.
- Stop from outside. A permission denial, a read-only mode, a human prompt, or a tool you never connected.
Planning is sometimes a separate mode. Cursor Plan mode and Claude Code’s plan permission mode research without editing. The ChatGPT desktop app documents /plan before /goal when that goal feature is available.
Tools and function calling
On the OpenAI API a function tool is a JSON schema (name, description, parameters). The model may return a call. Your code runs it and sends the output back, tied to that call. Unknown names do not run. The guide’s strict example sets additionalProperties: false.
Claude Code’s loop includes Read, Edit, Write, Glob, Grep, Bash, WebSearch, WebFetch, and Agent. MCP adds tools. See the Claude Code cheat sheet. Cursor Agent searches, edits, runs shell, uses the web and a browser, and can ask questions. Its overview states there is no limit on tool calls per task. It asks before an MCP tool unless a Run Mode allowlists it.
n8n’s AI Agent needs a chat model and at least one tool (another workflow, custom code, HTTP, or a service such as Wikipedia). From n8n 1.82.0 the old agent-type picker is deprecated; nodes behave as a Tools Agent. The v1 picker leaves in n8n 3.0. A GPT Action is one OpenAPI document, and the user may have to approve the call.
Memory and planning
- Transcript. Prior turns and tool results come back on the next request. That is why a long task fills the window. The ChatGPT desktop app documents
/compactwhen that command is available. ChatGPT’s saved memory is a different store: the prompting cheat sheet. - Files the agent reads first. Codex reads
AGENTS.mdbefore work: global file under the Codex home (default~/.codex), then one file per directory from the repo root to the working directory. Later files override earlier ones. Combined size stops atproject_doc_max_bytes, 32 KiB by default./initscaffolds a starter file. - n8n memory. Memory sub-nodes attach only to the AI Agent, not to chain nodes. Simple Memory keeps a slice of the session. Redis, Postgres, Motorhead, Xata, and Zep are the documented persistent stores. Chat Memory Manager inserts, loads, or deletes messages when you need a step those nodes do not offer.
- Subagent context. Cursor subagents start clean. The parent must put facts in the handoff. You can resume one by agent id.
Cursor Plan mode (Shift+Tab, or /plan in the CLI) writes a plan you edit before a build. Ask mode (/ask or --mode=ask) does not edit. Claude Code plan and Codex --sandbox read-only stay read-only until an approval policy allows more.
Multi-agent patterns
One agent, many tools. The default in Claude Code, Cursor Agent, Codex, and the n8n Tools Agent. The model picks the next tool. You decide which tools exist.
Plan, then act. A read-only pass writes the steps. A second pass may edit. Cursor stores the plan and lets you build it after review. The desktop app documents /plan before /goal when goal mode is available. The gate is between intent and edits.
Subagents. A side task runs in its own context and returns a summary. Claude Code gives each subagent its own prompt, tool list, and permission mode. Omit tools and it receives every tool subagents can use. tools: ["Read", "Grep", "Glob"] cannot edit. Its requests count toward the same usage limits as the parent. Setup is the subagents guide. In plan mode the subagent stays in plan mode, with an exception the docs state for agent-team teammates.
Cursor subagents are foreground or background (is_background: true). readonly: true blocks edits and state-changing shell. They inherit MCP tools, except cloud subagents, which use the team’s servers on Cursor’s agent site.
n8n puts the agent in a workflow. A tool can be another workflow, so the graph stays outside the model. The tool docs list a “human fallback” example that uses Call n8n Workflow Tool. Build a normal workflow first: first n8n workflow. Claude Code hooks can block a tool call before it runs. That is separate from a subagent: hooks guide.
Where it fails
Mismatched tool calls. The model emits a name and arguments. A vague description yields a wrong name or a bad type. The MCP Python SDK rejects a bad type before your function runs. On a raw function-calling API, that check is yours. The JSON is a request, not a finished action.
Runaway loops. The stop is “no more tool calls.” Cursor’s overview states there is no cap per task. Claude Code subagents add requests on the same usage pool.
Context growth. Each turn resends history. A full file or a long log makes the next turn larger. Hand the noisy step to a subagent, or return only the lines that matter.
Shared trust. MCP servers in one session share model context, so a buggy server can steer the other tools. Local stdio is not a sandbox. See MCP servers explained.
Quiet overreach. Codex workspace-write can edit and run local commands inside the workspace without a prompt. Approval starts when it must leave that boundary or use the network.
Guardrails
| Control | Where it is documented | What it stops |
|---|---|---|
| Permission prompt | Claude Code default; Cursor MCP approval |
A call runs only after a person or an allow rule |
| Read-only / plan | Claude Code plan; Codex --sandbox read-only; Cursor Ask |
Edits |
| Sandbox plus approval | Codex workspace-write with on-request, untrusted, or never |
Leaving the workspace, network, or untrusted commands, depending on the pair |
| Narrow tool list | Subagent tools; n8n tool nodes you attach |
Calls you never connected |
| Hook or reviewer | Claude Code hooks; Codex approvals_reviewer = auto_review; Cursor Auto-review |
A call reviewed before it runs |
| Human step | Claude Code AskUserQuestion; Cursor questions; an n8n workflow tool |
The loop waits |
Codex full access is danger-full-access plus approval_policy = never, also --dangerously-bypass-approvals-and-sandbox. Do not use that as a default. codex exec starts read-only unless you pass --sandbox workspace-write. A subagent gets bypassPermissions only when the parent session is already in that mode.
When to pick each
Use a chatbot when you will run every command yourself. The prompting cheat sheet is enough. Use a copilot (Cursor Ask, Codex read-only) when you want a suggestion and a human accept. Use an agent when the task is find, patch, test, and read the failure: Claude Code, Cursor Agent, or Codex in a repo, or n8n when the steps are HTTP and other services. Use a subagent when one step is noisy research and the parent should only see the summary.
Migration path
- If the deliverable is text, stop. No tools.
- Add one read-only tool. Reject unknown names. Log every call.
- Allow edits in one directory only. Codex:
--sandbox workspace-write --ask-for-approval on-request. Claude Code: stay ondefault. Cursor: keep the MCP approval prompt. - Move the noisy step to a read-only subagent. Put standing rules in
AGENTS.md. Add a hook before any tool that deletes or posts.
FAQ
What is the difference between a chatbot and an AI agent?
A chatbot returns text. An agent also calls tools, reads the result, and chooses the next step. A copilot suggests a change you accept. What matters is whether the product can act without a new prompt.
What is an agent loop?
The model requests a tool call, the host runs it, and the result returns on the next turn. It stops when the model sends no further call, or when a permission rule or a cost limit stops it. Claude Code’s SDK describes receive, evaluate, execute tools, repeat, then a result.
How do subagents differ from one agent with many tools?
A subagent has its own context, instructions, and often a shorter tool list. Claude Code and Cursor use that split so search dumps stay out of the parent thread. The parent sees the summary.
Why do agents invent tool calls or keep looping?
The model picks a tool from its description, so a vague description or a missing argument check yields a call you should reject. The loop continues while calls keep coming. Cursor documents no cap on tool calls per task.
Is the n8n AI Agent node the same as Claude Code?
No. n8n’s AI Agent is a workflow node with a chat model and at least one tool. Claude Code is a coding agent with file, search, and shell tools in a project. Both are agents, with different permission models.
How this guide was verified
Written by hand from the official documentation, every command re-checked, and reviewed a second time before publishing. Last reviewed on .
Official sources read for this article
- platform.openai.com/docs/guides/function-calling
- code.claude.com/docs/en/agent-sdk/agent-loop
- code.claude.com/docs/en/sub-agents
- developers.openai.com/codex/sandboxing
- developers.openai.com/codex/agent-approvals-security
- developers.openai.com/codex/guides/agents-md
- cursor.com/docs/agent/overview
- cursor.com/docs/agent/plan-mode
- cursor.com/docs/subagents
- docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.agent/
- docs.n8n.io/build/integrate-ai/understand-ai-components/how-tools-work
- docs.n8n.io/build/integrate-ai/understand-ai-components/how-memory-works

