Summary
Implement server-side execution and validation of AI tool calls. The AI proposes actions, the backend validates and executes them safely.
Tool Definitions
update_exercise
Update weight, sets, reps, or rest time.
- Validate exercise exists
- Validate reasonable ranges (weight ±20%, reps 1-100, etc.)
- Log change to audit
skip_exercise
Mark exercise to skip for a date.
- Create date override
- Require reason
add_exercise
Add new exercise to a day.
- Validate day exists
- Validate exercise type
- Set sort_order
create_override
Create one-time schedule change.
- Validate date format
- Validate override type
get_exercise_history
Read-only: get recent feedback.
- Return last N feedback entries
- Used by AI to understand patterns
get_schedule
Read-only: get schedule for date.
- Used by AI to understand current program
Validation Rules
class ToolValidator {
public function validateUpdateExercise(array $params): ValidationResult {
// Weight change max ±20%
// Sets 1-10
// Reps 1-100
// Rest 10-300 seconds
}
}
Audit Logging
CREATE TABLE ai_actions (
id INT AUTO_INCREMENT PRIMARY KEY,
conversation_id VARCHAR(36),
tool_name VARCHAR(50) NOT NULL,
params JSON NOT NULL,
result JSON,
status ENUM('success', 'rejected', 'error') NOT NULL,
rejection_reason TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
Part of
Phase 2: AI Proxy
Summary
Implement server-side execution and validation of AI tool calls. The AI proposes actions, the backend validates and executes them safely.
Tool Definitions
update_exercise
Update weight, sets, reps, or rest time.
skip_exercise
Mark exercise to skip for a date.
add_exercise
Add new exercise to a day.
create_override
Create one-time schedule change.
get_exercise_history
Read-only: get recent feedback.
get_schedule
Read-only: get schedule for date.
Validation Rules
Audit Logging
Part of
Phase 2: AI Proxy