spring-projects / spring-projects/spring-ai

Content field is empty in streaming response after tool call in MCP client

Open
#2,575 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

mcp
Dominant language
Java
Stars
9.5k
Forks
2.9k
Avg merge
1d 7h
Merged PRs (30d)
6

Description

Bug description
When using the Spring AI MCP client for handling tool calls, we've observed inconsistent behavior between streaming and non-streaming modes regarding the content field in the request payload.

  1. Streaming Mode (stream: true):

    {
      "messages": [
        {
          "content": "What data does the database contain?",
          "role": "user"
        },
        {
          "content": "",  // 👈 Content is unexpectedly empty
          "role": "assistant",
          "tool_calls": [
            {
              "id": "...",
              "type": "function",
              "function": {"name": "list_tables"}
            }
          ]
        },
        // ... subsequent tool response
      ],
      "stream": true
    }
    
  2. Non-streaming Mode (stream: false):

    {
      "messages": [
        {
          "content": "What data does the database contain?",
          "role": "user"
        },
        {
          "content": "\n<think>\n ... \n</think>\n\n",  // Content contains intermediate thought steps
          "role": "assistant",
          "tool_calls": [
            // ... same tool call structure
          ]
        },
        // ... subsequent tool response
      ],
      "stream": false
    }
    

Environment

  • Spring AI version: 1.0.0-M6
  • Java version: 17
  • MCP API version: 0.7.0-SNAPSHOT

Steps to reproduce

  1. Send a tool call request with stream: true
  2. Observe empty content field in assistant message
  3. Compare with non-streaming request where content contains text content

Expected behavior

  • Both streaming and non-streaming modes should maintain consistent payload structure
  • The content field should either:
    1. Contain intermediate thought steps in both modes, or
    2. Be omitted in streaming mode while preserving tool call metadata

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the streaming and non-streaming MCP client requests described in the issue, then trace the Spring AI MCP client code that builds assistant messages after a tool call. Compare how content and tool-call metadata are serialized in both paths; done means the chosen content behavior is consistent and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.