Skip to content

Commit eab2045

Browse files
AICtrl Botclaude
andcommitted
fix: use custom provider to route OpenCode through hush proxy
OpenCode's built-in providers ignore options.baseURL from opencode.json (anomalyco/opencode#5674). Define a custom "hush-zhipu" provider with npm adapter @ai-sdk/openai-compatible so the baseURL is actually respected and all LLM traffic routes through the hush gateway. Verified locally: hush logs show requests at /api/coding/paas/v4/chat/completions with tokenCount > 0 (PII redaction active). Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent f43c082 commit eab2045

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

‎.github/workflows/opencode-review.yml‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,14 @@ jobs:
103103
curl -fsSL https://opencode.ai/install | bash -s -- --no-modify-path
104104
echo "$HOME/.opencode/bin" >> $GITHUB_PATH
105105
106-
# Configure OpenCode to route through hush proxy + hush plugin
106+
# Configure OpenCode with custom provider routing through hush proxy.
107+
# NOTE: Overriding baseURL on built-in providers (zai-coding-plan) does not
108+
# work — OpenCode's bundled @ai-sdk/openai-compatible ignores options.baseURL
109+
# (see anomalyco/opencode#5674). Instead, we define a new custom provider
110+
# "hush-zhipu" that explicitly sets baseURL via the npm adapter.
107111
mkdir -p .opencode/plugins
108112
cp examples/team-config/.opencode/plugins/hush.ts .opencode/plugins/hush.ts
109-
printf '%s\n' '{"provider":{"zai-coding-plan":{"options":{"baseURL":"http://127.0.0.1:4000/api/coding/paas/v4"}}},"plugin":[".opencode/plugins/hush.ts"]}' > opencode.json
113+
printf '%s\n' '{"provider":{"hush-zhipu":{"npm":"@ai-sdk/openai-compatible","name":"Hush ZhipuAI Proxy","options":{"baseURL":"http://127.0.0.1:4000/api/coding/paas/v4","apiKey":"{env:ZHIPU_API_KEY}"},"models":{"glm-5":{"name":"GLM 5"},"glm-4.7-flash":{"name":"GLM 4.7 Flash"}}}},"plugin":[".opencode/plugins/hush.ts"]}' > opencode.json
110114
111115
- name: Direct OpenCode Review
112116
if: steps.check_changes.outputs.skip != 'true'
@@ -116,11 +120,11 @@ jobs:
116120
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117121
run: |
118122
SHA=${{ github.event.pull_request.head.sha || github.sha }}
119-
echo "Starting review with GLM-5 for SHA $SHA..."
123+
echo "Starting review with hush-zhipu/glm-5 for SHA $SHA..."
120124
echo "opencode.json:"; cat opencode.json
121125
echo "Hush health:"; curl -sf http://127.0.0.1:4000/health || echo "gateway unreachable"
122126
123-
$HOME/.opencode/bin/opencode run --model zai-coding-plan/glm-5 "Review the changes in this PR for the Hush Semantic Gateway.
127+
$HOME/.opencode/bin/opencode run --model hush-zhipu/glm-5 "Review the changes in this PR for the Hush Semantic Gateway.
124128
125129
**IMPORTANT**: This is a code review only. Do NOT run tests, npm commands, or build commands. Only read source files and git diffs.
126130

‎examples/team-config/opencode.json‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
{
22
"provider": {
3-
"zai-coding-plan": {
3+
"hush-zhipu": {
4+
"npm": "@ai-sdk/openai-compatible",
5+
"name": "Hush ZhipuAI Proxy",
46
"options": {
5-
"baseURL": "http://127.0.0.1:4000/api/coding/paas/v4"
7+
"baseURL": "http://127.0.0.1:4000/api/coding/paas/v4",
8+
"apiKey": "{env:ZHIPU_API_KEY}"
9+
},
10+
"models": {
11+
"glm-5": { "name": "GLM 5" },
12+
"glm-4.7-flash": { "name": "GLM 4.7 Flash" }
613
}
714
}
815
},

0 commit comments

Comments
 (0)