ALTER TABLE agent_message
    ADD COLUMN IF NOT EXISTS token_count INTEGER,
    ADD COLUMN IF NOT EXISTS finish_reason TEXT;

ALTER TABLE agent_message
    ADD COLUMN IF NOT EXISTS search_vector tsvector
        GENERATED ALWAYS AS (to_tsvector('english', coalesce(content, ''))) STORED;

CREATE INDEX IF NOT EXISTS idx_agent_message_search
    ON agent_message USING GIN (search_vector);
