Session 3
AI 3010, advancedUsing agentic frameworks
Rebuild session 2's agent on LangChain and LangGraph, the framework Amadeus has chosen, and see what the framework takes off your hands. Participants ported the hand-built harness one step at a time: the model call, memory, instructions, tools and the loop, approval by a person, tracing and retrieval. They then met the LangChain Expression Language, the chaining pattern the framework is named after.
60 minutes
Homework due before your sitting of session 4 on 20 November 2026
Recording
This browser blocks the SharePoint player, even when you are signed in.
Watch the recording in SharePointOpen in SharePoint — use this if the player above is blank, or asks you to sign in.
Captions and a transcript are available in the SharePoint player.
Homework
Due before your sitting of session 4 on .
- Task
- Implement a new version of the agent you built for session 2’s homework, this time with LangChain and LangGraph. Start from the session 3 folder of the course repository, and use your coding agent and the LangChain documentation to go further than the examples do. At the start of session 4, volunteers will demonstrate their agent, and presenting earns an extra entry in the draw.
- Deliverable
- Your implementation, as a zip file.
- File name
{lastname}-{firstname}-AI3010-Session3.zip- Submit to
- Homework submissions folder
Every submission is entered into a draw for exclusive program swag, awarded at the end of the semester.
Notes
Summary
- A framework is not an AI model. It is the infrastructure you build around one, and LangChain is the one Amadeus has chosen.
- The session ported session 2 step for step. Every step of the hand-built harness has a LangChain or LangGraph partner with the same name, so you can see what the framework takes over: the HTTP calls, the message list, the tool schemas, the loop, pausing for approval and the trace.
- LangGraph treats an agent as a graph. The model and the tools are nodes, a checkpointer keeps the conversation, and the loop is edges between the nodes.
- The name comes from chaining. The LangChain Expression Language composes a prompt, a model and a parser into one chain with pipes.
- Keep the parts that must be exact in plain code. Use the model for explanation and judgement, and check what it does with evaluations.
Key concepts
A framework is the plumbing around the model
Session 2 built a framework’s core by hand: the model interface, instructions, tools, the loop, memory and approval by a person. A framework such as LangChain provides that core, plus the other three layers: orchestration, capabilities such as retrieval and API integration, and production concerns such as observability, guardrails and deployment. That leaves you to work on what the agent does rather than on the plumbing.
- It is vendor-agnostic. Models and providers can be swapped with little change.
- It is widely used in production, including at Amadeus. Raya, which runs in AppCenter, the carrier console and as a standalone application, is built on it.
- It is young but early. Its first stable release came this year, yet it was one of the first agent frameworks, so its concepts carry over to the others.
The LangChain family
- LangChain is the high-level layer for building agents, and what most of the session used.
- LangGraph is the lower level, for when you need more control: graphs, state, orchestration and handoffs between agents.
- LangSmith is LangChain’s paid platform for hosting and observability. It picks up an agent’s trace and visualises it.
- Integration packages connect LangChain to a provider.
langchain-openaitalks to any model that offers the OpenAI API, which is why it works with DeepSeek in Microsoft Foundry and with Ollama on your own machine. Others exist for Anthropic, Microsoft Foundry and more.
The other options at Amadeus
- A3TK is Amadeus’s agentic framework, built on LangChain. It is aimed at creating agents without code, with drag-and-drop tooling, and is what Amadeus will use to run agents on OpenShift in the future.
- The Microsoft Agent Framework, formerly Semantic Kernel, is the .NET option. It offers the same concepts, everything in this session can be done with it, and it runs locally or in Microsoft Foundry.
- LangChain agents can be deployed to Microsoft Foundry, in the Azure subscriptions Navitaire uses today.
Memory is a checkpointer, and a conversation is a graph
In session 2, the harness kept every message in a list and sent the whole list
with every request. In LangGraph, a StateGraph holds the conversation’s state as
messages. A checkpointer (here InMemorySaver) stores that state, keyed by a
thread_id, and each message now has an ID. The behaviour is the same, with less
code and better tracing. Run step 2 with --forgetful and each turn starts a new
thread, so the agent forgets. The graph also gives the model more context, and the
more context an agent has, the more predictable it becomes.
Coding agents such as GitHub Copilot, Kiro and Claude Code face the same problem with long threads. Compaction is their answer: summarising a long thread to keep the memory small.
Tools are described from your code
Session 2 wrote a JSON schema by hand for every tool, which had to be kept in step
with the code. A schema that falls out of step leaves the model unable to call the
tool. In LangChain the @tool decorator, with parse_docstring=True, builds the
schema from the function’s signature and docstring, and bind_tools gives the
tools to the model. So write docstrings as if the model reads them, because it does.
Approval and tracing are middleware
Step 5 replaces session 2’s agent class with create_agent, which builds the loop
itself. Approval by a person is HumanInTheLoopMiddleware, configured to interrupt
on rebook_passenger and to offer two decisions, approve or reject. The agent
pauses, the checkpointer keeps its place, and the run resumes once a person decides,
so you don’t write the code to break off and pick up again. A rejection tells the
model not to retry. Tracing is a callback handler that writes every message, tool
call, argument and timing to trace.jsonl. In production that trace would be
visualised, which is what LangSmith does.
Mix deterministic and non-deterministic code
Step 6 keeps session 2’s design. Finding the booking, the retrieval over EU Regulation 261/2004 and the compensation calculation are plain Python, which answers instantly and the same way every time. The model runs only when asked to explain. Pointing a model at something like a CI/CD pipeline and letting it work everything out is the opposite approach, and a worse one: the best results marry the two. Because a model can hallucinate even when it calls the right tools, evaluations (evals) are how you verify that it found the right information.
The LangChain Expression Language (LCEL)
LangChain is named after the chaining pattern: methods that each return an object
you can call the next one on, like StringBuilder in C#. LCEL composes a chain with
pipes, as in a Unix shell:
chain = prompt | model | parser
chain.invoke({"question": "What is the capital of Europe?"})
ChatPromptTemplate fills placeholders such as {question} in a prompt.
StrOutputParser turns the model’s reply into a string. Steps 1 to 6 are a direct
port of the hand-built harness; step 7 is closer to how LangChain is meant to be
used.
Methods and frameworks
Porting the hand-built harness
Every file in the repository’s session-3 folder has a partner of the same name in
session-2. Opening them side by side is the quickest way to see what the
framework does.
| Step | Session 2, by hand | Session 3, with LangChain and LangGraph |
|---|---|---|
llm.py | An HTTP request in every step | ChatOpenAI, given defaults from the environment |
| 1, hello model | Build the JSON, post it, read the reply | model.invoke with a SystemMessage and a HumanMessage |
| 2, memory | A list sent with every request | Graph state and a checkpointer, keyed by thread |
| 3, instructions | The system prompt as the first message | A SystemMessage put in front of the history on every call |
| 4, tools and the loop | Hand-written schemas and a loop | @tool, bind_tools, a ToolNode and a recursion limit of 8 |
| 5, the agent | harness.py, with approvals and a trace | create_agent, human-in-the-loop middleware and a tracing callback |
| 6, retrieval | An agent full of if-statements | A graph whose exact parts are plain Python, with the model only to explain |
| 7, LCEL | — | A prompt, a model and a parser, chained |
Practical takeaways
- Use the shared model if your own machine struggles. For this course the presenters have deployed DeepSeek V4 Pro in Microsoft Foundry, which is faster and knows far more than Qwen 3.5 4B: asked who Luis Maroto is, it answered where the small model said there was no one of note by that name. The endpoint and key were posted in the meeting chat and stay live until the end of the semester. Use them only for AI 3010 work, don’t share them outside the organization, and don’t point coding agents at them. Local models still work.
- Set up
.envbefore step 7. Copy.env.exampleto.env, which is not tracked, and add the values from the chat. Step 7 buildsChatOpenAIdirectly, which readsOPENAI_API_KEYandOPENAI_API_BASE, and fails without them. - Mind the amber warning on LangChain’s website. It is there because LangChain also runs hosted infrastructure that passes what you send it through models. Use the documentation freely, but don’t send it company information.
- Keep tool sets small and narrowly scoped. There is no known recommended number, but every tool adds to the context, and with it to the cost and the risk of hallucination.
- Develop against mock data first. One participant’s homework, an agent that summarises a sprint, ran only on mock Azure DevOps data until it could be trusted with the real thing, and was starting to be measured with evals.
- Temperature controls randomness. The higher it is, the more creative the model, and the more likely it is to make things up. Step 7 sets it to 0.7.
- Don’t commit your
trace.jsonl. It is in the repository only as an example, and it changes every time you run steps 5 and 6. - This is the surface. The textbook, the LangChain documentation and your coding agent will show you far more than these seven steps.
Key terms
| Term | Meaning |
|---|---|
| Agentic framework | The infrastructure around a model that turns it into an agent; not a model itself |
| LangChain | The open-source framework Amadeus has chosen for building agents |
| LangGraph | LangChain’s lower level, which models an agent as a graph of nodes and edges |
| LangSmith | LangChain’s paid platform for hosting agents and visualising their traces |
| A3TK | Amadeus’s no-code agentic framework, built on LangChain |
| Checkpointer | The LangGraph component that stores a conversation’s state, keyed by thread |
| Thread ID | The key that tells one conversation’s memory from another’s |
ToolNode | The graph node that runs the tools the model asks for |
| Recursion limit | The maximum number of steps the reasoning and acting loop may take |
| Middleware | Code that runs around the agent’s loop, such as pausing for approval |
| Compaction | Summarising a long conversation so that the memory stays small |
| Evals | Tests that check an agent’s behaviour, such as whether it found the right information |
| LCEL | The LangChain Expression Language, which chains steps with pipes |
Resources mentioned
- The course repository, in the
session-3folder: on GitHub, which needs membership of the amadeus-nav organization, or its mirror in Azure DevOps. If you can reach neither, the code is under the downloads as a zip file. - The LangChain documentation, including LangGraph.
- The course textbook, listed on the syllabus.
- The Microsoft Agent Framework, for .NET.