You are an expert curriculum designer for an Agent AI Engineering course using a Quarto website for course instruction, textbook, and assignments. You have decided to focus mostly on concepts of agentic AI that will stick around for a long time, but the LangChain v1.x+ ecosystem using Python with Gemini models (gemini-2.5-flash) is the current focus.
Create a Quarto (.qmd) file for a single lesson using the provided . Use the details provided in the block to flesh out the content. Rules: 1. If any {{VARIABLE}} in is empty, STOP. Ask me to provide the variable before you write any code. 2. Follow all guidelines in strictly. 3. Output ONLY the raw Quarto markdown text. Do not include conversational filler. - Unit & Lesson: Unit 3, Lesson 3 - Topic: Context Management Types Identify the context management types: truncate, summarize, selection, file write, database, isolate/delegation Identify broadly the strengths and weaknesses of each Identify based on a problem which of truncate, summarize, or selection is best Implement a conversation with truncate Implement a conversation with selection Implement a conversation with summarization Experience the usefulness and limitations of each If the “implement” outcomes can’t easily be done with LangChain, use LangSmith One beginning activity should include being given 6 different LangSmith traces and identifying each. There will be a slide presentation to explain Always default model instantiation to LangChain v1.x using create_agent, NOT create_react_agent. Consult documentation every time you write code to make sure it is up to date. Prefer simple readable code over robust code to aid in student understanding. Here is an example model instantiation: from langchain.chat_models import init_chat_model from langchain.tools import tool system_prompt="You are a simple, friendly Hello World assistant. Use your tool to print to console" @tool def hello_world(): """Prints 'Hello World!' to console""" print('Hello World!') agent = create_agent( model="google_genai:gemini-2.5-flash", system_prompt=system_prompt, tools=[hello_world] ) agent.invoke("Hello world!") title: subtitle: format: html execute: eval: false — Quick LinksBefore ClassAfter Class Practice Primer Slides Examples Lecture Notes Next Lesson 🏃♂️➡️ 🌱 🧑🏫 📓 📋 ➡️ Practice Primer Previous Lesson 🏃♂️➡️ 🌱 ⬅️ Practice Primer Next Lesson 🏃♂️➡️ 🌱 ➡️ Outcomes Preparation Discussion Report on work accomplished Key takeaways Questions unaddressed Optional discussion questions Log partner’s contribution Class Before next class Practice Primer Next Lesson 🏃♂️➡️ 🌱 ➡️(lessonx_x.qmd) title: “API’s & Your First LLM Call” subtitle: “Unit 1, Lesson 2” format: html execute: eval: false — title: “What is Context Engineering?” subtitle: “Unit 3, Lesson 1” format: html execute: eval: false — ::: {.panel-tabset} Quick Links Practice Primer Slides Examples Lecture Notes Next Lesson 🏃♂️➡️ 🌱 🧑🏫 📓 📋 ➡️ Before Class Practice Primer Previous Lesson 🌱 ⬅️ After Class Practice Primer Next Lesson 🏃♂️➡️ 🌱 ➡️ ::: ::: {.panel-tabset} Quick Links Practice Primer Slides Examples Lecture Notes Next Lesson 🏃♂️➡️ 🌱 🧑🏫 (https://colab.research.google.com/github/ethanbyui/agentic_ai_course/blob/main/examples/example1_2.ipynb “Opens in Google Colab - See README if broken”) 📋 ➡️ Before Class Practice Primer Previous Lesson 🏃♂️➡️ 🌱 ⬅️ After Class Practice Primer Next Lesson 🏃♂️➡️ 🌱 ➡️ ::: 1. Report on work accomplished 2. Key takeaways 3. Questions unaddressed 4. Optional discussion questions - What could Cisco have done to avoid their customer service catastrophe? - Is prompt, context, or intent engineering more important? Why? 5. Log partner’s contribution 1. Report on work accomplished 2. Key takeaways 3. Questions unaddressed 4. Optional discussion questions - How easy was it to read through the documentation? Did you get stuck? Bored? - What did you find most helpful with your last programming assignment? - What definitely did not work? - What issue should your group members avoid? 5. Log partner’s contribution No group discussion today # Getting Started: Gemini API Setup About API keys An API key is a password for someone’s services. It opens the door of communication between your computer and their servers. In accessing Gemini with Python, you send your prompt and API key to their server; if the key is accepted, it will process your prompt and return its response (along with some other metadata). It is your first step to opening the AI door. Let’s get one! Do This Access the developer’s site for Gemini here: Gemini API key You will need to sign in A key should be created automatically. You can click on it and copy the large string of characters and numbers. If it doesn’t work Make sure you are using a personal Google account, not your school email If it says you don’t have access in your region, you may need to verify your age in your Google account settings If this becomes too much of a hassle, you use an OpenAI API key instead, but you will have to pay $5 and become familiar with what code to change as you go through the course (slight added complexity, but really not that much) I have a key, now what? TipChoose Your Platform You can follow along using either Google Colab (recommended for beginners - no setup required!) or local development (requires Python environment setup). The code examples below include instructions for both. For Google Colab: In Google Colab, we’ll use Colab’s built-in secrets feature to store your API key securely. Steps: Click the 🔑 key icon in the left sidebar (“Secrets”) Click “Add a new secret” Name it: GOOGLE_API_KEY Paste your Gemini API key as the value Toggle on “Notebook access” for this notebook # Set up API key from Colab secrets import os from google.colab import userdata os.environ['GOOGLE_API_KEY'] = userdata.get('GOOGLE_API_KEY') For Local Development: DO NOT paste it in this file DO NOT paste it in .env.example DO: Rename .env.example to .env Paste key in .env Save .env This is safe only when the .gitignore file has .env listed. Why .env? API keys are coveted (especially for LLM’s). If it gets published to GitHub, it will be stolen and used by strangers. To keep yours safe, store it in the .env file in the main directory. This environment variable file stays local to your machine and will not be pushed to GitHub (because the .gitignore file says to ignore it. You can open the .gitignore file to see .env listed as files it won’t publish to GitHub). The file .env.template is just a template. Please rename .env.template to .env before adding API keys. # Load environment variables from .env file (local development only) from dotenv import load_dotenv load_dotenv() Finally You can now run the below code to install needed packages. (You only need to run pip install once.) # This installs the dependencies you need !pip install -q -U langchain langchain-google-genai After saving your API key, you can run the below code to see if it worked. from langchain.chat_models import init_chat_model model = init_chat_model( model="gemini-2.5-flash", model_provider="google_genai" ) model.invoke("Hello world!") You should see something like: AIMessage(content='Hello there! How can I help you today?', additional_kwargs={}, ... STOP If you got things working, rejoice! Make sure to help your neighbor gets there too. Then you can continue. # Lesson Overview Segment Duration Lecture: Why, What, and How? 15 minutes Activity: API Key Setup 10 minutes Guided Coding: LangChain Basics 15 minutes Exploration: Prompt & Context Engineering 20+ minutes What is Context Engineering? What is Context Engineering? Home /index.html Unit 1 Unit 1 Overview /lessons/unit1.html — Day 1 : APIs & Your First LLM Call /lessons/lesson1_1.html Day 2 : Tools - Structure & Uses /lessons/lesson1_2.html Day 3 : Tool Wrappers & Local Data /lessons/lesson1_3.html Day 4 : Response Formats & Datatypes /lessons/lesson1_4.html Day 5 : Statefulness & Conversation History /lessons/lesson1_5.html Day 6 : Connecting to the World via MCP /lessons/lesson1_6.html Day 7 : MCP from GitHub /lessons/lesson1_7.html Day 8 : Subagents & Multi-Agent Intro /lessons/lesson1_8.html Unit 1 Project : Build a Powerful Bot /lessons/lesson1_9.html Unit 2 Unit 2 Overview /lessons/unit2.html Day 1 : What Makes an Agent Bad? /lessons/lesson2_1.html Day 2 : Defining Main Failures /lessons/lesson2_2.html Day 3 : LangSmith Setup & Trace Reading /lessons/lesson2_3.html Day 4 : Token & Latency Analysis /lessons/lesson2_4.html Day 5 : Evals & Golden Test Sets /lessons/lesson2_5.html Day 6 : Debugging Failure Patterns /lessons/lesson2_6.html Day 7 : Automation Rules & Alerts /lessons/lesson2_7.html Day 8 : Diagnosing a Broken Agent /lessons/lesson2_8.html Day 9 : Unit Review & Assessment /lessons/lesson2_9.html Unit 2 Project : Build a Good Bot /lessons/lesson2_10.html Unit 3 Unit 3 Overview /lessons/unit3.html ⚠️ Unit 3 is currently in production Day 1 : What Is Context Engineering? /lessons/lesson3_1.html Day 2 : Planning Agentic Systems /lessons/lesson3_2.html Day 3 : Context Management Strategies /lessons/lesson3_3.html Dictionary /dictionary.html Agentic AI Course — BYU-Idaho Built with Quarto What is Context Engineering? What is Context Engineering? What is Context Engineering? Unit 3, Lesson 1 Unit 3, Lesson 1
Rules: 1. If any {{VARIABLE}} in is empty, STOP. Ask me to provide the variable before you write any code. 2. Follow all guidelines in strictly. 3. Output ONLY the raw Quarto markdown text. Do not include conversational filler.
- Unit & Lesson: Unit 3, Lesson 3 - Topic: Context Management Types
Identify the context management types: truncate, summarize, selection, file write, database, isolate/delegation Identify broadly the strengths and weaknesses of each Identify based on a problem which of truncate, summarize, or selection is best Implement a conversation with truncate Implement a conversation with selection Implement a conversation with summarization Experience the usefulness and limitations of each
If the “implement” outcomes can’t easily be done with LangChain, use LangSmith
One beginning activity should include being given 6 different LangSmith traces and identifying each.
There will be a slide presentation to explain
Always default model instantiation to LangChain v1.x using create_agent, NOT create_react_agent. Consult documentation every time you write code to make sure it is up to date.
create_agent
create_react_agent
Prefer simple readable code over robust code to aid in student understanding.
Here is an example model instantiation:
from langchain.chat_models import init_chat_model from langchain.tools import tool system_prompt="You are a simple, friendly Hello World assistant. Use your tool to print to console" @tool def hello_world(): """Prints 'Hello World!' to console""" print('Hello World!') agent = create_agent( model="google_genai:gemini-2.5-flash", system_prompt=system_prompt, tools=[hello_world] ) agent.invoke("Hello world!")
title: subtitle: format: html execute: eval: false —
title: “API’s & Your First LLM Call” subtitle: “Unit 1, Lesson 2” format: html execute: eval: false —
title: “What is Context Engineering?” subtitle: “Unit 3, Lesson 1” format: html execute: eval: false —
::: {.panel-tabset}
:::
1. Report on work accomplished 2. Key takeaways 3. Questions unaddressed 4. Optional discussion questions - What could Cisco have done to avoid their customer service catastrophe? - Is prompt, context, or intent engineering more important? Why? 5. Log partner’s contribution
1. Report on work accomplished 2. Key takeaways 3. Questions unaddressed 4. Optional discussion questions - How easy was it to read through the documentation? Did you get stuck? Bored? - What did you find most helpful with your last programming assignment? - What definitely did not work? - What issue should your group members avoid? 5. Log partner’s contribution
No group discussion today
# Getting Started: Gemini API Setup
An API key is a password for someone’s services. It opens the door of communication between your computer and their servers. In accessing Gemini with Python, you send your prompt and API key to their server; if the key is accepted, it will process your prompt and return its response (along with some other metadata). It is your first step to opening the AI door. Let’s get one!
Access the developer’s site for Gemini here: Gemini API key
You will need to sign in
A key should be created automatically. You can click on it and copy the large string of characters and numbers.
Make sure you are using a personal Google account, not your school email
If it says you don’t have access in your region, you may need to verify your age in your Google account settings
You can follow along using either Google Colab (recommended for beginners - no setup required!) or local development (requires Python environment setup). The code examples below include instructions for both.
In Google Colab, we’ll use Colab’s built-in secrets feature to store your API key securely.
Steps:
GOOGLE_API_KEY
# Set up API key from Colab secrets import os from google.colab import userdata os.environ['GOOGLE_API_KEY'] = userdata.get('GOOGLE_API_KEY')
DO NOT paste it in this file DO NOT paste it in .env.example
.env.example
DO:
Rename .env.example to .env
.env
Paste key in .env
Save .env
This is safe only when the .gitignore file has .env listed.
.gitignore
API keys are coveted (especially for LLM’s). If it gets published to GitHub, it will be stolen and used by strangers. To keep yours safe, store it in the .env file in the main directory. This environment variable file stays local to your machine and will not be pushed to GitHub (because the .gitignore file says to ignore it. You can open the .gitignore file to see .env listed as files it won’t publish to GitHub). The file .env.template is just a template. Please rename .env.template to .env before adding API keys.
.env.template
# Load environment variables from .env file (local development only) from dotenv import load_dotenv load_dotenv()
You can now run the below code to install needed packages. (You only need to run pip install once.)
pip install
# This installs the dependencies you need !pip install -q -U langchain langchain-google-genai
After saving your API key, you can run the below code to see if it worked.
from langchain.chat_models import init_chat_model model = init_chat_model( model="gemini-2.5-flash", model_provider="google_genai" ) model.invoke("Hello world!")
You should see something like:
AIMessage(content='Hello there! How can I help you today?', additional_kwargs={}, ...
If you got things working, rejoice!
Make sure to help your neighbor gets there too. Then you can continue.
# Lesson Overview
What is Context Engineering? What is Context Engineering? Home /index.html Unit 1 Unit 1 Overview /lessons/unit1.html — Day 1 : APIs & Your First LLM Call /lessons/lesson1_1.html Day 2 : Tools - Structure & Uses /lessons/lesson1_2.html Day 3 : Tool Wrappers & Local Data /lessons/lesson1_3.html Day 4 : Response Formats & Datatypes /lessons/lesson1_4.html Day 5 : Statefulness & Conversation History /lessons/lesson1_5.html Day 6 : Connecting to the World via MCP /lessons/lesson1_6.html Day 7 : MCP from GitHub /lessons/lesson1_7.html Day 8 : Subagents & Multi-Agent Intro /lessons/lesson1_8.html Unit 1 Project : Build a Powerful Bot /lessons/lesson1_9.html Unit 2 Unit 2 Overview /lessons/unit2.html Day 1 : What Makes an Agent Bad? /lessons/lesson2_1.html Day 2 : Defining Main Failures /lessons/lesson2_2.html Day 3 : LangSmith Setup & Trace Reading /lessons/lesson2_3.html Day 4 : Token & Latency Analysis /lessons/lesson2_4.html Day 5 : Evals & Golden Test Sets /lessons/lesson2_5.html Day 6 : Debugging Failure Patterns /lessons/lesson2_6.html Day 7 : Automation Rules & Alerts /lessons/lesson2_7.html Day 8 : Diagnosing a Broken Agent /lessons/lesson2_8.html Day 9 : Unit Review & Assessment /lessons/lesson2_9.html Unit 2 Project : Build a Good Bot /lessons/lesson2_10.html Unit 3 Unit 3 Overview /lessons/unit3.html ⚠️ Unit 3 is currently in production Day 1 : What Is Context Engineering? /lessons/lesson3_1.html Day 2 : Planning Agentic Systems /lessons/lesson3_2.html Day 3 : Context Management Strategies /lessons/lesson3_3.html Dictionary /dictionary.html
Agentic AI Course — BYU-Idaho
Built with Quarto
What is Context Engineering? What is Context Engineering? What is Context Engineering? Unit 3, Lesson 1 Unit 3, Lesson 1
Unit 3, Lesson 1