跪拜 Guibai
← All articles
Tencent · Interview · Agent

A Tencent Interviewer's Agent Architecture Grilling, Answered from a Real CLI Implementation

By 沉默王二 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Agent interviews at major Chinese tech firms now test implementation details, not just definitions. Candidates who can trace every concept—ReAct, MCP, memory eviction, streaming tool-call assembly—to a real codebase stand out, and the bar is shifting from "used a framework" to "designed the control loop."

Summary

The interview opens with the boundary between LLMs and agents: the model decides, the framework executes, and the difference is whether a closed loop of decision-action-observation exists. From there, the candidate breaks down a ReAct agent into five concrete modules—model client, tool registry, executor, loop control, and context management—and walks through the full execution flow, including streaming parameter reassembly and a 20-turn hard limit.

Deeper questions probe the architecture of a from-scratch agent framework (six layers, with security as a first-class concern), the relationship between MCP and local tools (unified registry, namespace isolation, and virtual tools for resources), and a three-tier memory system spanning session, project, and global scopes. The candidate details compression triggers, deduplication, TTL-based expiration, and a hard rule that model-generated summaries never graduate to long-term memory.

Skill loading gets a quantified defense: a progressive disclosure mechanism keeps only a 4000-character index resident, loading full skill bodies on demand, which cuts context cost by 25x versus eager loading. The quality-assurance answer layers post-write syntax checks, a reviewer agent with retries, and prompt-level acceptance criteria—while openly admitting what hasn't been built yet.

Takeaways
An agent is an execution system around an LLM that adds tools, a reasoning loop, and memory; the LLM makes every decision but remains stateless.
A ReAct agent splits into five modules: model client, tool registry, tool executor, loop control (20-turn hard cap), and context management.
Streaming tool-call parameters arrive in fragments and must be reassembled by sequence number before JSON parsing, or the call fails.
Read-only tools can run 4 concurrently; write operations are strictly serial to prevent conflicts.
A from-scratch agent framework needs six layers: entry, agent (ReAct/plan/multi-agent), model, tool, memory/context, and security.
The security layer blacklists commands like sudo and rm -rf, enforces path guards, requires human confirmation for high-risk ops, and logs everything.
MCP tools are wrapped into the same registry as local tools and fed to the model via function calling; the model never knows which is remote.
Remote MCP tools get a service-name prefix for namespace isolation, and non-read-only tools require human confirmation before execution.
Short-term memory is a 100-message list compressed at 80% budget down to 55%, keeping the last 6 messages intact and summarizing earlier turns on user-message boundaries.
Long-term memory uses SQLite with hash deduplication, TTL expiration, 1000-entry eviction by importance/confidence/access count, and lexical recall weighted by freshness.
Model-generated summaries are never promoted to long-term memory; only user-explicitly-saved facts enter the store.
Progressive disclosure for Skills keeps a 4000-character index of top-5 matches resident and loads full skill bodies (5000-char cap) only on demand, reducing context cost 25x.
Skill matching uses weighted scoring on name, tags, and description, with bigram/trigram tokenization for Chinese recall.
Output quality is enforced via post-write syntax checks, a reviewer agent with up to 2 retries, and prompt-level acceptance criteria with self-review before delivery.
The candidate openly stated what wasn't implemented: universal hooks, structured output validation, and automatic main-loop retries.
Conclusions

Streaming tool-call parameter reassembly is a concrete failure mode that framework users rarely see but that every builder must handle; a half-arrived JSON fragment crashes the executor.

The hard separation between compression-generated summaries and long-term memory is a design choice with real consequences. Without it, the model's own paraphrasing gradually pollutes the knowledge base.

Quantifying the Skill loading mechanism—25x context savings—turns a design pattern into a defensible engineering decision, which is exactly what interviewers want to hear.

Admitting what isn't built yet (hooks, structured output validation, auto-retry) while detailing what is built signals engineering maturity more than pretending completeness.

The interviewer's closing study checklist is itself a syllabus: prefix caching economics, temperature/structured prompting, RAG chunking and hybrid search—all mapped to Claude Code's open-source ecosystem as a reference implementation.

Concepts & terms
ReAct
A loop pattern for AI agents that alternates between Reasoning (the LLM thinks about what to do) and Acting (it calls a tool), then feeds the result back into the next reasoning step, forming a closed decision-action-observation cycle.
MCP (Model Context Protocol)
An open protocol that turns tools into standalone services, allowing any MCP-compatible client to discover and call them. It solves the M×N integration problem between multiple applications and multiple tools by providing a standard interface for transport, tool description, and execution.
Progressive Disclosure
A loading strategy where only a lightweight index (names and short descriptions) of available skills is kept in context permanently; the full body of a skill is loaded only when the model explicitly requests it, dramatically reducing token consumption.
Function Calling
A capability of LLMs where the model outputs a structured JSON object specifying which function to call and with what parameters, rather than free-form text. The application executes the function and returns the result to the model.
Context Compression
A technique to keep message history within token limits by summarizing older conversation turns when the context window approaches its budget, preserving recent messages intact while condensing earlier ones into extractive summaries.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗