CREATE TABLE IF NOT EXISTS agent_model_invocation (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    session UUID NOT NULL,
    conversation UUID,
    message UUID,
    model_version UUID NOT NULL,
    request_id TEXT,
    status TEXT NOT NULL DEFAULT 'pending',
    prompt TEXT,
    response TEXT,
    error TEXT,
    started_at TIMESTAMPTZ NOT NULL DEFAULT now(),
    finished_at TIMESTAMPTZ,
    latency_ms BIGINT
);
