跪拜 Guibai
← All articles
Frontend · Backend · Agent

The 34 Concepts That Separate Prompt Tweaking from Building Real Agents

By iDao技术魔方 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

The jump from prompting a chatbot to fielding an autonomous agent in production is gated by a dense set of interconnected concepts—Token, RAG, ReAct, MCP, Harness—that most developers encounter piecemeal. A single map that ties them into one thread, with explicit cost and failure-mode notes for each, turns months of scattered reading into a weekend of orientation.

Summary

LLMs are pure text-in, text-out functions. Every capability that looks like memory, tool use, or web access is a shell built around that function. This guide arranges 34 core concepts along that insight: Token economics, Context Windows and Lost in the Middle, the Agent loop (LLM + Actions + Loop), ReAct and Self-Refine patterns, RAG and the chunking/hybrid-search/reranking pipeline, Reflexion's cross-trial memory, MCP as the USB interface for tools, A2A for agent-to-agent communication, and the three-layer engineering stack of Prompt, Context, and Harness Engineering.

Production concerns get equal weight. Eval sets are non-negotiable—an Agent without them is code without tests. Observability means logging every LLM call and tool invocation so bugs can be replayed, not guessed at. Prompt Caching cuts costs up to 90% in long-context, repeated-query scenarios. On security, the Lethal Trifecta (access to private data, exposure to untrusted content, ability to communicate externally) is the framework for spotting dangerous architectures before they ship.

The guide closes with a verified learning path: write Skills in Claude Code, build a ReAct Agent, add RAG, then layer on Eval and observability before attempting multi-agent systems.

Takeaways
An LLM is a pure function: text in, text out. It has no memory, no internet access, and no sense of time unless those are supplied externally.
Token counts drive billing, latency, and context-window limits; using English abbreviations over verbose Chinese can meaningfully cut production costs.
Lost in the Middle means LLMs forget content in the center of long contexts—place critical instructions at the start and end of prompts.
An Agent is defined by three elements: an LLM for reasoning, Actions (tools) for doing, and a Loop that cycles until the goal is met or budget runs out.
ReAct is the most common Agent loop pattern (Thought → Action → Observation), but it is not the only one; CodeAct and computer-use are also Agents.
Structured Output via JSON schema enforcement is the baseline for Agent-LLM communication; free-text returns break state transfer and tool-call parsing.
RAG is an inference-time data-insertion architecture, not training. When documents change, rebuild the index—model weights stay untouched.
Chunking strategy, hybrid search (semantic + BM25), and a cross-encoder reranking step form the standard production RAG quality stack.
Contextual Retrieval prepends a document-level summary to each chunk before embedding, solving the 'this snippet is meaningless alone' problem.
Reflexion differs from Self-Refine by persisting lessons across trials in an episodic memory store, enabling cumulative improvement over tasks.
MCP standardizes how tools connect to LLMs (the USB interface); A2A standardizes how agents talk to each other. They are sister protocols.
Claude Code Skills auto-load when their frontmatter description matches the current context; writing descriptions that start with 'Use when…' maximizes trigger accuracy.
An Agent without an Eval set is like code without tests. Run evals on every prompt change, model swap, or RAG adjustment.
Observability means logging every LLM call, tool invocation, and intermediate result so production bugs can be replayed rather than guessed at.
Prompt Caching can cut LLM costs up to 90% in RAG scenarios where system prompts and fixed document prefixes repeat across queries.
The Lethal Trifecta—access to private data, exposure to untrusted content, and external communication—is the core threat model for prompt injection exfiltration.
Harness Engineering (the execution and control layer) is the real moat of most Agent products, not the underlying model.
Context Engineering—choosing exactly what goes into the context window—now outweighs Prompt Engineering in determining Agent output quality.
Conclusions

Framing the LLM as a pure function upfront is a pedagogical power move: it makes every subsequent concept—RAG, Memory, Tool Use—read as an engineering workaround rather than magic, which is the correct mental model for debugging production failures.

The guide's emphasis on Context Engineering over Prompt Engineering reflects a 2026 consensus that is still underappreciated by beginners, who tend to obsess over prompt wording while ignoring the quality of retrieved chunks and memory.

Calling out that ReAct is a pattern, not the definition of Agent, pushes back against a common conflation in tutorials that treat the two as synonymous.

The Lethal Trifecta from Simon Willison is a compact, actionable threat model that every developer wiring an Agent to email or Slack should internalize before shipping.

Placing Eval and Observability as the first production steps—not afterthoughts—correctly frames them as prerequisites to iteration, not polish for mature systems.

The three-layer engineering stack (Prompt, Context, Harness) gives teams a shared vocabulary for dividing work and identifying where their quality problems actually live.

Concepts & terms
Token
The sub-word unit LLMs process; ~1.3 tokens per English word, ~1.5–2 per Chinese character. All billing, context windows, and latency are measured in tokens.
Lost in the Middle
The phenomenon where LLMs forget content in the center of long contexts while remembering the beginning and end well. Mitigated by placing critical instructions at the extremes.
Chain-of-Thought (CoT)
A prompting technique that makes the LLM output reasoning steps before the final answer, improving accuracy on multi-step tasks at the cost of higher token usage.
ReAct
Reasoning + Acting: the classic Agent loop pattern of Thought → Action → Observation, repeating until a final answer is reached. The foundation of most Agent frameworks.
RAG (Retrieval-Augmented Generation)
An inference-time architecture that retrieves relevant documents from a vector database and inserts them into the prompt, giving the LLM access to private or up-to-date knowledge without retraining.
Hybrid Search
Combining semantic (embedding-based) search with keyword (BM25) search, then merging results. The default approach for production RAG systems.
Reranking
A two-stage retrieval pattern: a fast first pass fetches many candidates, then a slower, more accurate cross-encoder model re-ranks them into a smaller set for the LLM.
Contextual Retrieval
Anthropic's method of prepending a document-level context summary to each chunk before embedding, so the chunk carries its surrounding meaning into the vector store.
Reflexion
An Agent reflection pattern that persists lessons across trials in an episodic memory store, enabling cumulative improvement rather than single-session self-correction.
MCP (Model Context Protocol)
Anthropic's open protocol that standardizes how external tools connect to LLMs, analogous to a USB interface. Governed by the Linux Foundation.
A2A (Agent-to-Agent Protocol)
Google-initiated protocol for agent-to-agent communication, the sister standard to MCP. MCP handles agent↔tool; A2A handles agent↔agent.
Lethal Trifecta
Simon Willison's security concept: an Agent that simultaneously has access to private data, exposure to untrusted content, and external communication capability is vulnerable to prompt injection data exfiltration.
Harness Engineering
The execution and control layer of an Agent—loop logic, tool registration, context management, permissions, retries, circuit breakers. The code that is neither model weights nor prompts.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗