Skip to content

fix(opencode): GLM message format rejection and proactive context pruning#22184

Closed
tobias-weiss-ai-xr wants to merge 5 commits intoanomalyco:devfrom
tobias-weiss-ai-xr:feat/prune-before-compaction-clean
Closed

fix(opencode): GLM message format rejection and proactive context pruning#22184
tobias-weiss-ai-xr wants to merge 5 commits intoanomalyco:devfrom
tobias-weiss-ai-xr:feat/prune-before-compaction-clean

Conversation

@tobias-weiss-ai-xr
Copy link
Copy Markdown

@tobias-weiss-ai-xr tobias-weiss-ai-xr commented Apr 12, 2026

Closes #22209

What

GLM models (glm-5-turbo, glm-4.7, etc.) reject messages with empty content, consecutive assistant messages, or unsupported reasoning parts. Also adds proactive context pruning at 50% usage to smooth quality before compaction kicks in.

How

  • Added GLM/ZhipuAI normalization handler in transform.ts — filters empty content, strips reasoning parts, scrubs tool IDs, fixes consecutive assistant messages
  • Added proactive pruning that removes older tool results at 50% context usage with model-aware token estimation (EMA from actual usage)

Verification

  • 19 packages typecheck clean
  • 127 transform tests pass (6 new GLM cases)

GLM models (glm-5-turbo, glm-4.7, etc.) via litellm proxy returned
'The messages parameter is illegal' because messages contained empty
content, consecutive assistant roles, unscrubbed tool IDs, and raw
reasoning parts the GLM API doesn't support.
@tobias-weiss-ai-xr tobias-weiss-ai-xr changed the title feat: compression improvements and GLM message format fix fix(opencode): GLM message format rejection and proactive context pruning Apr 12, 2026
@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Apr 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions
Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Apr 13, 2026
@github-actions github-actions bot closed this Apr 13, 2026
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.

fix: GLM/ZhipuAI models reject message format from opencode

1 participant