Chapter 2 · AI Harness

24 core slides · Context Engineering / Prompt / Security Defense / Agent / Cost Optimization + Closing Reflection + Chapter Summary

← Back to Table of Contents
Chapter 2
AI
Harness
From context management to Agent deployment, from cost control to security defense — this is the practical AI Harness handbook for AI Product Managers.
Sections
1
Context Engineering
2
Prompt Engineering
3
Security: Prompt Attack & Defense
4
Agent Engineering
5
Cost Optimization
Instructor Tip
Click any slide on the right to jump directly, or click "Start Teaching" to play slides in order.
Each slide's content unfolds naturally as you scroll; continue with "Next Lesson" at the bottom.
Context Engineering
16
Context Window: AI's Working Memory
Visualize window composition, drag to simulate overflow, compare capacities across major models
Interactive
›
17
Context Overflow: Three Handling Strategies
Direct truncation / Summary compression / Selective retention — visualize the trade-offs of each strategy
Interactive
›
Prompt Engineering
18
Why LLMs Choose Markdown
Plain-text model + formatting needs = MD as the top choice; step-by-step reasoning why HTML/Word/LaTeX don't work
Animation
›
19
Markdown Syntax and Rendering Pipeline
Quick syntax reference + live editor + marked.js / react-markdown / markdown-it rendering options
Interactive
›
20
You Say It, It Becomes It
Switch between five roles in real time, control output format, core principles of System Prompt
Interactive
›
21
Advanced Prompt Techniques
Few-Shot / CoT / constraints / task decomposition — good-vs-bad comparison interactive demo
Interactive
›
22
Output Format Trade-offs
Plain text / JSON / Markdown / YAML / XML — scenario-fit comparison, Token cost vs. parsing complexity trade-offs
Interactive
›
23
Streaming Output and Format Compatibility
JSON requires full text to parse / MD renders word by word / XML captures and renders tags on the fly — live demo of the differences
Interactive
›
Security Defense
24
Prompt Injection: Why Do Attacks Succeed?
SQL injection analogy → Message List fundamentals → lack of parameterization → overview of 5 attack types
Security Step-through
›
25
Prompt Injection: 12 Attack Case Studies
Privilege escalation / role-play / Few-Shot / structural injection / metaphor disguise — vulnerable vs. defended version for each
Security Interactive
›
26
Prompt Defense: TiedStory Three-Layer Interception in Practice
Input layer regex → prompt layer constraints → output layer leak detection → frontend + secondary review, full attack-chain simulation
Hands-on Interactive
›
Agent Engineering
27
Agent: AI That Gets Things Done
Four core capabilities: Plan / Tool / Memory / Act — click to see real-world examples
Interactive
›
28
The Secret of Tool Calling
Model outputs JSON → framework parses and executes → result injected back — four-step process visualization
Interactive
›
29
ReAct in Practice: The Real Loop an Agent Goes Through
Step-by-step Thought / Action / Observation demo — 3 failures + 1 success — the complete Agent struggle loop
Animation
›
30
Skill: Help the Agent Take the Right Path
Skill = process instructions + tool-calling guidance; good loop vs. bad loop analogy with SKILL.md file structure
Interactive
›
31
Scaffolding Engineering: From Prototype to Product
Simulate Agent booking flights and hotels — full comparison with vs. without scaffolding, 5 key capabilities explained
Interactive
›
Cost Optimization
32
Why Does Multi-Turn Dialogue Get More Expensive?
Visualize cumulative Token costs — drag turns to see how costs grow exponentially
Interactive
›
33
KV Cache: Trading Space for Time (and Money)
Analogy-based understanding + savings calculator — explicit cache comparison: Anthropic vs. Qwen in practice
Interactive
›
34
Explicit Caching: Anthropic vs. Qwen in Practice
cache_control syntax, cache hit detection, price discount comparison — real savings demonstrated
Interactive
›
35
Dynamic Timestamps: The Most Expensive System Prompt Design
Bad design vs. good design — switch between three time-handling approaches
Anti-pattern
›
36
Holistic Cost Optimization: Save Money at the System Level
5-layer optimization strategy, cost breakdown visualization, system design that saves 70–90%
System Design
›
37
Image Tokens: Pixels That Burn Money
Image billing formula, scaling mechanism, resolution pitfalls, task-based tiered strategy
Multimodal
›
38
Match Resolution to Task: Fine-Grained Image Cost Control
High / medium / low resolution strategies — Token cost comparison across scenarios with selection advice
Multimodal
›
39
Syntax-Level Optimization: Prompts Written for Machines
YAML vs JSON, CSV vs arrays, compressed JSON output — save 10–30% on formatting Tokens
Prompt Engineering
›
40
Semantic-Level Optimization: Don't Use Context as a Trash Can
Dynamic Few-Shot, LLMLingua-2 compression, drag-to-sort attention — boost information density
Semantic
›
41
Output Layer + KV Cache Advanced
Negative constraints, Diff polishing, stop sequences; KV Cache tool traps and sliding window issues
Architecture
›
42
Model Selection: Capability vs. Cost Trade-offs and Decision Framework
Capability/cost matrix for major models, selection decision tree, model-matching strategy by scenario
Selection
›
⚗
The Greatest Simplicity: Holding to First Principles
The essence of AI Harness / what to build vs. what to skip / Harness that will be obsoleted / the ultimate question
Closing Reflection
›
★1
Chapter 2 Summary (Part 1) · Prompt Engineering + Agent Design
Context overflow strategies / 6 elements of Prompt / truth about tool calling / Skill + scaffolding
Chapter Summary
›
★2
Chapter 2 Summary (Part 2) · Cost Optimization + Full AI PM Perspective
Five-layer cost system / KV Cache principles / Image Tokens / complete course capability checklist
Chapter Summary
›