Require openai in coplan.rb so OpenAI constant is loaded#123
Merged
Conversation
ruby-openai is a transitive dependency through coplan-engine's gemspec, so host apps (coplan-square) don't auto-require it via Bundler.require. Without this require, SummarizePlanJob fails with: NameError: uninitialized constant CoPlan::AiProviders::OpenAi::OpenAI because the OpenAI::Client constant is never loaded in the host process. Amp-Thread-ID: https://ampcode.com/threads/T-019e898e-809a-7332-8e3e-a51658bf36f3 Co-authored-by: Amp <amp@ampcode.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The freshly bumped
coplan-engineis crashing in coplan-square production with:triggered by
SummarizePlanJob(the new AI summary feature from #118).Root cause
ruby-openaiis declared as a dependency in engine/coplan.gemspec (spec.add_dependency "ruby-openai"), which installs the gem but does not auto-require it. Host apps usingBundler.requireonly auto-require gems listed directly in their own Gemfile — transitive gemspec deps must be required explicitly by the consuming gem.In dev, this often works by accident (other code paths or dev gems can pull
openaiin), but in coplan-square production the constant is never loaded, so the firstOpenAI::Client.newcall blows up.Fix
Add
require "openai"to engine/lib/coplan.rb alongside the other top-level requires (commonmarker,diffy).Validation
bundle exec rspec spec/services/ai_spec.rb spec/jobs/summarize_plan_job_spec.rb✅ (15 examples, 0 failures)Once this merges I'll re-bump coplan-square to pick it up.