fix(orchestrator): use vendored OpenCode endpoint detection#7823
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Claude encountered an error after 0s —— View job I'll analyze this and get back to you. |
|
Claude encountered an error after 0s —— View job I'll analyze this and get back to you. |
Summary
elizaOS/opencode#3/5a58f5cendpoint detectionWhy
The orchestrator already prefers the vendored OpenCode shim before falling back to a globally installed or npm OpenCode binary. This keeps that path explicit and makes Cerebras detection general: actual Cerebras hosts such as
api.cerebras.aiorgateway.cerebras.aiuse the Cerebras provider, while unrelated proxy URLs that merely containcerebras.aiin the path stay generic OpenAI-compatible or local config.Related
Validation
OpenCode vendored source:
bunx prettier --write packages/opencode/src/provider/provider.ts packages/opencode/src/provider/transform.ts packages/opencode/test/provider/provider.test.ts packages/opencode/test/provider/transform.test.tsbun test --timeout 30000 test/provider/provider.test.ts test/provider/transform.test.ts-> 331 passed, 0 failedbun run typecheckwas checked; currentdevstill has two baseline errors unrelated to this patch (OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAXflag typing and missing../../src/project/with-instanceintest/acp/event-subscription.test.ts)Eliza orchestrator after merging latest
origin/develop:git diff --checkbunx vitest run __tests__/unit/opencode-spawn-config-auto-detect.test.ts __tests__/unit/acp-service.test.ts __tests__/unit/available-agents.test.ts-> 43 passed, 0 failedbun run typecheck && bun run buildinplugins/plugin-agent-orchestrator-> passedNotes
This PR is intentionally narrow: it keeps provider endpoint detection in URL parsing code and tests instead of adding prompt text, deployment-specific config, or substring/regex matching against arbitrary paths.
Greptile Summary
This PR tightens Cerebras endpoint detection in the orchestrator's OpenCode spawn config by replacing a regex URL-text match with a proper hostname check via the
URLAPI, and bumps the vendored OpenCode submodule to5a58f5ceewhich includes the same fix upstream.isCerebrasBaseUrlnow parses the URL and checks only thehostnamefield (cerebras.aior*.cerebras.ai), preventing false positives whencerebras.aiappears only in a URL path segment.bin/opencodeandbin/opencode.cmddrop the now-irrelevant PR number reference.Confidence Score: 5/5
Safe to merge — targeted, well-tested narrowing of URL matching logic with no regressions on existing paths.
The only functional change is replacing a regex with a hostname-only check using the standard URL API, wrapped in a try/catch for invalid inputs. All pre-existing tests still pass and two new tests directly exercise the corrected behavior. The submodule bump and comment cleanups carry no runtime risk.
No files require special attention.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[buildOpencodeSpawnConfig] --> B{llmProvider == cloud?} B -- yes --> C[Return elizacloud config] B -- no --> D[isCerebrasBaseUrl customBaseUrl] D --> E{hostname == cerebras.ai or *.cerebras.ai?} E -- yes --> F[wantsCerebras = true] E -- no --> G{cerebrasApiKey set?} G -- yes --> F G -- no --> H{no customBaseUrl AND opencodeApiKey AND isCerebrasBaseUrl cerebrasBaseUrl?} H -- yes --> F H -- no --> I[wantsCerebras = false] F --> J{wantsCerebras AND any key or URL?} J -- yes --> K[Return cerebras config] J -- no --> L{localOptIn or customBaseUrl?} I --> L L -- yes --> M[Return eliza-local config] L -- no --> N{powerful model set?} N -- yes --> O[Return user opencode.json config] N -- no --> P[Return null]Reviews (2): Last reviewed commit: "Merge origin/develop into vendored openc..." | Re-trigger Greptile