Session 2: The Agent Loop, Tools, and Memory

Presentation slides for Large Language Models for Software Engineers (Session 2).

Downloads: PowerPoint Presentation (.pptx) · PDF Slides (.pdf)


Session 2 Objectives

This session turns the single call from Session 1 into a complete agent: a loop that reads, acts, and remembers.

Specific Outcomes for Session 2:

  1. Assemble the Agent Loop: Build the loop every agent is made of (input, memory, API call, response, display) and explain the split between the stateless model and the stateful harness that owns the message array.
  2. Put Knowledge in the Loop: Add external knowledge with retrieval (RAG) and attachments, and choose between them.
  3. Turn Output into Action: Move from JSON output to the tool contract, where the model proposes a call and the harness validates and executes it.
  4. Build the Toolbox: Design read tools, the surgical write idiom, and a shell tool as ordinary code behind the tool contract.
  5. Manage Memory: Control the growing context with trim, compact, and wipe operations, and treat the context window as a budget.
  6. Read Coding Agents as Loops: Diagnose what tools like Cursor, Claude Code, and Copilot are doing at each step (prompt assembly, tool execution, context limits) using the loop model.

Workshop Materials