Skip to content

fix(orchestrator): use vendored OpenCode endpoint detection#7823

Merged
lalalune merged 2 commits into
developfrom
nubs/vendor-opencode-cerebras-endpoint-20260520
May 20, 2026
Merged

fix(orchestrator): use vendored OpenCode endpoint detection#7823
lalalune merged 2 commits into
developfrom
nubs/vendor-opencode-cerebras-endpoint-20260520

Conversation

@NubsCarson

@NubsCarson NubsCarson commented May 20, 2026

Copy link
Copy Markdown
Member

Summary

  • update the vendored OpenCode submodule to include elizaOS/opencode#3 / 5a58f5c endpoint detection
  • parse Cerebras base URLs by hostname in the orchestrator OpenCode spawn config instead of matching arbitrary URL text
  • remove the stale PR-number reference from the vendored OpenCode shim comments

Why

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.ai or gateway.cerebras.ai use the Cerebras provider, while unrelated proxy URLs that merely contain cerebras.ai in 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.ts
  • bun test --timeout 30000 test/provider/provider.test.ts test/provider/transform.test.ts -> 331 passed, 0 failed
  • bun run typecheck was checked; current dev still has two baseline errors unrelated to this patch (OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX flag typing and missing ../../src/project/with-instance in test/acp/event-subscription.test.ts)

Eliza orchestrator after merging latest origin/develop:

  • git diff --check
  • bunx 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 failed
  • bun run typecheck && bun run build in plugins/plugin-agent-orchestrator -> passed

Notes

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 URL API, and bumps the vendored OpenCode submodule to 5a58f5cee which includes the same fix upstream.

  • isCerebrasBaseUrl now parses the URL and checks only the hostname field (cerebras.ai or *.cerebras.ai), preventing false positives when cerebras.ai appears only in a URL path segment.
  • Two new tests validate subdomain detection and the false-positive case; the stale vault-pointer test string is cleaned up.
  • Shim comments in bin/opencode and bin/opencode.cmd drop 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

Filename Overview
plugins/plugin-agent-orchestrator/src/services/opencode-config.ts isCerebrasBaseUrl replaced regex with URL hostname parsing; handles invalid URLs via try/catch; logic is correct and more precise
plugins/plugin-agent-orchestrator/tests/unit/opencode-spawn-config-auto-detect.test.ts Two new tests cover subdomain detection and false-positive prevention for path-only matches; vault test string cleaned up
plugins/plugin-agent-orchestrator/vendor/opencode Submodule pointer bumped from 8a86b585c to 5a58f5cee to pull in elizaOS/opencode#3 endpoint detection
plugins/plugin-agent-orchestrator/bin/opencode Shim comment updated to remove stale PR reference; functional behavior unchanged
plugins/plugin-agent-orchestrator/bin/opencode.cmd Windows shim comment updated in parallel with bash shim; no functional change

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]
Loading

Reviews (2): Last reviewed commit: "Merge origin/develop into vendored openc..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6e8af610-b9b8-4030-aefe-6f11aea82882

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch nubs/vendor-opencode-cerebras-endpoint-20260520

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@claude

claude Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

@claude

claude Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

@lalalune
lalalune merged commit 170cecd into develop May 20, 2026
25 of 29 checks passed
@lalalune
lalalune deleted the nubs/vendor-opencode-cerebras-endpoint-20260520 branch May 20, 2026 02:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants