fix: route GLM document seats through Z.AI directly - #52
Conversation
Replace the incompatible Claude Code transport with Z.AI Chat Completions, keep bearer credentials out of argv, support WSL, and align MCP prerequisites, tests, routing guidance, and cost documentation. Co-Authored-By: Codex <noreply@openai.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: af7622a218
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (( curl_rc == 0 )) \ | ||
| && jq -e '.choices[0].message.content | type == "string" and length > 0' \ | ||
| "$response_file" >/dev/null 2>&1; then | ||
| jq -r '.choices[0].message.content' "$response_file" > "$output_file" |
There was a problem hiding this comment.
Reject truncated GLM responses
When Z.AI returns HTTP 200 with nonempty content but finish_reason: "length"—for example, when a long bounce exceeds the completion allowance—this condition accepts the partial Markdown and replaces the working document with it. Downstream validation only checks whether the artifact is nonempty or resembles an error, so the run can report convergence after silently truncating the document; require a successful finish reason before extracting the content and classify length/content-filter stops as failures.
Useful? React with 👍 / 👎.
| if (agents.includes("glm")) { | ||
| if ( | ||
| (process.env.WSL_DISTRO_NAME && findOnPath("cmd.exe")) || | ||
| isWslLauncher(bashPath) | ||
| ) { | ||
| if (!findOnPath("curl")) { | ||
| throw runtimeError( | ||
| "glm", | ||
| "native_claude_dispatch", | ||
| "glm seat unsupported under WSL claude dispatch", | ||
| "curl", | ||
| "glm seat requires curl for the direct Z.AI API", |
There was a problem hiding this comment.
Remove the stale Claude prerequisite for MCP GLM runs
For an MCP call selecting glm,glm or glm,kimi on a machine with curl, jq, and a Z.AI key but no Claude CLI, server.ts invokes preflight() before reaching this direct adapter, and preflight.ts:46-47 still adds claude whenever GLM is selected. The tool therefore rejects the advertised Claude-independent route as missing a prerequisite; update the MCP preflight dependency set and its tests to match the new direct transport.
AGENTS.md reference: AGENTS.md:L185-L187
Useful? React with 👍 / 👎.
| jq -Rs --arg model "${GLM_MODEL:-glm-5.3-flash}" '{ | ||
| model: $model, | ||
| messages: [{role: "user", content: .}], | ||
| stream: false, | ||
| temperature: 0 | ||
| }' "$prompt_file" > "$request_file" |
There was a problem hiding this comment.
Honor or reject GLM effort overrides
When a GLM role is configured with --reviewer-effort, --composer-effort, or GLM_EFFORT, apply_role_seat still stores the value and the run metadata reports it, but this request body never uses it. Before this change the value reached Claude as --effort; now the accepted option silently has no effect, so map it to the direct API's corresponding control or reject it explicitly as is done for Kimi.
Useful? React with 👍 / 👎.
Summary
Why
Live smoke testing showed Claude Code/Z.AI returning only internal system-warning metadata for a full Bounce Protocol prompt. The documented direct Z.AI endpoint returned clean model text and preserved the complete Markdown artifact.
Test plan