function recordChatCompletionMessages({
  agent,
  shim,
  segment,
  transaction,
  bedrockCommand,
  bedrockResponse,
  err
}) {
  if (shouldSkipInstrumentation(agent.config) === true) {
    shim.logger.debug('skipping sending of ai data')
    return
  }

  const summary = new LlmChatCompletionSummary({
    agent,
    bedrockResponse,
    bedrockCommand,
    transaction,
    segment,
    isError: err !== null
  })

  // Record context message(s)
  const promptContextMessages = bedrockCommand.prompt
  promptContextMessages.forEach((contextMessage, promptIndex) => {
    const msg = new LlmChatCompletionMessage({
      agent,
      segment,
      transaction,
      bedrockCommand,
      content: contextMessage.content,
      role: contextMessage.role,
      bedrockResponse,
      index: promptIndex,
      completionId: summary.id
    })
    recordEvent({ agent, type: 'LlmChatCompletionMessage', msg })
  })

  bedrockResponse.completions.forEach((content, completionIndex) => {
    const chatCompletionMessage = new LlmChatCompletionMessage({
      agent,
      segment,
      transaction,
      bedrockCommand,
      bedrockResponse,
      isResponse: true,
      index: promptContextMessages.length + completionIndex,
      content,
      role: 'assistant',
      completionId: summary.id
    })
    recordEvent({ agent, type: 'LlmChatCompletionMessage', msg: chatCompletionMessage })
  })

  recordEvent({ agent, type: 'LlmChatCompletionSummary', msg: summary })

  if (err) {
    const llmError = new LlmError({ bedrockResponse, err, summary })
    agent.errors.add(transaction, err, llmError)
  }
}
Creates and enqueues the LlmChatCompletionSummary and
LlmChatCompletionMessage events and adds an error to transaction if it
exists. It will also assign the request, conversation and messages ids by
the response id.

@param {object} params function params
@param {object} params.agent instance of agent
@param {object} params.segment active segment
@param {BedrockCommand} params.bedrockCommand parsed input
@param {Error|null} params.err error from request if exists
@param {BedrockResponse} params.bedrockResponse parsed response
@param {Shim} params.shim shim instace
@param {Transaction} params.transaction active transaction