Agentic AI, Multi-Agent Systems and MCP

The agent loop, tools and memory, orchestration patterns, multi-agent designs and when to avoid them, the Model Context Protocol, and safety controls for agents that take actions.

What makes something an agent

An agent is an LLM-driven system that decides its own steps toward a goal: it plans, calls tools, observes results and iterates until done or stopped. Workflows with fixed steps that call an LLM are useful too, but they are not agents.

flowchart LR
  G[Goal from user] --> LLM[LLM: decide next step]
  LLM -->|tool call| T[Tools: search, APIs, code, DB]
  T -->|observation| LLM
  LLM -->|needs approval| H[Human approval]
  H --> LLM
  LLM -->|done| R[Result]
  MEM[(Memory: session, long-term)] <--> LLM

Patterns (simplest first)

Pattern Description Use when
Single LLM call Prompt → answer Classification, extraction, drafting
Workflow / chain Fixed sequence (retrieve → draft → check) Predictable processes
Router Classify request, send to specialized prompt/model Varied request types
Single agent with tools One model loops over tool calls Open-ended tasks with clear tools
Orchestrator-workers (multi-agent) Lead agent splits work, sub-agents work in parallel, results merged Broad research, parallelizable tasks
Evaluator-optimizer One model generates, another critiques, iterate Quality-critical generation

[!PRACTICE] Start with the simplest pattern that works. Multi-agent systems multiply tokens, latency and failure modes; use them when tasks are genuinely parallel or need separate context windows.

Model Context Protocol (MCP)

MCP is an open protocol (introduced by Anthropic in November 2024 and now governed under the Linux Foundation's Agentic AI Foundation) that standardizes how AI applications connect to tools and data. An MCP server exposes tools, resources and prompts; an MCP client inside the AI application (host) discovers and calls them over stdio or streamable HTTP. It replaces bespoke integrations per model/framework with one interface.

flowchart LR
  HOST[AI app / agent host<br/>MCP client] -- MCP --> S1[MCP server: ticketing]
  HOST -- MCP --> S2[MCP server: CRM]
  HOST -- MCP --> S3[MCP server: internal docs]
  S1 --> API1[Jira / ServiceNow API]
  S2 --> API2[Salesforce API]
  S3 --> IDX[(Search index)]

Enterprise MCP considerations: authenticate MCP servers with OAuth (per-user delegated access), run them behind a gateway with allowlists, review tool descriptions (tool poisoning risk), log every call, and version servers.

Memory

  • Short-term: conversation state within the context window (summarize when long).
  • Long-term: facts and preferences stored in a database/vector store with explicit write policies and user controls.
  • Episodic/task state: durable workflow state (e.g. Temporal, LangGraph checkpoints) so long tasks survive failures.

Safety controls for agents

  • Least-privilege tools with narrow scopes; separate read and write tools.
  • Human-in-the-loop for irreversible or high-impact actions.
  • Budgets: max steps, tokens, time and cost per task.
  • Sandboxed execution for code tools.
  • Full tracing of decisions and tool calls; replay for audits.

Frameworks and platforms (version-sensitive)

LangGraph, OpenAI Agents SDK, Claude Agent SDK, Google ADK, Microsoft Agent Framework (successor to Semantic Kernel/AutoGen), CrewAI, Spring AI; managed: Bedrock AgentCore, Vertex AI Agent Engine, Foundry Agent Service.

Interview questions and answers

When is a multi-agent design worse than a single agent?

When tasks are sequential and tightly coupled: coordination overhead, context loss between agents, higher cost and more failure points outweigh specialization. Multi-agent helps for parallel, separable subtasks.

How do you prevent an agent from doing something harmful?

Constrain capabilities (tools and scopes) rather than relying on instructions; enforce authorization outside the model; require approvals for risky actions; set budgets; monitor and be able to stop execution.