iachat/spec/enterprise/services/captain
Rodribm10 b457e84c2f fix(captain): route embeddings to legacy OpenAI + retry transient errors
Resolve duas camadas de problema identificadas em teste end-to-end:

1. Embeddings falhavam com HTTP 404 (/codex/v1/embeddings não existe).
   Solução: Captain::Llm::EmbeddingService sempre usa OpenAI tradicional
   via Llm::Config.with_api_key(legacy_settings). ProviderConfig expõe
   legacy_openai_settings pra isso.

2. Servidor Codex ocasionalmente responde com response.failed +
   code=server_error (instabilidade transitória). Client agora retenta
   até 2x com backoff exponencial (0.5s, 1.5s) em erros retryable:
   HTTP 5xx, server_error no response.failed, ou stream inacabado.

Outras correções nesta etapa:
- Scenario#agent_model: em modo Codex, ignora CAPTAIN_OPEN_AI_MODEL_SCENARIO
  (que pode ter gpt-4o legado) e usa ProviderConfig.model.
- ExtractionService/ContradictionCheckerService/TranslateQueryService:
  trocam constantes hardcoded gpt-4o-mini/gpt-4.1-nano por
  ProviderConfig.light_model (respeitando o provider ativo).
- ProviderConfig.DEFAULT_CODEX_MODEL agora é gpt-5.2 (reconhecido pelo
  RubyLLM; gpt-5.4 não está no catalog do gem).

Validado ponta-a-ponta: WhatsApp → Chatwoot → Jasmine → handoff Daniela
→ faq_lookup com embedding OK → resposta com preços corretos.

Docs em docs/captain-codex-oauth.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 17:42:31 -03:00
..
assistant fix(captain): remove scenario->orchestrator back-handoff (ping-pong) 2026-04-19 11:30:19 -03:00
codex fix(captain): always include instructions in Codex responses body 2026-04-22 15:27:37 -03:00
contact_memories fix(captain-memory): temporal memory model + aggressive dedup 2026-04-19 08:30:42 -03:00
contact_stats feat(retention): UI layer — badge, filters, cohort matrix, KPI dashboard 2026-04-22 10:30:19 -03:00
copilot chore: fix linting 2025-12-20 12:55:27 -03:00
inter chore(style): fix rubocop offenses and update typing indicators 2026-02-25 15:06:58 -03:00
lifecycle test(lifecycle): add end-to-end integration spec for scheduler→dispatch→send flow 2026-04-15 09:29:52 -03:00
llm fix(captain): route embeddings to legacy OpenAI + retry transient errors 2026-04-22 17:42:31 -03:00
onboarding feat: legacy features to ruby llm (#12994) 2025-12-11 14:17:28 +05:30
reports feat(captain): semantic memory fixes + roleta + reclamações + analytics 2026-04-21 15:36:25 -03:00
reservations chore(style): fix rubocop offenses and update typing indicators 2026-02-25 15:06:58 -03:00
tools ajuste galeria de imagens 2026-02-26 15:27:25 -03:00
open_ai_message_builder_service_spec.rb Merge branch 'main' into chatwoot/develop 2025-07-16 09:37:08 -03:00
tool_registry_service_spec.rb feat: Update UI for Copilot (#11561) 2025-06-02 22:02:03 -05:00