Welcome to the Tool Use Summary project! In this tutorial series, we will build a system that watches an AI Agent perform complex technical tasks and summarizes them into a simple, human-readable sentence (like a git commit message).
Imagine you have a robot assistant helping you code. You ask it to "Set up a new login page." To do this, the robot might:
login.html.If the robot just tells you "I'm done," you don't really know what happened. You need a detailed log. However, before we can write a summary of the work, we need a standard way to record exactly what action took place.
We need a standardized "container" or "report card" for every single action the robot takes. This container is called the Tool Execution Structure (or ToolInfo).
ToolInfo
The ToolInfo structure is the fundamental building block of our summary system. It acts as a snapshot of a single event.
Think of it like a receipt from a store. A receipt always has the same structure regardless of what you bought:
In our code, we map this directly to three properties:
name: The specific tool used (e.g., "readFile", "runTest").input: The arguments passed to the tool (e.g., the filename).output: The result returned by the tool (e.g., the file contents or "Success").Let's look at how we represent the robot creating a file using this structure.
Here is how we define the shape in TypeScript. It is very simple:
type ToolInfo = {
name: string
input: unknown
output: unknown
}
Explanation:
name: A string text representing the tool.input: Defined as unknown because tools can accept text, numbers, or complex JSON objects.output: Also unknown because a tool might return a string, a list of files, or nothing at all.
Let's see this in action. If our AI agent runs a tool called createFile, we capture that event into a ToolInfo object like this:
const fileCreationEvent: ToolInfo = {
name: 'createFile',
input: { path: '/src/login.html', content: '...' },
output: 'File created successfully'
}
Explanation:
Now we have a bundled object fileCreationEvent. We don't have to guess what happened; we have the name, the parameters, and the result all in one place.
How does this structure fit into the bigger picture?
Before the system can generate a summary (which we will cover in the next chapter), it must collect these ToolInfo objects into a list.
Here is a simple sequence of how an action becomes data:
Let's look at the actual code in toolUseSummaryGenerator.ts to see where this structure lives.
The system is designed to handle a batch (a list) of these tools. The main function generateToolUseSummary expects an array of these objects.
// From file: toolUseSummaryGenerator.ts
export type GenerateToolUseSummaryParams = {
// This is where our structure is used!
// It accepts a list of tool executions.
tools: ToolInfo[]
signal: AbortSignal
isNonInteractiveSession: boolean
}
Explanation:
The GenerateToolUseSummaryParams type defines the inputs for our main generator. The most important part is tools: ToolInfo[]. The square brackets [] mean "list of". So, the generator doesn't just look at one action; it looks at the history of actions to understand the context.
In this chapter, we established the foundation of our project: the Tool Execution Structure.
We learned that:
ToolInfo type acts as a "report card" holding the Name, Input, and Output.Now that we have our data neatly packaged, we are ready to feed it into an AI model to write a summary for us.
Next Chapter: Tool Summary Generator
Generated by Code IQ