Skip to content

GLM-4.7/GLM-5 (Z.AI) loses reasoning state between turns causing infinite loops #7363

@Max0xDay

Description

@Max0xDay

Goose drops the reasoning_content field between turns instead of passing it back to the API. GLM-4.7 via Z.AI requires this field to be preserved for its "Preserved Thinking" feature to work. Without it, the model loses all reasoning context after every single action and spirals into infinite loops — redoing completed work, corrupting files, and spawning redundant subagents.

To Reproduce

  1. Configure Goose with Z.AI as a custom provider (Anthropic I have only tested) using model glm-4.7
  2. Give it any multi-step agentic task (e.g. fix linting violations across multiple files)
  3. Watch the model lose track of what it already did after each tool call and begin looping

Expected behavior

Goose should pass reasoning_content back to the API on every turn with clear_thinking: false, as required by Z.AI's API for multi-turn agentic tasks. The same model completes identical tasks correctly in Claude Code in ~2 minutes. In Goose the same task took 40+ tool calls and 40 minutes with no successful completion.

Screenshots

Image

Please provide the following information

  • OS & Arch: Macos Tahoe 26.3
  • Interface: CLI and Desktop
  • Version: 1.24.0
  • Extensions enabled: Developer
  • Provider & Model: Z.AI custom provider – glm-4.7 / glm-5

Additional context

Related issues: #6902 (same reasoning_content passback bug with Kimi k2.5), #6322 (partial fix that doesn't cover Z.AI/GLM).

Z.AI Preserved Thinking docs: https://docs.z.ai/guides/capabilities/thinking-mode for extra info on it

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions