[codex] add GLM 5.2 and OpenAI-compatible endpoint mode#44
Merged
Conversation
This was referenced Jun 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds two related Workers AI chat-model updates for
langchain-cloudflare:@cf/zai-org/glm-5.2across model behavior, examples, REST integration coverage, and Worker integration coverage.endpoint_format="openai_compatible"toChatCloudflareWorkersAIso REST callers can route chat requests through Cloudflare's OpenAI-compatible chat completions endpoint.The default remains
endpoint_format="workers_ai", which preserves existing/ai/run/{model}behavior. The OpenAI-compatible mode is REST-only; Worker bindings still useenv.AI.run()and now raise clearly if that mode is requested with a binding.Current Status
CI follow-up commits fixed the first runner failures and the separate Worker example dependency issue:
2d6a114fixes mypy under CI's newer floating dependency resolution and newerlangchain-testsmodel-override conformance.54fef21fixes the Worker example dependency layout that triggered the separate Dependabot security-update error onmain.langchainin[project.dependencies];pywrangler synckeeps only Pyodide-compatible dependencies, andscripts/setup_pyodide_deps.shremains responsible for the known-workingcreate_agentvendored stack.create_agentintegration tests now fail on501instead of skipping, so unavailablecreate_agentis no longer hidden.AI Gateway update: the account now has the
test-ai-gatewaygateway configured. Targeted Worker binding and REST AI Gateway tests pass against it.Why
Cloudflare's native Workers AI run endpoint and OpenAI-compatible chat completions endpoint can behave differently for multimodal and structured-output workflows. This exposes the endpoint choice directly without changing existing defaults.
GLM-5.2 is also now registered with model-specific parameter handling so it keeps supported OpenAI-compatible fields like
max_tokensandtool_choicewhile stripping unsupported fields liketop_kandrepetition_penalty.User Impact
Users can now instantiate:
and continue using the existing default behavior without changes:
Validation
make lint- passed (ruff check,ruff format --diff, mypy)make test- 110 passed, 2 skippedpre-commit run --all-files- passeduv run pytest --disable-socket --allow-unix-socket tests/unit_tests/test_chat_models.py -q- 57 passed, 2 skipped before the CI follow-up test was addeduv run pytest tests/integration_tests/test_workersai_models.py::TestOpenAICompatibleEndpoint -v -s- 3 passeduv run pytest tests/integration_tests/test_worker_integration.py::TestWorkerAIGateway -v -s- 3 passedAI_GATEWAY=test-ai-gateway uv run pytest tests/integration_tests/test_workersai_models.py::TestAIGatewayHeaders -v -s- 3 passedcd examples/workers && uv run pywrangler sync --force- passedcd examples/workers && ./scripts/setup_pyodide_deps.sh- passed; installs the known-working LangChain 1.0 Worker stackcreate_agentcoverage on Qwen - 3 passed:TestWorkerAgentTools::test_agent_tools[@cf/qwen/qwen3-30b-a3b-fp8]TestWorkerAgentStructuredOutput::test_agent_structured_output[@cf/qwen/qwen3-30b-a3b-fp8]TestWorkerAgentStructuredJsonSchema::test_agent_structured_json_schema[@cf/qwen/qwen3-30b-a3b-fp8]uv run pytest tests/integration_tests/test_workersai_models.py -v -s- 128 passed, 64 skipped, 1 failedtest-ai-gatewaywas configured:uv run pytest tests/integration_tests/test_worker_integration.py -v -s- 158 passed, 6 skipped, 5 failedKnown Unrelated Failures
Full REST integration has the known Mistral structured-output batch failure where one result returns
None.Full Worker integration has known/environment-sensitive model-output failures:
NoneNoneA targeted Worker rerun reproduced the Mistral and gpt-oss-20b structured-output batch failures while gpt-oss-120b passed, which points to model-output quality rather than this endpoint-routing change.