Overview
SDK hooks have a TODO for recording tool-specific metrics (e.g., how often agents use Write vs Bash).
Current State
File: codeframe/lib/sdk_hooks.py lines 237-239
if tool_name in ["Write", "Bash"]:
# TODO: Extend this to record tool-specific metrics in database
# For now, just log the usage
Expected Behavior
- Track tool usage per agent (Write, Bash, Read, etc.)
- Store metrics in database
- Enable analysis of agent behavior patterns
- Display tool usage in dashboard
Implementation Requirements
- Create
tool_usage table in database
- Record tool name, agent_id, timestamp on each tool use
- Aggregate metrics for dashboard
- Support querying by agent, tool, date range
Database Schema
CREATE TABLE IF NOT EXISTS tool_usage (
id INTEGER PRIMARY KEY AUTOINCREMENT,
agent_id TEXT NOT NULL,
tool_name TEXT NOT NULL,
project_id INTEGER,
task_id INTEGER,
timestamp TEXT NOT NULL,
duration_ms INTEGER,
success BOOLEAN NOT NULL,
FOREIGN KEY (project_id) REFERENCES projects(id),
FOREIGN KEY (task_id) REFERENCES tasks(id)
);
Example Metrics
# Get tool usage for agent
usage = db.get_tool_usage(agent_id="backend-001")
# Result:
# {
# "Write": 45,
# "Read": 120,
# "Bash": 30,
# "Edit": 25
# }
Acceptance Criteria
Priority
P3 - Advanced: Interesting analytics, but not critical for core functionality.
References
- File: codeframe/lib/sdk_hooks.py line 238
Overview
SDK hooks have a TODO for recording tool-specific metrics (e.g., how often agents use Write vs Bash).
Current State
File:
codeframe/lib/sdk_hooks.pylines 237-239Expected Behavior
Implementation Requirements
tool_usagetable in databaseDatabase Schema
Example Metrics
Acceptance Criteria
Priority
P3 - Advanced: Interesting analytics, but not critical for core functionality.
References