Repository navigation
Not enough data to satisfy transfer length header #216
Description
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
kyle-li-dev commentedon Nov 27, 2025
Has anyone responded to this issue, Sarah Critchley (@sarahcritchley)?
rodrigobr-msft commentedon Dec 3, 2025
Hi, @ka2048, I will take a look at this.
kyle-li-dev commentedon Dec 5, 2025
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.
rodrigobr-msft commentedon Dec 5, 2025
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?
rodrigobr-msft commentedon Dec 5, 2025
From what I can gather, this does appear to be an issue with the connection ending mid-stream.
kyle-li-dev commentedon Dec 10, 2025
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.
kyle-li-dev commentedon Dec 10, 2025
By the way, the use of the MCP connector in the tool seems to be related to this as well.
rodrigobr-msft commentedon Feb 9, 2026
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.
kyle-li-dev commentedon Feb 26, 2026
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)
MattB-msft commentedon Feb 26, 2026
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.