Skip to content

feat(bedrock): add GLM-5 reasoning support on AWS Bedrock#28264

Open
lopince wants to merge 14 commits into
anomalyco:devfrom
lopince:feat/bedrock-glm-reasoning
Open

feat(bedrock): add GLM-5 reasoning support on AWS Bedrock#28264
lopince wants to merge 14 commits into
anomalyco:devfrom
lopince:feat/bedrock-glm-reasoning

Conversation

@lopince

@lopince lopince commented May 19, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #28168

Type of change

  • New feature

What does this PR do?

Adds reasoning control for ZAI GLM-5 models on AWS Bedrock. Bedrock exposes GLM reasoning via additionalModelRequestFields.reasoning_config, which is different from the existing Anthropic thinking and Nova reasoningConfig patterns.

GLM models only support a binary thinking toggle (not graduated effort levels), so we expose a single high variant — following the same convention as Anthropic and Nova on Bedrock where selecting an effort level enables reasoning. The variant sends reasoning_config: "high" to Bedrock.

Also fixes a tool-call replay bug: GLM streams tool args as partial strings, and Bedrock Converse rejects string toolUse.input on history replay. The fix coerces them back to JSON objects.

Usage

Set variant: "high" in your agent config:

{ "agent": { "variant": "high" } }

Reasoning is disabled by default — only enabled when the variant is explicitly selected. Same pattern as variant: "high" for Nova or variant: "max" for Anthropic on Bedrock.

How did you verify your code works?

  • Ran locally against Bedrock GLM endpoints with reasoning enabled
  • Confirmed tool-call history replay no longer triggers Bedrock validation errors
  • Verified that when no variant is selected, no reasoning_config is sent

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

lopince and others added 6 commits May 18, 2026 17:53
- Add reasoning_config variants (default/low/medium/high) via
  additionalModelRequestFields for GLM models on Bedrock
- Add safety fallback in options() defaulting to reasoning_config "medium"
- Add smallOptions() fallback using reasoning_config "low" for
  title/summary calls that bypass the variant system
- Fix normalizeMessages() to coerce GLM tool-call string inputs back to
  JSON objects (Bedrock Converse rejects string toolUse.input on replay)
- Add topP=0.95 for GLM models
- Add glm.txt system prompt tailored for GLM-5 on Bedrock
- Route GLM/zai_glm model IDs to the new GLM prompt in system.ts
lopince and others added 5 commits May 21, 2026 11:27
GLM models only support a binary thinking toggle, not graduated effort
levels. Replace the low/medium/high variants with a single "enabled"
variant that sends reasoning_config: "high" to Bedrock.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
GLM models only support a binary thinking toggle, not graduated effort
levels. Expose a single "high" variant (consistent with how Anthropic
and Nova on Bedrock use effort-level keys) that sends reasoning_config:
"high" to toggle thinking on. No variant = reasoning off.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

[FEATURE]: Add GLM-5 reasoning support on AWS Bedrock

1 participant