fix(providers): handle nil input in GLM series tool_use blocks#1662
Closed
hyperwd wants to merge 1 commit intosipeed:mainfrom
Closed
fix(providers): handle nil input in GLM series tool_use blocks#1662hyperwd wants to merge 1 commit intosipeed:mainfrom
hyperwd wants to merge 1 commit intosipeed:mainfrom
Conversation
- add defensive nil check for tool call Arguments field
- replace nil input with empty object to comply with Anthropic spec
- prevent API errors when GLM models return null input in tool_use blocks
Zhipu AI's GLM series models may return tool_use blocks with null input field,
which causes their API to reject subsequent requests with error:
"ClaudeContentBlockToolResult object has no attribute id"
This fix ensures compatibility by converting nil inputs to empty objects {},
matching the Anthropic Messages API specification while maintaining backward
compatibility with other providers.
Contributor
Author
|
Closing to recreate with English description |
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.
问题
Zhipu AI 的 GLM 系列模型在返回 tool_use 块时,可能会将 input 字段设置为 null,这会导致后续 API 请求失败并报错:
ClaudeContentBlockToolResult object has no attribute id修复
{},以符合 Anthropic 规范这是对 PR #1284 的后续修复。