Skip to content

Not enough data to satisfy transfer length header #216

Closed

Description

@kyle-li-dev

Language/Version
What package version of the SDK are you using.

  • Language: Python
  • Package version: 0.5.2
  • SDK Use: Clients

Describe the bug
microsoft_agents.copilotstudio.client.copilot_client.ask_question(question="Extensive problem descriptions")

Traceback (most recent call last):

File ".venv/lib/python3.13/site-packages/microsoft_agents/copilotstudio/client/copilot_client.py", line 85, in ask_question
async for activity in self.ask_question_with_activity(activity):
│ │ │ └ Activity(type='typing', id='6906eeb5-eea9-462c-9e63-3a9e12a703ed-72', timestamp=None, local_timestamp=None, local_timezone=No...
│ │ └ <function CopilotClient.ask_question_with_activity at 0x10c149260>
│ └ <microsoft_agents.copilotstudio.client.copilot_client.CopilotClient object at 0x10c7ecd50>
└ Activity(type='typing', id='6906eeb5-eea9-462c-9e63-3a9e12a703ed-72', timestamp=None, local_timestamp=None, local_timezone=No...
File ".venv/lib/python3.13/site-packages/microsoft_agents/copilotstudio/client/copilot_client.py", line 112, in ask_question_with_activity
async for activity in self.post_request(url, data, headers):

...

File ".venv/lib/python3.13/site-packages/microsoft_agents/copilotstudio/client/copilot_client.py", line 46, in post_request
async for line in response.content:
│ │ └ <StreamReader e=ClientPayloadError("Response payload is not completed: <TransferEncodingError: 400, message='Not enough data ...
└ b'\r\n'
File ".venv/lib/python3.13/site-packages/aiohttp/streams.py", line 52, in anext
rv = await self.read_func()
│ └ <member 'read_func' of 'AsyncStreamIterator' objects>
└ <aiohttp.streams.AsyncStreamIterator object at 0x10c753880>
File ".venv/lib/python3.13/site-packages/aiohttp/streams.py", line 360, in readline
return await self.readuntil()
│ └ <function StreamReader.readuntil at 0x10beff060>
└ <StreamReader e=ClientPayloadError("Response payload is not completed: <TransferEncodingError: 400, message='Not enough data ...
File ".venv/lib/python3.13/site-packages/aiohttp/streams.py", line 394, in readuntil
await self._wait("readuntil")
│ └ <function StreamReader._wait at 0x10befef20>
└ <StreamReader e=ClientPayloadError("Response payload is not completed: <TransferEncodingError: 400, message='Not enough data ...
File ".venv/lib/python3.13/site-packages/aiohttp/streams.py", line 355, in _wait
await waiter
└ <Future finished exception=ClientPayloadError("Response payload is not completed: <TransferEncodingError: 400, message='Not e...

aiohttp.client_exceptions.ClientPayloadError: Response payload is not completed: <TransferEncodingError: 400, message='Not enough data to satisfy transfer length header.'>

Activity

  1. kyle-li-dev commented on Nov 27, 2025

    @kyle-li-dev
    Author

    Has anyone responded to this issue, Sarah Critchley (@sarahcritchley)?

  2. rodrigobr-msft commented on Dec 3, 2025

    @rodrigobr-msft
    Contributor

    Hi, @ka2048, I will take a look at this.

  3. kyle-li-dev commented on Dec 5, 2025

    @kyle-li-dev
    Author

    Hi, @ka2048, I will take a look at this.嗨,我会看看这个。

    Hello Rodrigo Brandão (@rodrigobr-msft) ,

    This issue occurs quite frequently, and I’m not sure whether it is related to the size of the payload I’m sending. It might be caused by the server actively closing the connection, but I’m not certain.

    I have already tried overriding the aiohttp parameters on my side, but the problem still persists. I also noticed your recent commit, “Adding configurability for CopilotClient ClientSession creation,” so I believe this change may not address the issue I reported.

    It would be very helpful if I could learn more about the underlying cause of this error or any potential solutions.

    Thank you for your time, and I appreciate your assistance.

  4. rodrigobr-msft commented on Dec 5, 2025

    @rodrigobr-msft
    Contributor

    Could you provide me some more information about the Copilot you are using? As well as any surrounding code and the rate of/ any details around this error?

  5. rodrigobr-msft commented on Dec 5, 2025

    @rodrigobr-msft
    Contributor

    From what I can gather, this does appear to be an issue with the connection ending mid-stream.

  6. kyle-li-dev commented on Dec 10, 2025

    @kyle-li-dev
    Author

    From what I can gather, this does appear to be an issue with the connection ending mid-stream.

    Rodrigo Brandão (@rodrigobr-msft) Yes, though I am trying to understand what information I can provide that would be most helpful to you. Should I share the question and conversation ID parameters I passed to the SDK? Or do you need the connection details from the Copilot Studio?

    From my perspective, these client-side details may not contribute much to diagnosing the issue. If possible, could we also consider whether the issue might be related to the server closing the connection? If so, it may be helpful for your server-side POC to take a look as well. I would appreciate it if this could be forwarded to the appropriate team for further investigation.

    Thank you for your support.

  7. kyle-li-dev commented on Dec 10, 2025

    @kyle-li-dev
    Author

    By the way, the use of the MCP connector in the tool seems to be related to this as well.

  8. rodrigobr-msft commented on Feb 9, 2026

    @rodrigobr-msft
    Contributor

    Hi, it's been a while. If you're still facing this, I am curious about how your agent in Copilot Studio is set up and information about when this disconnection happens: if it tends to be be after a while or immediately after connecting, etc. Anything you think might be useful.

  9. kyle-li-dev commented on Feb 26, 2026

    @kyle-li-dev
    Author

    The frequency of encountering this issue is quite low nowadays.
    I also have a new question I’d like to ask:
    When using ask_question, it only returns activities of type typing and no activities of type message. Could you help me understand why this happens?

    Rodrigo Brandão (@rodrigobr-msft)

  10. MattB-msft commented on Feb 26, 2026

    @MattB-msft
    Member

    I expect that your agent is using either Agent to Agent or MCP ?
    If so, this is expected right now... those features are in Preview and are not fully supported via the SDK Clients/API's yet. There is some work on this in flight now in prep for enabling this in the API's and SDK Clients.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions