CREATE TABLE IF NOT EXISTS agent_tool_call_log (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    invocation UUID,
    session UUID NOT NULL,
    conversation UUID,
    message UUID,
    tool_call_id TEXT,
    tool_name TEXT NOT NULL,
    arguments TEXT,
    result TEXT,
    error TEXT,
    status TEXT NOT NULL DEFAULT 'pending',
    started_at TIMESTAMPTZ NOT NULL DEFAULT now(),
    finished_at TIMESTAMPTZ,
    latency_ms BIGINT
);
