Skip to content

Require ruby-openai in engine entry point (COPLAN-24 hotfix)#124

Merged
HamptonMakes merged 1 commit into
mainfrom
hampton/coplan-24/openai-require-fix
Jun 2, 2026
Merged

Require ruby-openai in engine entry point (COPLAN-24 hotfix)#124
HamptonMakes merged 1 commit into
mainfrom
hampton/coplan-24/openai-require-fix

Conversation

@HamptonMakes
Copy link
Copy Markdown
Collaborator

Hotfix for COPLAN-24.

What broke

Downstream hosts that consume coplan-engine as a gem (e.g. coplan-square) hit:

NameError: uninitialized constant CoPlan::AiProviders::OpenAi::OpenAI
  in app/services/coplan/ai_providers/open_ai.rb:15
     `client = OpenAI::Client.new(...)`

The engine's coplan.gemspec declares ruby-openai as a runtime dep, but engine/lib/coplan.rb never required it. The local test suite passed because the host Gemfile in this repo also lists gem "ruby-openai", which masked the missing require.

Fix

Add require "openai" to the engine entry point alongside the existing require "commonmarker" and require "diffy", so the engine self-loads its declared dependencies.

Follow-up

Should add a smoke test that boots the engine in isolation (without the host Gemfile) to catch this class of bug — tracking separately.

🤖 Drafted with Amp.

Co-authored-by: Amp amp@ampcode.com

The engine's gemspec declares ruby-openai as a runtime dependency,
but engine/lib/coplan.rb never required it — so the OpenAI constant
isn't defined for gem consumers that don't separately list it in
their own Gemfile.

The local worktree test suite happened to pass because the host
Gemfile here also lists `gem "ruby-openai"`, masking the missing
require. Downstream hosts (coplan-square) consuming only coplan-engine
hit:

  NameError: uninitialized constant CoPlan::AiProviders::OpenAi::OpenAI
  ...in app/services/coplan/ai_providers/open_ai.rb:15
     `client = OpenAI::Client.new(...)`

Add `require "openai"` alongside the existing `require "commonmarker"`
/ `require "diffy"` so the engine self-loads its declared deps.

Amp-Thread-ID: https://ampcode.com/threads/T-019e84ca-1d09-777c-baf1-b1f380ec013c
Co-authored-by: Amp <amp@ampcode.com>
@HamptonMakes HamptonMakes merged commit 7883132 into main Jun 2, 2026
5 checks passed
@HamptonMakes HamptonMakes deleted the hampton/coplan-24/openai-require-fix branch June 2, 2026 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant