[ ABORT TO HUD ]
SEQ. 1
SEQ. 2
SEQ. 3

Few-Shot & Chain-of-Thought

✍️ Prompt Engineering for Agents10 min80 BASE XP

Teaching Agents by Example

Two of the most powerful prompting techniques: Few-Shot Prompting (showing examples) and Chain-of-Thought (demonstrating reasoning steps).

Few-Shot Prompting for Tool Use

## Tool Usage Examples

User: "What's the weather in London?"
Thinking: User wants weather data. I should use get_weather.
Action: get_weather({"location": "London, UK"})
Result: {"temp": 12, "condition": "cloudy"}
Response: "It's 12°C and cloudy in London."

User: "Tell me a joke"
Thinking: General request, no tool needed.
Response: "Why do programmers prefer dark mode?..."

Chain-of-Thought Comparison

TechniqueWhen to UseToken CostQuality Boost
Zero-Shot CoT"Think step by step"Low (+50 tokens)+20-30%
Few-Shot CoTProvide reasoning examplesMedium (+200)+40-60%
Structured CoTForce specific formatMedium (+300)+50-80%
Extended ThinkingClaude native featureSeparate budgetHighest

Structured CoT Template

Before answering, reason through these steps:
1. **Understand:** What is the user asking for?
2. **Gather:** What information do I need?
3. **Plan:** What's my step-by-step approach?
4. **Execute:** Carry out the plan.
5. **Verify:** Does my answer address the question?
🎯 Pro Tip: Always include a NEGATIVE example in few-shot prompts — showing when the agent should NOT use a tool. This dramatically reduces unnecessary tool calls.
SYNAPSE VERIFICATION
QUERY 1 // 2
Why should few-shot prompts include negative examples?
To save tokens
Because agents over-use tools without examples showing when tools are unnecessary
To confuse the agent
Not useful
Watch: 139x Rust Speedup
Few-Shot & Chain-of-Thought | Prompt Engineering for Agents — AI Agents Academy