function recordCompletions({ events, completionSummary, agent, segment, shim, transaction }) {
  for (let i = 0; i < events.length; i += 1) {
    let msg = events[i]
    if (msg?.content) {
      msg = msg.content
    }

    let msgString
    try {
      msgString = typeof msg === 'string' ? msg : JSON.stringify(msg)
    } catch (error) {
      shim.logger.error(error, 'Failed to stringify message')
      msgString = ''
    }

    const completionMsg = new LangChainCompletionMessage({
      sequence: i,
      agent,
      content: msgString,
      completionId: completionSummary.id,
      segment,
      transaction,
      runId: segment[langchainRunId],
      // We call the final output in a LangChain "chain" the "response":
      isResponse: i === events.length - 1
    })

    common.recordEvent({
      agent,
      shim,
      type: 'LlmChatCompletionMessage',
      pkgVersion: shim.pkgVersion,
      msg: completionMsg
    })
  }
}
Records the LlmChatCompletionMessage(s)

@param {object} params function params
@param {Array} params.events prompt and response messages
@param {LangChainCompletionSummary} params.completionSummary LlmChatCompletionSummary event
@param {Agent} params.agent instance of agent
@param {TraceSegment} params.segment active segment
@param {Shim} params.shim shim instance
@param {Transaction} params.transaction active transaction