Building an Agentic Personal Trainer - Part 2: The Tool System
This is Part 2 of a series on building an agentic personal trainer. Read Part 1 for the architecture overview and coaching philosophy.
An LLM without tools is just a chatbot. To make a real coaching agent, I needed to give it hands—ways to check injuries, recall workouts, and manage schedules.
LangChain tools follow a simple pattern: name, description, and a function. The description is critical—it's how the LLM decides when to use each tool.
Here's the injury checking tool (injury-tool.js:7-27):
export const getInjuriesTool = new Tool({
name: "get_active_injuries",
description: "Get list of current active injuries. Use this
to check what injuries the athlete has before recommending workouts.",
func: async (input) => {
const injuries = getActiveInjuries();
if (injuries.length === 0) return "No active injuries.";
return injuries.map(i =>
`- ${i.name} (${i.severity}): Affects ${i.affects.join(', ')}`
).join('\n');
}
});
The 8 tools: Eight tools across three categories: injuries, workouts, and scheduling
The prototype contains 8 tools across three categories:
Injuries (injury-tool.js): get_active_injuries, check_injury_status
Workouts (workout-tool.js): get_recent_workouts, suggest_workout, suggest_brick_workout
Schedule (schedule-tool.js): get_planned_schedule, add_planned_workout, reschedule_workout
The suggest_workout tool (workout-tool.js:33-82) takes JSON with a feeling field—energy level, not performance metrics. When the athlete says "I'm wiped," the agent can pass {feeling: "tired"} and get recovery-focused suggestions like yoga or an easy swim.
if (feeling === 'tired' || feeling === 'low_energy') {
suggestions.push('Yoga (recovery focus)');
suggestions.push('Easy swim (30-40 min, low intensity)');
suggestions.push('Light walk or stretching');
}
The check_injury_status tool (injury-tool.js:29-40) doesn't actually check anything—it returns a prompt telling the agent to ask the user. Some tools are action triggers, others are conversation prompts. This distinction matters: the tool signals the agent to gather information rather than execute an action.
The description matters more than the implementation. A perfectly coded tool with a vague description will never get called. Write descriptions like you're explaining to a new hire when to use each capability.
Tool descriptions deserve more attention than they typically get. The LLM reads those descriptions to decide which tool fits the user's request. Vague descriptions = wrong tool choices = bad coaching.
Next: the system prompt that shapes the agent's personality.
Part 2 of 9 in the Agentic Personal Trainer series.
agentic-personal-trainer - View on GitHub
This post is part of my daily AI journey blog at Mosaic Mesh AI. Building in public, learning in public, sharing the messy middle of AI development.
