Skip to content

Conversation

Maokaman1
Copy link

Closes #40097

When multiple files are added sequentially to the agent panel, the request JSON incorrectly includes "text" elements containing only spaces. These empty elements cause the Zhipu AI API to return a "text cannot be empty" error.
The fix filters out any "text" elements that are empty or contain only whitespaces.

UI state when the error occurs:
Image

Request JSON (causing the error):

{
  "model": "glm-4.6",
  "messages": [
    {
      "role": "system",
      "content": "<<CUT>>"
    },
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "[@1.txt](zed:///agent/file?path=C%3A%5CTemp%5CTest%5C1.txt)"
        },
        { "type": "text", "text": " " },
        {
          "type": "text",
          "text": "[@2.txt](zed:///agent/file?path=C%3A%5CTemp%5CTest%5C2.txt)"
        },
        { "type": "text", "text": " describe" },

Release Notes:

  • Filter out whitespace-only text content parts for OpenAI and OpenAI compatible providers

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Oct 16, 2025
@SomeoneToIgnore SomeoneToIgnore added the ai Improvement related to Agent Panel, Edit Prediction, Copilot, or other AI features label Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai Improvement related to Agent Panel, Edit Prediction, Copilot, or other AI features cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AI: Zhipu AI returns "text cannot be empty" when using multiple context files

2 participants