class RubyLLM::RequestShape

A RequestShape describes a conversation request as the provider received it, without its contents: each turn’s role and parts with their sizes, the tools on offer, the thinking settings, and the problems RubyLLM finds in it, such as a part with no data or a tool call with no result. Read it from Error#request_shape when a provider rejects a request without saying what is wrong with it.

begin
  chat.ask "What's due today?"
rescue RubyLLM::BadRequestError => e
  Rails.logger.error("#{e.message}\n#{e.request_shape}")
  Rails.error.report(e, context: { request_shape: e.request_shape.to_h })
  raise
end

A shape holds no text, tool arguments, tool results, signatures, URLs, file data, or setting values beyond thinking settings, so you can log it and send it to an error tracker. A long conversation keeps its first 10 and last 50 turns.