Skip to main content

Source Code

agent-client-tutorial/02-read-and-transform

What You’ll Build

A Spring Boot application that asks an agent to read log files, count severity levels (ERROR, WARNING, INFO), and produce a summary CSV. This demonstrates agents working with existing files and producing structured output.

Step 1: Set Up Sample Data

Clone the tutorial repository and navigate to the lesson:
The application creates sample log files automatically if they don’t exist. Three service logs (auth.log, api.log, worker.log) with mixed severity levels.

Step 2: Understand the Goal

The goal is a multi-line prompt that specifies the input, the transformation, and the expected output format:
Notice the specificity: file format, column names, exact line count. Agents perform better with precise output specifications.

Step 3: Run It

Step 4: Verify

Check the output CSV:

What’s Different from Lesson 1

  • Agent reads existing files β€” not just creating from scratch
  • Multi-file input β€” the agent scans a directory of logs
  • Structured output β€” the result is a well-defined CSV, not free text
  • Data transformation β€” counting, aggregating, formatting
This pattern β€” read existing state, transform it, write structured output β€” is the core of most agent tasks in production.

Next

Lesson 4: Git Operations β†’ β€” Use an agent to inspect git history and recover lost changes.