What It Really Takes to Build an AI Agent: Core Engineering Skills Over Frameworks
This article explains why choosing an all-in-one framework is often the wrong starting point for building AI agents. It breaks down the four core engineering capabilities that determine whether an agent can ship and run reliably—planning, memory, retrieval-augmented generation, and tool calling with evaluation—and shows how each can be implemented with minimal custom code and general cloud services. Readers will learn how to make layered planning decisions, manage short-term context budgets, model long-term user preferences, tune retrieval chunking and routing, enforce safety constraints on tool calls, and build an evaluation loop that keeps quality measurable. The takeaway: master the capability checklist first, and treat the framework as a replaceable shell.
Introduction: Clearing Up the “Framework Dependency” Myth
When many teams kick off an agent project, their first instinct is to pick an all-in-one framework, then spend a large amount of time adapting to the framework’s abstraction layers. But what actually determines whether an agent can ship and run stably is not the framework itself. It is four underlying engineering capabilities: planning, memory, retrieval, and tool calling with evaluation. Each of these has well-established implementation paths in the industry, and the cost of building them yourself is far lower than most people expect. The benefits a framework brings usually come down to “convenience of assembly.”
It is worth stressing that this article does not point to any specific third-party product. It discusses general technical capabilities and engineering practices. When cloud-side capabilities are involved, only general categories are used, such as object storage, message queues, container platforms, logging services, and monitoring and alerting.
1. Planning: Understand the Boundaries, Not the Abstractions
The goal of a planning module is to let the model break “the problem to be solved” into executable steps. Common forms in the industry include workflow orchestration, chain-of-thought reasoning, and lightweight thinking modes. What they share is that they are all essentially about organizing a process, not black magic that must be bound to a particular framework.
The value of workflow orchestration lies in locking down deterministic steps. Take expression-style orchestration as an example: its core is to chain the input through several composable operators (prompt templates, model calls, parsers, retrievers) into a directed flow. Even without introducing any orchestration library, the same thing can be achieved in a few dozen lines of code:
def run_pipeline(query, retriever, llm, parser):need_kg = router(query) # whether external knowledge is neededctx = retriever(query) if need_kg else ""raw = llm(prompt(query, ctx))return parser(raw)
The barrier to entry for this code is extremely low, which shows that “orchestration” is not a moat. What really requires judgment is: which steps must execute deterministically, and which can be left to the model’s autonomous decisions.
Chain-of-thought methods deliver clear value in offline analysis and complex reasoning evaluation, but in user-facing online scenarios there are two hard constraints: latency and cost. Users cannot accept “thinking for tens of seconds before the first token appears.” So in engineering practice, a lightweight thinking mode is more common: limit the reasoning length, move complex reasoning to an offline stage, or trigger a second round of reasoning only when confidence is low.
The conclusion is clear: what you need to master for planning is “when to plan, and to what depth to plan,” not memorizing a particular framework’s API.
2. Memory: Short-Term Relies on Budgeting, Long-Term Relies on Modeling
Short-Term Memory: Context Budget Management
Short-term memory handles message organization across multiple turns of dialogue, and the goal is just two words: save money, save time. The approach is to first keep a complete copy of the session for auditing and replay, then trim it according to a policy before feeding it to the model. Common trimming strategies include:
- Drop the oldest messages by turn, keeping the most recent N turns;
- Dynamically truncate by token budget, prioritizing system instructions and the latest user intent;
- Filter retrieval results by relevance, removing low-scoring fragments;
- Summarize and compress long text, replacing the original with the summary.
def build_context(messages, budget=4000, keep_last=6):recent = messages[-keep_last:]summary = summarize(messages[:-keep_last]) # compress historyctx = [{"role": "system", "content": summary}] + recentreturn trim_by_token(ctx, budget)
There is no technical barrier here; generating a trimming function with a general-purpose AI coding tool takes only a few minutes. The difficulty lies in matching the strategy to the business: a customer service scenario needs to retain key entities like order numbers, while a Q&A scenario needs to retain premises the user has already clarified.
Long-Term Memory: Where the Real Differentiation Lies
Long-term memory addresses user preferences and long-term needs across sessions, such as language style, response length, area of expertise, and long-term goals. Its engineering difficulty is not in storage, but in three things:
- Write timing and content filtering: not all information is worth storing long-term, so you need criteria for judging “reusable preferences”;
- Conflict resolution and expiration management: preferences change, and old preferences must be able to be overwritten or expired;
- Precise recall and cross-talk prevention: recall only the preferences relevant to the current intent, avoiding bringing information from session A into session B.
The common industry approach is a dual channel of “structured profile + vector recall”: structured fields store stable preferences (such as language and length), while a vector store holds descriptive preferences (such as “prefers the conclusion first, then the derivation”). At recall time, first perform intent classification, then filter by category, and finally apply a relevance threshold.
def recall_preference(user_id, query):intent = classify_intent(query) # intent routingcand = vector_search(user_id, query, top_k=10) # semantic recallcand = [c for c in cand if c.category == intent]return [c for c in cand if c.score > 0.75] # threshold to prevent cross-talk
When long-term memory is done well, an agent’s personalization capability improves significantly. This is key to product differentiation, and it is also where most general-purpose solutions are still relatively weak today.
3. Retrieval-Augmented Generation: Mature Tools, Victory in Implementation Details
Retrieval-augmented generation is often thought of as overly complex. Broken down, there are only three things.
First, corpus chunking and knowledge organization. Chunk granularity determines recall quality: too small causes semantic breaks, too large causes noise and wasted tokens. In practice, people commonly chunk by heading hierarchy while keeping an overlap window; for strongly structured data, they extract entity relationships to form a knowledge graph, using the graph structure to handle multi-hop questions.
Second, retrieval routing, that is, deciding “whether to retrieve.” Simple small talk, pure calculation, and common-sense Q&A generate directly; only when internal knowledge, time-sensitive data, or precise numbers are involved does it go through retrieval. Routing can be rules plus a lightweight classifier, balancing latency and accuracy.
def router(query):if is_chitchat(query) or is_pure_math(query):return Falsereturn classifier.predict(query) == "need_kb"
Third, storage and approximate retrieval. Vector retrieval relies on approximate nearest neighbor algorithms to balance recall and latency, while graph structures are suited to relationship traversal. At the deployment level, index building and incremental updates should be separated to avoid writes affecting online queries.
What really opens up the gap is tuning: building a recall evaluation set, scanning chunking parameters, fusing hybrid retrieval (keyword plus semantic), integrating a reranking model, and verifying answer faithfulness. None of these steps has a “must use a particular framework” situation; a self-built setup can run through completely.
4. Tool Calling and Evaluation: What Determines Whether You Can Ship
Tool calling requires mastering four points: standardized tool descriptions (clear name, purpose, parameters, and constraints), parameter validation and idempotent design, failure retries and graceful degradation, and permissions and auditing. High-risk operations must have a second confirmation, and write operations must be rollback-capable.
The evaluation system is often overlooked but is the part that deserves the most attention. Its value shows in two ways: first, turning “it feels better” into quantifiable metrics, including task success rate, retrieval hit rate, answer faithfulness, latency, and cost per call; second, forming a regression defense, so that any adjustment to prompts or chunking strategy can be validated on a fixed evaluation set, avoiding repeated back-and-forth in the live experience.
The recommended minimum loop is: prepare on the order of a hundred labeled samples, covering both high-frequency and long-tail cases; run offline evaluation on every change; do sampled manual review online; and feed failed samples back into the evaluation set as new cases.
Conclusion: A Capability Checklist Before a Framework Checklist
What you must master to build an agent is layered decision-making in planning, budget management for short-term memory, preference modeling for long-term memory, chunking and routing tuning for retrieval augmentation, safety constraints for tool calling, and an evaluation loop that runs throughout. These capabilities can be self-built with a small amount of code, and can also be carried by general cloud capabilities such as container platforms, logging services, and monitoring and alerting. Make the capability checklist solid, and the framework is just a replaceable shell.
