Skip to content

[Future] Implement custom SDK hooks for tool-specific metrics #123

Description

@frankbria

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

  1. Create tool_usage table in database
  2. Record tool name, agent_id, timestamp on each tool use
  3. Aggregate metrics for dashboard
  4. 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

  • tool_usage table created
  • Tool usage recorded on each tool invocation
  • Metrics queryable by agent, tool, date
  • Dashboard displays tool usage charts
  • Unit tests verify metric recording

Priority

P3 - Advanced: Interesting analytics, but not critical for core functionality.

References

  • File: codeframe/lib/sdk_hooks.py line 238

Metadata

Metadata

Assignees

Labels

FutureDeferred - beyond v1/v2 scope, consider for future versionsenhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions