Repository navigation
fix(providers): keep OpenCode's internal plugins so OAuth logins work - #810
Conversation
OPENCODE_DISABLE_DEFAULT_PLUGINS=1 skips every internal OpenCode plugin. In OpenCode 1.18.33 those plugins implement the OAuth logins (ChatGPT via CodexAuthPlugin, Copilot, GitLab, ...) and only register auth and chat.headers/chat.params hooks, no tools. With the flag set, an OAuth login is never attached and every call fails with "Unexpected server error", although the sandbox is meant to keep the user's existing login usable. Tool access stays denied by the deny-all agent and OPENCODE_PERMISSION, and external plugins stay off through --pure / OPENCODE_PURE. Fixes NVIDIA#809 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: elliottwaves-20 <pail1217@web.de>
…scrub The _build_opencode_argv docstring still said the runner disables plugins; only external plugins are off, the internal OAuth/provider plugins stay enabled. The isolation test now also feeds an ambient OPENCODE_DISABLE_DEFAULT_PLUGINS=1, which the sandbox must scrub so a user environment cannot switch the OAuth logins back off. Refs NVIDIA#809 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: elliottwaves-20 <pail1217@web.de>
|
Follow-up after an independent review of this change (pushed as 22cec46):
Verified against OpenCode One known limitation, not addressed here so the PR stays minimal: with OAuth working, a token refresh writes the real |
|
End-to-end check with a real ChatGPT OAuth login (OpenCode 1.18.33,
The same login works with a plain A side note for anyone patching this downstream instead of waiting for the merge: run_agent_cli reads the builder from |
rng1995
left a comment
There was a problem hiding this comment.
[SkillSpector Review]
@elliottwaves-20 thank you for the precise root cause, the source-level evidence, and the live before/after check with a real ChatGPT login.
Value and readiness
OPENCODE_DISABLE_DEFAULT_PLUGINS=1 makes OpenCode 1.18.33 skip its internal plugins, and those plugins implement the OAuth logins (ChatGPT, Copilot, GitLab, and others), so opencode_cli failed on every call for OAuth users. Dropping only that variable restores the documented intent ("use the user's existing login") and keeps the isolation:
- External plugins stay off through
--pure/OPENCODE_PURE=1, and the policy preflight still requires a resolvedplugin: []. - Tools stay denied by the per-invocation deny-all agent and
OPENCODE_PERMISSION. - An inherited
OPENCODE_DISABLE_DEFAULT_PLUGINSis dropped by the allowlist scrub, and the test now pins that.
Ready for maintainer review.
Material findings
None blocking. Optional:
- Optional: leaving internal plugins enabled is safe only while none of them registers
tool,tool.execute.*,permission.ask,shell.envorconfighooks. That holds at 1.18.33, but nothing re-checks it when_OPENCODE_SUPPORTED_VERSIONmoves. A short note next to the pin in_agent_cli.pywould carry this into the bump checklist. - Optional: the refresh-token race you describe deserves a tracking issue. With OAuth now working, parallel
opencode runprocesses can rotate the same refresh token. #808 would lower the CLI default fan-out to 2, which narrows the race but does not remove it.
PIC tradeoffs
- All 12 internal plugins now initialize in every sandboxed call. Two of them (
opencode-gitlab-auth,opencode-poe-auth) are third-party npm packages compiled into the OpenCode binary, not fetched at runtime, and their hooks only act for their own providers. Accepting them is the price of OAuth support.
Verification and gaps
- Read the full diff,
_prepare_opencode_env,_preflight_opencode_policyand the_RUNTIME_ENV_NAMESallowlist at the head. - Read OpenCode
v1.18.33(anomalyco/opencode)plugin/index.ts: internal plugins are "directly imported (not installed from npm)" and gated only byflags.disableDefaultPlugins, while external plugins are gated byflags.pure. Also readruntime-flags.tsand the nine in-tree plugin files (codex, copilot, modal, cloudflare, azure, digitalocean, xai, cerebras, snowflake-cortex). They registerauth,providerandchat.params/chat.headersonly; I found no tool, shell, permission or config hooks and no process spawning. - Not inspected: the two npm-sourced plugins. I did not run OpenCode.
- All six CI checks pass, and the PR merges cleanly into
main.
Summary
Fixes #809. With the
opencode_cliprovider, OpenCode logins that use OAuth (ChatGPT Plus/Pro viaopencode auth login→ OpenAI, GitHub Copilot, GitLab, …) fail on every call withUnexpected server error. The sandbox env setsOPENCODE_DISABLE_DEFAULT_PLUGINS=1, which in OpenCode 1.18.33 skips all internal plugins — and the OAuth logins are internal plugins. This PR stops setting that one variable.Why this keeps the isolation
At OpenCode
v1.18.33,packages/opencode/src/plugin/index.tsloadsinternalPlugins()only when the flag is unset:The list is
CodexAuthPlugin,CopilotAuthPlugin,ModalPlugin,GitlabAuthPlugin,PoeAuthPlugin,CloudflareWorkersAuthPlugin,CloudflareAIGatewayAuthPlugin,AzureAuthPlugin,DigitalOceanAuthPlugin,SnowflakeCortexAuthPlugin,XaiAuthPlugin,CerebrasPlugin. None of them registers atoolhook; they provideauthpluschat.headers/chat.paramsfor their own provider. Everything else stays as it is:OPENCODE_PERMISSION(unchanged)--pureandOPENCODE_PURE=1(unchanged, still asserted in the test)The
_prepare_opencode_envdocstring already states the intent ("The real OpenCode authentication store remains available so this CLI provider can use the user's existing login"); it now also says why internal plugins stay enabled.Changes
src/skillspector/providers/_agent_cli.py: dropOPENCODE_DISABLE_DEFAULT_PLUGINSfrom the sandbox env; docstring explains the reason.tests/provider/test_opencode_cli.py:test_policy_overrides_hostile_ambient_configurationnow asserts the variable is absent (with a comment pointing to opencode_cli: OPENCODE_DISABLE_DEFAULT_PLUGINS breaks OAuth logins (ChatGPT, Copilot) #809); theOPENCODE_PUREassertion stays.Testing
pytest tests/provider/→ 43 passed, 3 skipped (the changed assertion failed before the fix).ruff check/ruff format --checkon both files: clean.openai/gpt-6-luna, using SkillSpector's own_build_opencode_argv+_prepare_opencode_env: before the fixexit 1, "Unexpected server error"; after the fixexit 0, the model answers.