Module: Smith::Doctor::Checks::OpenaiApiMode

Defined in:
lib/smith/doctor/checks/openai_api_mode.rb

Overview

Validates that Smith.config.openai_api_mode is one of the allowed values (:off | :auto). Also surfaces whether the Smith::Providers::OpenAI::Responses adapter is loaded when mode is :auto — if not, gpt-5 family + tools + thinking would raise NotImplementedError at runtime.

Class Method Summary collapse

Class Method Details

.responses_adapter_loaded?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/smith/doctor/checks/openai_api_mode.rb', line 45

def responses_adapter_loaded?
  defined?(Smith::Providers::OpenAI::Responses)
end

.run(report) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/smith/doctor/checks/openai_api_mode.rb', line 14

def run(report)
  mode = Smith.config.openai_api_mode
  unless %i[off auto].include?(mode)
    report.add(
      name: "config.openai_api_mode",
      status: :fail,
      message: "openai_api_mode = #{mode.inspect} (invalid)",
      detail: "Must be :off or :auto"
    )
    return
  end

  if mode == :auto && !responses_adapter_loaded?
    report.add(
      name: "config.openai_api_mode",
      status: :warn,
      message: "openai_api_mode = :auto but Smith::Providers::OpenAI::Responses is not vendored",
      detail: "When (gpt-5 family + tools + thinking) is detected, the routing path " \
              "raises NotImplementedError. Either: (a) set openai_api_mode = :off to fall " \
              "back to graceful tool-dropping, or (b) vendor the Responses adapter (PR #770 " \
              "on crmne/ruby_llm tracks the upstream effort)."
    )
  else
    report.add(
      name: "config.openai_api_mode",
      status: :pass,
      message: "openai_api_mode = #{mode.inspect}"
    )
  end
end