Repository navigation
feat(review): add a GLM reviewer backend and make it the default - #675
Conversation
The release owner wants to compare GLM with IBM Bob as the PR reviewer,
starting with the next release.
- scripts/offload-review/backends/glm.sh: GLM through Claude Code
(`claude -p`) pointed at a gateway that serves GLM in the Anthropic
/v1/messages format. Tools, sessions and resume work as for Claude.
- The key is read at call time through apiKeyHelper from the file
that GLM_KEY_FILE names. It never enters the reviewer's
environment, so a reviewer that runs `env` cannot print it.
- The gateway URL and the model id come from the same file.
- Each reviewer has its own Claude Code config folder, .glm-cc/, in
its worktree. Round 1 fixes a session id, and round 2 resumes it
by id, because "latest" could pick the other reviewer's session.
- --max-turns (default 200) is the spend cap. Claude Code has no GLM
price, so --max-budget-usd would count nothing.
- scripts/offload-review.sh: glm is the default backend. The
changed-files check allows the .glm-cc/ folder.
- SKILL.md: lists both backends and what glm needs.
Bob stays available with --backend bob or OFFLOAD_BACKEND=bob.
Assisted-By: Claude
Signed-off-by: DAVID AMID <[email protected]>
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (bob, user of @amiddavid) | IBM Bob Shell 1.0.3 | offload-review skill, @amiddavid's session | fresh | 2 of 2 | 1 of 2 | 7d6c558c0636 |
approve |
Verdict: approve
Findings
None. The PR adds a GLM backend for the offload-review skill with proper security controls and documentation.
Non-blocking
-
Line 82 in glm.sh — Python inline script could use error handling
- The inline Python script that writes settings.json has no error handling. If the write fails (disk full, permissions), the script continues silently.
- Not blocking because: the next command (line 89-93) will fail when it tries to read the missing or corrupt file, and backend_run will return nonzero, which the caller handles.
- Consider: Add error handling in the Python script or check that settings.json exists and is readable after line 88.
-
Line 63 in glm.sh — Guard condition could be more explicit
- The guard
[[ $d == */.glm-cc ]] && [ "$d" != "/.glm-cc" ]protects against dangerous paths. The second check (not exactly "/.glm-cc") is good, but the pattern match allows paths like "x/.glm-cc" where x is empty or a relative path. - Not blocking because:
glm_dir()always returns$(pwd -P)/.glm-cc, which is an absolute path from a real directory. The worktree must exist for the backend to run. - Consider: Add an explicit check that
$dstarts with/to make the absolute-path requirement clear.
- The guard
-
Line 247 in offload-review.sh — Regex could be more specific
- The grep pattern
\.glm-cc/)$matches any file ending with.glm-cc/. A file namedfoo.glm-cc/would be ignored. - Not blocking because: Git does not track directories, only files. A file cannot end with
/. The pattern is correct forgit status --porcelainoutput, which shows directories with a trailing/. - No change needed. The pattern is correct.
- The grep pattern
What I checked
- Security: The GLM backend never exposes the API key in the reviewer's environment. The key is read at call time through
apiKeyHelper, which is a Python script that reads the key file. The key file path is the only secret-adjacent value in the settings file. The reviewer cannot print the key by runningenvin its shell. - Credential isolation: The backend unsets all Anthropic credential environment variables (line 106) and uses a private
CLAUDE_CONFIG_DIR(line 107) to keep the user's own settings out of the run. - Session management: Each reviewer gets its own session folder (
.glm-cc/) inside its worktree. The session ID is fixed in round 1 and resumed by ID in round 2. Two reviewers running at once cannot pick each other's session. - Cleanup: The
backend_cleanupfunction removes the.glm-cc/folder with proper guards (line 59-65). The guard checks that the path ends with/.glm-ccand is not exactly/.glm-cc. - Default change: The default backend changed from
bobtoglm(line 42 in offload-review.sh). The documentation (SKILL.md) lists both backends and saysglmis the default. - File filtering: The script now ignores
.glm-cc/when checking for files the reviewer changed (line 247). This is correct because the backend owns that folder. - Documentation: SKILL.md documents the GLM backend's environment requirements and explains that the key file is not in the repo. It also documents the cleanup behavior.
- Fail-open: If
GLM_KEY_FILEis not set or not readable,backend_runreturns 1 with a clear error message (line 69). The caller handles this as a reviewer failure. - Model variable override: The backend sets every Claude Code model variable to the GLM model (lines 98-102). This prevents Claude Code from asking the gateway for a Claude model it does not serve.
- Resume logic: The backend checks for an existing session with
backend_has_session(line 55-57). If the session-id file exists and is not empty, round 2 resumes that session. - Prompt handling: The backend reads the prompt from the file given as the first argument (line 108). It does not use a positional prompt, which is correct for Claude Code.
- Turn limit: The backend uses
OFFLOAD_MAX_TURNS(default 200) as the spend cap (line 109). This is documented in the header comment (line 21-22). - No changes outside the skill: The PR changes only the offload-review skill and its backends. It does not change any core code or other skills.
- ASD-STE100 style: The documentation uses short sentences, simple words, and active voice. The technical notes are in a separate section at the end.
- Commit message: Not checked (I cannot see the commit message from the diff).
- DCO sign-off: Not checked (I cannot see the commit metadata from the diff).
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (bob, user of @amiddavid) | IBM Bob Shell 1.0.3 | offload-review skill, @amiddavid's session | fresh | 1 of 2 | 1 of 2 | 7d6c558c0636 |
blocking |
Verdict: blocking
Findings
-
scripts/offload-review/backends/glm.sh:92 — Session creation fails silently when uuidgen is missing
- What fails: If
uuidgencommand is not available, the pipelineuuidgen | tr 'A-Z' 'a-z'creates an emptysession-idfile. Round 2 then tries to resume with an empty session id, which fails. - Proof: Line 92 has no error check. Line 90 in
backend_runuses$(cat "$d/session-id")which would be empty. The--resume ""argument toclaudewould fail. - Fix: Check that
uuidgenexists before using it, or use a fallback method. Addcommand -v uuidgen >/dev/null || { echo "glm backend: uuidgen not found" >&2; return 1; }before line 92.
- What fails: If
-
scripts/offload-review/backends/glm.sh:82-88 — Settings file write has no error handling
- What fails: The Python script writes
settings.jsonwithopen(out, "w")but does not catch write errors. If the write fails (disk full, permission denied), the script exits 0 andbackend_runcontinues. Theclaudecommand then fails with a confusing error about missing or invalid settings. - Proof: Lines 82-88 use
python3 -I -with no error handling in the Python code. The bashset -edoes not catch Python exceptions. A write failure would makeclaudefail at line 108. - Fix: Wrap the Python
open()andjson.dump()in a try-except block, or check the exit code and validate thatsettings.jsonexists and is readable before callingclaude.
- What fails: The Python script writes
-
scripts/offload-review/backends/glm.sh:109 — No check that claude command exists
- What fails: If
claudeis not installed or not in PATH, the script fails with "command not found" instead of a clear error message. - Proof: Line 109 invokes
claudedirectly. No prior check exists. The error would be "claude: command not found" from the shell, not a backend error message. - Fix: Add
command -v claude >/dev/null || { echo "glm backend: claude command not found" >&2; return 1; }at the start ofbackend_run.
- What fails: If
-
scripts/offload-review/backends/glm.sh:63 — Cleanup guard is incomplete for edge case
- What fails: If
pwd -Preturns/(root directory), thendbecomes/.glm-cc. The check[ "$d" != "/.glm-cc" ]passes, butrm -rf /.glm-ccwould still be dangerous. - Proof: Line 61 sets
d=$(glm_dir)which is$(pwd -P)/.glm-cc. Line 63 checks[[ $d == */.glm-cc ]] && [ "$d" != "/.glm-cc" ]. Ifpwd -Pis/, the second condition fails, but the first passes. The||makes the whole expression fail, sormdoes not run. However, the error message "bad dir" is misleading. - Fix: This is extremely unlikely in practice (worktrees are never at root), but for completeness, add a check that
dcontains at least two path components:[[ $d =~ ^/.+/.glm-cc$ ]].
- What fails: If
Non-blocking
-
Documentation clarity: SKILL.md line 21-22 says "GLM has no price in Claude Code's table, so a turn limit is the spend cap". This implies
--max-budget-usdwould not work, but the doc does not state this explicitly. Consider adding: "The--max-budget-usdflag does not count GLM tokens." -
Consistency: The new backend changes the default from
bobtoglm, which is documented. However, users withOFFLOAD_BACKENDset will not see the change. This is correct behavior, but worth noting in the commit message or PR description.
What I checked
- Read every changed line in the diff (3 files: SKILL.md, offload-review.sh, glm.sh)
- Verified credential handling: key never enters reviewer environment, uses
apiKeyHelperpattern correctly - Checked fail-open behavior: errors return non-zero, script handles them
- Verified
.glm-cc/exclusion in git status validation (line 249 of offload-review.sh) - Confirmed documentation updates match code changes
- Checked that backend interface is correctly implemented (all 4 required functions)
- Verified session isolation: each reviewer gets its own config folder and session id
- Checked environment variable isolation: all credential variables properly unset
- Confirmed the cleanup function guards against dangerous paths
- Verified that the default change is documented in both SKILL.md and offload-review.sh
From reviewer 1 of #675, round 1, findings 1 and 3. uuidgen is not on every Linux box; python3 is already required by this backend. Assisted-By: Claude Signed-off-by: DAVID AMID <[email protected]>
|
Author reply to reviewer 1, round 1 (head
Non-blocking points: noted. The PR body already says that |
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (bob, user of @amiddavid) | IBM Bob Shell 1.0.3 | offload-review skill, @amiddavid's session | resumed | 1 of 2 | 2 of 2 | 37c39d9d9f39 |
approve |
Verdict: approve
Findings
None. All blocking findings from round 1 are resolved.
Status of round 1 findings
-
Session creation with missing uuidgen: FIXED in commit 37c39d9. The backend now uses
python3 -c 'import uuid; print(uuid.uuid4())'to generate the session id (line 94). It checks that the file is non-empty (line 95) and fails with a clear message if not. -
Settings file write error handling: REJECTED, and the rejection is correct. I claimed the Python script "exits 0" on an exception. This is wrong. An uncaught Python exception exits with code 1. The script runs under
set -euo pipefail(offload-review.sh:35), so a failed write stops execution beforeclaudestarts. No change needed. -
No check for claude command: FIXED in commit 37c39d9. Line 69 now checks
command -v claudeand fails with "claude (Claude Code) is not on PATH" if it is missing. -
Cleanup guard for root path: REJECTED, and the rejection is correct. When
dis/.glm-cc, the expression[[ $d == */.glm-cc ]] && [ "$d" != "/.glm-cc" ]is false (the second condition fails), so the||makes the guard return 1 beforermruns. The code is safe. No change needed.
Non-blocking
- Reviewer 2's non-blocking point about the Python inline script (their finding 1) is the same as my rejected finding 2. The author's response covers it.
What I checked
- Last review: round 1, 7d6c558, 2026-10-23T07:48:51Z
- New commits read: 1 commit (37c39d9 "fix(review): check for claude, and make the session id with python3")
- Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
- New items since my last review:
- Commit 37c39d9: fixes findings 1 and 3 from my round 1 review
- Author comment at 2026-10-23T07:50:13Z: replies to all 4 findings, with fixes for 1 and 3, and correct rejections for 2 and 4
- Reviewer 2's round 1 review at 2026-10-23T07:48:06Z: verdict approve, no blocking findings, 3 non-blocking points (one overlaps with my rejected finding 2)
- Verified the fixes:
- Line 69:
command -v claudecheck is present - Line 94: session id now comes from
python3 -c 'import uuid; print(uuid.uuid4())' - Line 95: checks that session-id file is non-empty with
[ -s "$d/session-id" ]
- Line 69:
- Re-checked my rejected findings:
- Finding 2: I was wrong about "exits 0". Python exceptions exit with code 1, and
set -euo pipefailstops the script there. - Finding 4: The guard is correct. When
dis/.glm-cc, the whole expression is false, sormdoes not run.
- Finding 2: I was wrong about "exits 0". Python exceptions exit with code 1, and
- Checked that no new issues were introduced by the fixes
- Verified the commit message follows conventions: "fix(review):" prefix, references the PR and findings, includes DCO sign-off
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (bob, user of @amiddavid) | IBM Bob Shell 1.0.3 | offload-review skill, @amiddavid's session | resumed | 2 of 2 | 2 of 2 | 37c39d9d9f39 |
approve |
Verdict: approve
Findings
None. All fixes from round 1 are correct.
Review of round 1 findings
Reviewer 1's findings:
-
Session creation fails when uuidgen is missing: FIXED
- Line 93 now uses
python3 -I -c 'import uuid; print(uuid.uuid4())'instead ofuuidgen. - Line 94 checks that the session-id file is not empty and fails with a clear message if it is.
- The fix is correct. Python3 is already required by this backend.
- Line 93 now uses
-
Settings file write has no error handling: REJECTED, correctly
- The author's rejection is correct. An uncaught Python exception exits with code 1, not 0.
- The script runs under
set -euo pipefail(offload-review.sh:35), so a failed write stops the run immediately. - The
claudecommand never starts when the write fails.
-
No check that claude command exists: FIXED
- Line 68 now checks
command -v claude >/dev/nulland fails with "claude (Claude Code) is not on PATH" if it is missing. - The fix is correct.
- Line 68 now checks
-
Cleanup guard is incomplete for edge case: REJECTED, correctly
- The author's rejection is correct. When
d=/.glm-cc, the guard[[ $d == */.glm-cc ]] && [ "$d" != "/.glm-cc" ]evaluates to false (first condition true, second false, so&&returns false), which triggers the||and returns 1. - The
rmon line 64 never runs. No change is needed.
- The author's rejection is correct. When
My round 1 non-blocking points:
All three remain valid observations but are not blocking. No changes were made to address them, which is correct for non-blocking items.
Non-blocking
None new. The round 1 non-blocking points still apply.
What I checked
- Last review: round 1, 7d6c558, 2026-10-23T07:48:06Z
- New commits read: 1 commit (37c39d9 "fix(review): check for claude, and make the session id with python3")
- Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
- New items since my last review:
- Reviewer 1's round 1 review (2026-10-23T07:48:51Z): read all 4 findings and verified each one
- Author's reply comment (2026-10-23T07:50:13Z): read the response to each finding
- New commit 37c39d9: read the full diff and verified the fixes
Verification of fixes:
- Line 68:
command -v claudecheck added (fixes finding 3) - Line 93:
python3 -I -c 'import uuid; print(uuid.uuid4())'replacesuuidgen | tr 'A-Z' 'a-z'(fixes finding 1) - Line 94:
[ -s "$d/session-id" ]check added with error message (fixes finding 1) - No changes for findings 2 and 4, which were correctly rejected
Verification of rejections:
- Finding 2: Confirmed that uncaught Python exceptions exit with code 1, and
set -ecatches them - Finding 4: Confirmed that the guard prevents
rmfrom running whend=/.glm-cc
Security review (unchanged from round 1):
- API key still never enters the reviewer's environment
- Credential isolation still correct
- Session management still correct
- All security controls from round 1 remain intact
Commit metadata:
- DCO sign-off: present (
Signed-off-by: DAVID AMID <[email protected]>) - AI attribution: present (
Assisted-By: Claude) - Commit message: follows conventional commit format (
fix(review): ...)
…ude Code (#679) feat(review): fall back to the next reviewer backend, ending with Claude Code When GLM was made the default (#675), a colleague without a GLM key file got a failed review at once: there was no fallback. - Each reviewer now tries the backends in order: the chosen one, then OFFLOAD_FALLBACK (default "bob claude"). So the default order is glm, then bob, then claude. - The next backend runs only when the reviewer has not posted a review of this round and head. A reviewer never posts twice. - A backend may define backend_ready. One that is not set up (no key file, no bob command) is skipped without a run. - Each backend has its own worktree, review-pr<N>-<backend>-r<1|2>, so its session files never mix with another backend's. - In round 2 each reviewer starts with the backend that wrote its round-1 review, so it resumes that session. - The marker names the backend that wrote the review, and the last line lists the backend of each reviewer. - --no-fallback (or OFFLOAD_FALLBACK="") turns it off, to compare one backend with another. - New backend claude.sh: the user's own Claude Code, with OFFLOAD_CLAUDE_MODEL to pick the model. - Worktree creation takes a lock, because with fallback the two reviewers can create worktrees at the same moment. Assisted-By: Claude Signed-off-by: DAVID AMID <[email protected]> fix(review): read the PR's reviews whole before grep in posted_now Found by both GLM reviewers of #679, round 1. Under pipefail, `gh api ... | grep -q` fails with SIGPIPE when gh writes after grep has matched. A posted review then reads as missing, and the next backend posts a second review of the same reviewer. posted_now now saves the answer, then greps it, as posted() does. A gh failure counts as posted, so an uncertain answer stops the chain. The final check still reports a review that is really missing. Assisted-By: Claude Signed-off-by: DAVID AMID <[email protected]>
Summary
--backend boborOFFLOAD_BACKEND=bob.What changed
scripts/offload-review/backends/glm.sh(new): GLM through Claude Code.claude -ppoints at a gateway that serves GLM in the Anthropic/v1/messagesformat, so tools, sessions and resume work as they do for Claude.apiKeyHelper, from the JSON file thatGLM_KEY_FILEnames. A reviewer that runsenvin its shell cannot print it..glm-cc/, in its worktree. Round 1 fixes a session id, and round 2 resumes that id.latestcould pick the other reviewer's session.--max-turns(default 200) is the spend cap. Claude Code has no price for GLM, so--max-budget-usdwould count nothing.scripts/offload-review.sh:glmis the default backend. The check for changed files allows.glm-cc/.SKILL.md: lists both backends, and whatglmneeds.The gateway host, the key file path and the key are internal. None of them is in this PR.
How it was tested
On the laptop, with the backend sourced in a scratch git folder:
bash -non both scriptsANTHROPIC_AUTH_TOKENandANTHROPIC_API_KEYare both unset in its shell.glm-cc/includedbackend_cleanupremoves.glm-cc/The first real two-reviewer run is this PR's own review, with
--backend bob.Open questions
🤖 Generated with Claude Code