Final Wrap-up
Summary (Part 1) · Prompt Engineering + Agent
Chapter 2 review · Part 1 of 2: core skills for designing a Message List, and the Agent engineering that takes AI from "saying" to "doing."
Part 1 · Context & Prompt
I. Context & Prompt Engineering
Core skills for designing the Message List
Three Context Overflow Strategies
Limited workspace — manage it deliberately
Truncation
Simple, but early messages are permanently lost — best for short-turn tools
Summarization
Balanced choice — requires an extra LLM call, suited for long-running conversations
Semantic Retrieval
Most precise — requires a vector system, optimal Token usage
6 Prompt Elements + 4 Advanced Techniques
Write Prompts like code
6 Elements: Role + Task + Context + Constraints + Examples + Format
4 Advanced Techniques: Few-Shot (learn format from examples), Chain of Thought (step-by-step reasoning), Constraints (word count / tone / banned words), Task Decomposition (break into steps)
4 Advanced Techniques: Few-Shot (learn format from examples), Chain of Thought (step-by-step reasoning), Constraints (word count / tone / banned words), Task Decomposition (break into steps)
Output Format Selection Principles
Choose format based on context
Streaming to user side → XML / plain text (incrementally parseable)
Backend consumption → YAML / JSON (YAML saves 15–30% Tokens)
Document / rich-text display → Markdown (render-friendly)
Backend consumption → YAML / JSON (YAML saves 15–30% Tokens)
Document / rich-text display → Markdown (render-friendly)
Part 2 · Agent Engineering
II. Agent Engineering
Taking AI from "saying" to "doing"
Four Core Agent Capabilities
🧭 Plan
Break complex tasks into executable steps
🔧 Tool Use
Call search, code execution, database, and APIs
🗃️ Memory
Short-term context + long-term vector database
🔄 Act / Reflect
Observe after acting — self-correct on failure
The Truth About Tool Calls
The model just outputs formatted text
1
System Prompt pre-defines the tool list, telling the model what tools are available
2
The model predicts a JSON string (not an actual call)
3
Framework code parses the JSON → makes the real API call → injects results back into context
Skill + Scaffolding
Making Agent reliable
Skill = process instructions + tool-call guidance, keeping the ReAct loop as short and efficient as possible
Scaffolding = timeout/retry + max-step limit + input/output validation + state machine + observability (logging).
An Agent without scaffolding is not reliable in production.
Scaffolding = timeout/retry + max-step limit + input/output validation + state machine + observability (logging).
An Agent without scaffolding is not reliable in production.
Chapter 2 Summary · Part 1 · Next: Cost Optimization + AI PM Comprehensive Understanding