fix(captain): generate_pix returns success=false on real errors

When Inter integration fails ("Unit not configured for Pix", missing
certs, etc.), the tool was returning success=true with the error
message as formatted_message. The LLM interpreted that as success and
hallucinated "Pix generated" to the customer — and never triggered the
generate_reservation_link fallback.

Switch the rescue path from tool_feedback_response (success=true) to
error_response (success=false) so the Daniela scenario correctly falls
back to the reservation-link tool as documented in her prompt.
This commit is contained in:
Rodribm10 2026-04-21 18:59:45 -03:00
parent ee2aae3958
commit 6c9d12559d

View File

@ -440,7 +440,10 @@ class Captain::Tools::GeneratePixTool < Captain::Tools::BaseTool
mapped_error = map_pix_error_message(e)
return mapped_error if mapped_error.is_a?(Hash)
tool_feedback_response(mapped_error)
# Erro real na geração do Pix deve voltar success: false pra LLM
# cair no fluxo de fallback (generate_reservation_link) em vez de
# alucinar que o Pix foi gerado.
error_response(mapped_error)
end
def map_pix_error_message(error)