Welcome to the TaskGetTool project!
In this first chapter, we are going to talk about the foundation of our tool. Before we can ask an AI to "get a task" or "complete a task," we need to define exactly what a task is.
Imagine you are working with a colleague, and you hand them a sticky note that says: "Fix the bug."
Your colleague will have questions:
In software, passing plain text around creates confusion. To solve this, we create a Task Domain Entity. This is the "Noun" of our system. It turns a vague idea into a structured object that both humans and AI models can understand perfectly.
The Central Use Case: We want an AI agent to look at a task (e.g., "Deploy Database") and automatically realize: "Wait, I cannot do this yet because it is blocked by 'Write Migration Script'."
To allow the AI to reason about order of operations, our Entity needs three main parts:
Every task needs a unique fingerprint and human-readable details.
T-123) to find it.We need to know the lifecycle of the work.
pending, in_progress, or completed?This is what makes our entity smart. Instead of just a list, tasks are nodes in a web (a graph).
In our project, the TaskGetTool returns this entity. Let's look at how we define this structure using a schema (a blueprint for data).
We use a library called zod to define this shape. Don't worry about the syntax yet (we cover that in Chapter 2: Data Contract Schemas), just look at the fields:
// From TaskGetTool.ts
z.object({
id: z.string(), // The unique fingerprint
subject: z.string(), // The title
description: z.string(), // The details
status: TaskStatusSchema(), // e.g., 'pending'
blocks: z.array(z.string()), // Tasks waiting on this
blockedBy: z.array(z.string()), // Dependencies
})
Explanation: This code tells the AI: "When you ask for a task, you will receive an object with exactly these six pieces of information." This guarantees the AI never has to guess if a task has dependenciesβthe field is always there.
How does the tool actually produce this entity? Let's walk through the flow when an AI asks for a task.
123.
Inside the TaskGetTool.ts file, there is a call function. This is where the magic happens. We fetch the data and strictly map it to our entity definition.
// Inside TaskGetTool.ts -> call() method
const task = await getTask(taskListId, taskId)
// If found, return the structured Entity
return {
data: {
task: {
id: task.id,
subject: task.subject,
status: task.status,
// The AI uses these to decide order of work:
blocks: task.blocks,
blockedBy: task.blockedBy,
},
},
}
Explanation:
This code explicitly copies fields from our internal database object (task) into the public response. By including blocks and blockedBy, we are giving the AI the ability to see the future (what comes next) and the past (what must be done first).
Think of the Task Domain Entity like a professional Recipe Card in a kitchen.
If you just wrote "Cake" on a napkin, the chef (the AI) might try to bake it before buying eggs. By using the Recipe Card structure, the chef knows exactly what prerequisites exist.
In this chapter, we defined the Task Domain Entity. We learned that a task is more than just text; it is a structured object with an ID, status, and crucial dependency information (blocks/blockedBy). This structure allows the AI to understand the workflow logic of a project.
Now that we know what our data looks like, how do we ensure the code never breaks this structure?
Next Chapter: Data Contract Schemas
Generated by Code IQ