Skip to content

fix: route GLM document seats through Z.AI directly - #52

Merged
alanshurafa merged 1 commit into
masterfrom
codex/glm-direct-api
Aug 29, 2026
Merged

fix: route GLM document seats through Z.AI directly#52
alanshurafa merged 1 commit into
masterfrom
codex/glm-direct-api

Conversation

@alanshurafa

Copy link
Copy Markdown
Owner

Summary

  • route GLM document passes through Z.AI Chat Completions instead of Claude Code
  • keep the bearer token in a mode-600 temporary curl config and remove it on exit
  • support native Git Bash, macOS/Linux, and WSL with curl + jq prerequisites
  • update MCP preflight, hermetic coverage, setup docs, and cost/routing guidance

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

  • live Z.AI direct-adapter bounce: converged with the complete Markdown artifact
  • document seat simulation: 9/9
  • reliability simulation: 37/37
  • docs sync: 38/38
  • MCP: 9/9
  • shell syntax and git diff check

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>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-29T20:32:14.056609Z af7622a PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread lib/co-evolution.sh
Comment on lines +645 to +648
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"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment thread mcp/src/bouncer.ts
Comment on lines 166 to +171
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",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread lib/co-evolution.sh
Comment on lines +624 to +629
jq -Rs --arg model "${GLM_MODEL:-glm-5.3-flash}" '{
model: $model,
messages: [{role: "user", content: .}],
stream: false,
temperature: 0
}' "$prompt_file" > "$request_file"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@alanshurafa
alanshurafa merged commit b41a92a into master Aug 29, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant