ASAmol Shukla
Projects
Courses
Prompts
Skills
Contact
Resume
Course Outline
Syllabus Overview

AI Tools: LLM & Prompt Engineering Mastery

Courses/AI Tools: LLM & Prompt Engineering Mastery/Lesson 19: Prompting for Agentic Workflows
60 mins lesson duration•11 mins read

Lesson 19: Prompting for Agentic Workflows

System prompts for agents, tool-use instructions, prompt chaining, and evaluation — production prompting for AI tools.

The Agent Prompt Is a Job Description

When you prompt an agent, you're writing the rules for a worker that decides its own steps. Structure beats cleverness here.

The Agent System Prompt Template

You are [ROLE] with access to [TOOLS].

GOAL: [what success looks like]

AVAILABLE TOOLS (name: description):
- tool_a(...): [when to use]
- tool_b(...): [when to use]

RULES:
1. Think before acting; call one tool at a time.
2. Stop and answer when you have enough information.
3. If a tool fails, try once more, then report the error.
4. Never invent tool results.

EXAMPLE:
[one full turn: Thought / Action / Observation / Answer]

Writing Tool Instructions (The Highest-Leverage Part)

Each tool description is a mini-prompt the model reads when deciding:

Weak description Strong description
"get_weather(city)" "Get current weather for a city. Use when the user asks about weather or temperature."
"search(q)" "Search the knowledge base for internal policies. Use for HR/IT questions. Returns up to 5 snippets."

The model chooses tools by these descriptions — vague descriptions cause wrong tool picks.

Prompt Chaining: One Task, Many Prompts

Break big jobs into chained prompts where each output feeds the next:

1. "List 10 trending AI topics for 2026."
2. "For each, write a one-line hook."
3. "Expand #3 into a 500-word outline."

Chaining beats one giant prompt: each stage gets a focused context, and you can review/redirect between stages.

The Reflect–Revise Pattern

For high-stakes output, add a self-review pass:

  1. Draft: generate the answer.
  2. Critique: "List the weaknesses of the draft against the rubric."
  3. Revise: "Rewrite fixing the weaknesses."

This 'generate → critique → revise' loop measurably improves drafts — at the cost of extra tokens.

Evaluating Prompts (Bring Back Lesson 15)

Change How to Verify
New system prompt Same 20-test golden set, compare scores
New tool description Does the agent now call the right tool?
New chain order End-to-end output quality + cost
Temperature change Consistency across 5 runs

Key Takeaways

  • An agent prompt = role + goal + tool catalog + rules + an example turn.
  • Tool descriptions are prompts — write them for the model, not for humans.
  • Chain complex tasks into focused prompts; add a critique–revise pass for quality.
  • Evaluate every change against a fixed test set.

Course complete: you now have the full toolkit — from how LLMs work to building and prompting agents. Keep learning, keep iterating.

Interactive Lesson Code Snippet
# A production-style agent system prompt, built in code
tools_section = """AVAILABLE TOOLS:
- get_weather(city: str) -> str
  Use when the user asks about weather or temperature.
- search_web(query: str) -> list[str]
  Use when the user asks for current information or research.
- calculate(expression: str) -> float
  Use for arithmetic or math questions.""" 

rules = """RULES:
1. Think step by step before acting.
2. Call at most one tool per turn.
3. When you have enough information, stop and answer.
4. Never invent tool results - report errors honestly."""

example = """EXAMPLE:
User: "What's the weather in Delhi?"
Assistant: I'll check the weather for Delhi.
Action: get_weather("Delhi")
Observation: "32C, sunny"
Answer: The weather in Delhi is 32C and sunny."""

system_prompt = f"""You are a helpful AI agent.

GOAL: Answer user questions accurately using tools when needed.

{tools_section}

{rules}

{example}"""

print(system_prompt)
Language: python

Lesson Code (Python)

# A production-style agent system prompt, built in code
tools_section = """AVAILABLE TOOLS:
- get_weather(city: str) -> str
  Use when the user asks about weather or temperature.
- search_web(query: str) -> list[str]
  Use when the user asks for current information or research.
- calculate(expression: str) -> float
  Use for arithmetic or math questions.""" 

rules = """RULES:
1. Think step by step before acting.
2. Call at most one tool per turn.
3. When you have enough information, stop and answer.
4. Never invent tool results - report errors honestly."""

example = """EXAMPLE:
User: "What's the weather in Delhi?"
Assistant: I'll check the weather for Delhi.
Action: get_weather("Delhi")
Observation: "32C, sunny"
Answer: The weather in Delhi is 32C and sunny."""

system_prompt = f"""You are a helpful AI agent.

GOAL: Answer user questions accurately using tools when needed.

{tools_section}

{rules}

{example}"""

print(system_prompt)

Console Output

You are a helpful AI agent.

GOAL: Answer user questions accurately using tools when needed.

AVAILABLE TOOLS:
- get_weather(city: str) -> str
  Use when the user asks about weather or temperature.
- search_web(query: str) -> list[str]
  Use when the user asks for current information or research.
- calculate(expression: str) -> float
  Use for arithmetic or math questions.

RULES:
1. Think step by step before acting.
2. Call at most one tool per turn.
3. When you have enough information, stop and answer.
4. Never invent tool results - report errors honestly.

EXAMPLE:
User: "What's the weather in Delhi?"
Assistant: I'll check the weather for Delhi.
Action: get_weather("Delhi")
Observation: "32C, sunny"
Answer: The weather in Delhi is 32C and sunny.

Code Visualization Tips

  • 🧠Draw the agent system prompt as an org chart: GOAL at top, TOOLS and RULES below, EXAMPLE as the footer.
  • 🧠Diagram a prompt chain as boxes with arrows — output of one feeds the next.
  • 🧠Sketch the critique–revise loop: Draft → Critique → Revise → Ship.

Professional Tips & Tricks

  • ⚡Include one full worked example turn in agent prompts — it teaches the format better than 10 rules.
  • ⚡After changing any prompt, re-run your golden set — 'small' prompt edits move scores a lot.
  • ⚡Log prompts + outputs per run; agent debugging lives or dies on traces.

Python Code Judge & Practice Arena

LeetCode Style

Run real Python 3.12 WebAssembly code directly in your browser against automated test suites.

Solved:0 / 1
0 / 30 XP
Challenges:
Problem 1 of 1

Write an Agent System Prompt

Hard+30 XP
Write a complete system prompt for a 'support triage agent' with tools: search_faq, escalate_to_human, and reply_draft. Include goal, tool descriptions, rules, and one example turn.
main.pyPython 3.12 (WASM)
1
2
3
4
5
6
7
8
9
10
11
12
Press Run Code to test or Submit to verify test cases

Up next · Continue learning

Self-Consistency — Sample & Vote

Run the same prompt several times and take the majority answer to lift accuracy on hard reasoning tasks, with examples.

9 mins read45 mins
Start next lesson
Previous: Structured Outputs & Reusable TemplatesNext: Self-Consistency — Sample & Vote
Made withbyAmol Shukla·amolshukla.online
ASAmol Shukla

AI Developer, Trainer & Agentic AI Expert building practical learning systems and real-world AI applications.

Explore

  • Projects
  • Courses
  • Prompts
  • Skills
  • Contact
  • Experience
  • Blogs

Connect

  • Resume
  • Contact
© 2026 Amol Shukla·Created withbyamolshukla.online
Back to top