跪拜 Guibai
← All articles
Backend · AI Programming · Artificial Intelligence

LLM, Token, Context, Prompt, RAG, MCP, Skill, Agent: How AI's Core Concepts Fit Together

By Shepherd ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

The AI stack has matured past single-model calls into a multi-component system. Understanding how these pieces divide labor—and where each one breaks—is what separates a brittle prototype from a production system that can retrieve, reason, and act reliably.

Summary

An LLM is a probabilistic prediction engine that serves as the reasoning hub, but it cannot access the outside world or execute actions on its own. Token is the basic unit of cost, speed, and capacity, while Context is the dynamically assembled temporary workspace the model sees for each request. Prompt structures the task, RAG retrieves external knowledge to ground answers, and MCP standardizes tool connections to cut integration complexity from M×N to M+N.

Skill packages stable processes, templates, and scripts into reusable modules for things like code review or security checklists. Agent ties everything together into a planning-memory-tools loop that breaks down goals, calls tools, observes results, and iterates until a task is complete. A ReAct-style agent skeleton shows the core cycle: decide, act, observe, repeat.

Common pitfalls include assuming bigger context windows always help, treating RAG as a universal knowledge fix, or believing every task needs an agent. The real shift is organizing the model, context, knowledge, tools, and process into a single coherent system.

Takeaways
An LLM is a next-token prediction engine; it does not access the world, execute actions, or guarantee factual accuracy on its own.
Token count directly drives API cost, latency, and how much fits in a context window—roughly 1 token ≈ 0.75 English words or 1.5–2 Chinese characters.
Context is a temporary, dynamically assembled workspace, not permanent memory; noise, order, and token budget all affect output quality.
Prompt quality hinges on including persona, task, context, output format, and constraints—not just a question.
RAG splits answering into retrieval then generation, giving the model up-to-date or private knowledge but remaining vulnerable to bad retrieval, poor chunking, and low-quality documents.
MCP is a unified protocol that reduces tool-integration complexity from M×N to M+N, but it does not make the model smarter or fix poorly described tools.
Skill packages stable SOPs, templates, and scripts into version-controlled, reusable modules; it suits rules that change infrequently, while RAG suits fast-changing information.
An Agent is an LLM plus planning, memory, and tools that runs a think-act-observe loop until a goal is met or a step limit is hit.
Agent reliability, cost, tool design, and safety boundaries are the real engineering challenges—not getting a loop to run once.
The whole stack works together: Prompt expresses the goal, Context assembles the workspace, LLM reasons, RAG fetches missing knowledge, MCP calls tools, Skill reuses process, and Agent drives the multi-step execution.
Conclusions

The M×N-to-M+N framing for MCP is a crisp way to explain why a protocol layer matters: without it, every new AI client and every new tool multiplies integration work.

Treating Context as a budgeted, noise-sensitive workspace—not an infinite bucket—reframes the engineering problem from 'how to fit everything' to 'what to leave out and where to place it.'

The three-layer memory model (working, short-term, long-term) maps cleanly onto existing infrastructure: context window, session store, and vector DB or external storage.

Skill vs. RAG is a useful stability heuristic: if the content changes weekly, it belongs in a retrievable document store; if it's stable for months, bake it into a Skill module.

Calling an Agent an 'executor' rather than a 'consultant' captures the leap from single-turn Q&A to multi-step goal-driven loops—and explains why reliability and cost control become the hard problems.

Concepts & terms
LLM (Large Language Model)
A probabilistic prediction engine trained on massive text corpora that generates output by repeatedly predicting the next most likely token. It serves as the reasoning hub of an AI system but has no direct access to external tools or real-time data.
Token
The smallest unit of text the model processes. Text is split into tokens, mapped to numeric IDs, and converted to vectors. Token count determines API cost, latency, and how much information fits in a context window.
Context Window
The temporary, dynamically assembled set of tokens a model can 'see' during a single inference call. It is not permanent memory; it carries the current task, history, retrieved documents, tool results, and system rules.
Prompt
A structured instruction to the model that typically includes persona, task description, context, output format, constraints, and optional examples. It translates a vague user intent into executable input.
RAG (Retrieval-Augmented Generation)
A pattern that splits answering into two stages: retrieve relevant documents from an external knowledge base, then feed them into the context so the model can generate a grounded answer. It addresses knowledge cutoffs and hallucinations but depends on retrieval quality.
MCP (Model Context Protocol)
A unified protocol that standardizes how AI clients connect to external tools, resources, and prompt templates. It reduces integration complexity from M×N to M+N, analogous to a USB standard for AI tooling.
Skill
A reusable, version-controlled module that packages a standard operating procedure, templates, scripts, and reference materials. It is suited for stable domain rules like code review checklists or release processes.
Agent
An execution system that combines an LLM with planning, memory, and tools. It runs a think-act-observe loop, breaking down goals, calling tools, and iterating until a task is complete or a limit is reached.
ReAct (Reasoning + Acting)
A classic Agent pattern where the model alternates between reasoning about the next step, executing an action via a tool, and observing the result, forming a closed loop that drives multi-step task completion.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗