Extracts and formats memory content into a system prompt