Respose-Tranformer response body change not being detected by other plugins that read the response body

I am working through a requirement where I need to append data to the response body using the response-transformer plugin. Right afterwards, another plugin (an extension of the kafka-log plugin) will read the response body and submit to a Kafka topic for processing. However, when the Kafka plugin reads the response body, it’s like the response transformer did not do its job at all. The field I added via response-transformer plugin is not available in the message that was dropped to Kafka or in what was returned to the calling client. If I disable the kafka-log plugin, then the response-transformer works as expected, but obviously with the message not being persisted to Kafka. Playing with the code, I commented out the sections that I believe could be causing the issue:

local chunk, eof = ngx.arg[1], ngx.arg[2]

if not eof then
  ngx.ctx.rt_body_chunks[ngx.ctx.rt_body_chunk_number] = chunk
  ngx.ctx.rt_body_chunk_number = ngx.ctx.rt_body_chunk_number + 1

– ngx.arg[1] = nil

  local body = table_concat(ngx.ctx.rt_body_chunks)
  local ok, err = producer:send(conf.topic, nil, cjson_encode(body))

– ngx.arg[1] = body

By commenting the code out above, Kong now returns the payload as expected to the client (with the appended data by the response-transformer plugin), but the code above is not seeing the appended field and is sending the unchanged request to the Kafka topic. I will continue to look at the code further, but any advice here is welcome.

Kafka-Log: 5
Respose-Transformer-Advanced: 800