Repository navigation
feat(guardian): add opencode-go DeepSeek provider over GitHub OIDC - #777
Conversation
) The finder moves to opencode-go / deepseek-v4.1-flash, so a review no longer needs an ANTHROPIC_API_KEY. The reusable workflow mints a short-lived inference token by exchanging a GitHub OIDC token; there is no static OPENCODE_API_KEY secret. Co-authored-by: Andrey Gromov <305761+zaebee@users.noreply.github.com>
There was a problem hiding this comment.
Code Review
This pull request adds support for the OpenCode Go provider, enabling DeepSeek model integration via an OpenAI-compatible gateway and supporting passwordless GitHub Actions OIDC authentication. The changes include the new provider implementation, runner integration, documentation updates, and comprehensive unit tests. The review feedback correctly identifies an opportunity to make the provider's initialization more robust against null values and simplifies the URL parsing logic.
Sonar flagged 25 duplicated lines between the new opencode provider and openrouter: the shared payload, temperature application, generate_content and generate_structured now live in providers/openai_compatible.py, with each provider keeping its own _payload (reasoning vs reasoning_effort). Also folds the OpenCode constructor's duplicate defaulting into one expression per the Gemini review. Co-authored-by: Andrey Gromov <305761+zaebee@users.noreply.github.com>
8f398a2 to
ff39b15
Compare
Parse the OIDC and token-exchange JSON with 'uv run --frozen python' instead of assuming python3 is on PATH, and skip sign-in when GUARDIAN_PROVIDER explicitly names another provider. The empty value still signs in so the minted key keeps opencode as the autodetected provider. Co-authored-by: Andrey Gromov <305761+zaebee@users.noreply.github.com>
|
|
/guardian review |
2 similar comments
|
/guardian review |
|
/guardian review |
There was a problem hiding this comment.
- [src/cgis/guardian/providers/base.py, src/cgis/guardian/providers/openai_compatible.py, src/cgis/guardian/providers/opencode.py, src/cgis/guardian/providers/openrouter.py, src/cgis/guardian/runner.py, tests/unit/test_guardian_runner.py]: ⚠ finder call failed
- [src/cgis/guardian/review_fingerprint.py]: ⚠ finder call failed
- [tests/unit/test_guardian_opencode.py]: ⚠ finder call failed
- [tests/unit/test_guardian_providers_name.py]: ⚠ finder call failed
- [tests/unit/test_guardian_review_script.py]: ⚠ finder call failed
- [tests/unit/test_guardian_workflow.py]: ⚠ finder call failed
- [tests/unit/test_review_fingerprint_closure.py]: ⚠ finder call failed
🤖 deepseek-v4.1-flash · graph 6/12 files (50%)
|
/guardian review |
There was a problem hiding this comment.
- [src/cgis/guardian/providers/base.py, src/cgis/guardian/providers/openai_compatible.py, src/cgis/guardian/providers/opencode.py, src/cgis/guardian/providers/openrouter.py, src/cgis/guardian/runner.py, tests/unit/test_guardian_runner.py]: ⚠ finder call failed
- [src/cgis/guardian/review_fingerprint.py]: ⚠ finder call failed
- [tests/unit/test_guardian_opencode.py]: ⚠ finder call failed
- [tests/unit/test_guardian_providers_name.py]: ⚠ finder call failed
- [tests/unit/test_guardian_review_script.py]: ⚠ finder call failed
- [tests/unit/test_guardian_workflow.py]: ⚠ finder call failed
- [tests/unit/test_review_fingerprint_closure.py]: ⚠ finder call failed
🤖 deepseek-v4.1-flash · graph 6/12 files (50%)
|
/guardian review |
There was a problem hiding this comment.
- [src/cgis/guardian/providers/base.py, src/cgis/guardian/providers/openai_compatible.py, src/cgis/guardian/providers/opencode.py, src/cgis/guardian/providers/openrouter.py, src/cgis/guardian/runner.py, tests/unit/test_guardian_runner.py]: ⚠ finder call failed
- [src/cgis/guardian/review_fingerprint.py]: ⚠ finder call failed
- [tests/unit/test_guardian_opencode.py]: ⚠ finder call failed
- [tests/unit/test_guardian_providers_name.py]: ⚠ finder call failed
- [tests/unit/test_guardian_review_script.py]: ⚠ finder call failed
- [tests/unit/test_guardian_workflow.py]: ⚠ finder call failed
- [tests/unit/test_review_fingerprint_closure.py]: ⚠ finder call failed
🤖 deepseek-v4.1-flash · graph 6/12 files (50%)



This is by an automated agent, not a human.
What changed
src/cgis/guardian/providers/opencode.py: a DeepSeek finder over the opencode-go OpenAI-compatible gateway (https://opencode.ai/inference/go/openai/v1), withmax_tokens, an explicitreasoning_effort(defaultlow), optionalGUARDIAN_TEMPERATURE, a client user agent and a stable per-runx-opencode-sessionheader. A 429 raisesOpenCodeQuotaError, any other HTTP error raises, and alengthfinish or a reasoning-only reply raises instead of being returned as a verdict._shared_payload,generate_content,generate_structured,response_formatand temperature application) intoproviders/openai_compatible.py, which OpenRouter and OpenCode Go both use. Each provider keeps its own_payloadwith its reasoning knob (reasoningvsreasoning_effort). This removes the duplication Sonar flagged.runner.build_providerunderopencode-go(canonical) andopencode(the provider's own hyphen-free name, from which the review fingerprint derives its module path). The model defaults todeepseek-v4.1-flash;GUARDIAN_MODEL,GUARDIAN_OPENCODE_EFFORTandGUARDIAN_OPENCODE_BASE_URLconfigure it, and auto-detection prefersOPENCODE_API_KEY. Anthropic and its explicit effort setting are unchanged.opencodeto the review fingerprint's known-provider set.id-token: write, and aSign in to OpenCode (OIDC)step exchanges the short-lived GitHub token for an inference token immediately before the review, writing it toGITHUB_ENV. There is no staticOPENCODE_API_KEYsecret, and the review step does not set that variable. The step parses JSON withuv run --frozen python(a self-hosted runner need not havepython3on PATH) and signs in only foropencode-go,opencode, or an unsetGUARDIAN_PROVIDER; an explicit other provider logs that OpenCode is not selected and skips.ANTHROPIC_API_KEYstays declared and passed.GUARDIAN_ANTHROPIC_EFFORTis no longer passed;GUARDIAN_OPENCODE_EFFORTis.guardian.yml) also grantsid-token: write.Verification
make format && make lint && make type-check && make pytest && make doc-coverage— all green.tests/unit/test_guardian_opencode.pycovers the default and overridden URL, bearer/user-agent/session headers,max_tokens, timeout,reasoning_effort, 429, other 4xx,finish_reason=length, emptycontentbesidereasoning_content, usage recording and structured output. The existing OpenRouter suite remains green after the shared-base extraction.id-tokenin both workflows, the absence of a static key, and the step's independence fromjq. The sign-in shell was also exercised against a fakecurlfor the missing-token, success and 4xx paths.Limitations
OPENCODE_CLIENT_IDfor the calling repository, and run/guardian review.Refs #775