Fix tool call timeout by implementing chunked response with keepalive

- Added special handling for HumanAgent_Chat tool calls to prevent Node.js undici 5-minute timeout
- Send HTTP headers immediately with Transfer-Encoding: chunked to stop headersTimeout
- Implement 4-minute keepalive mechanism writing space character to reset bodyTimeout
- Allows indefinite wait times for human responses in tool calls
- Tested successfully with 35+ minute wait time without timeout

Resolves issue where VS Code MCP client would cancel tool calls after ~5-6 minutes
with error 'The user cancelled the tool call' due to undici hardcoded timeouts.
This commit is contained in:
B Harper
2025-11-19 15:32:59 +11:00
parent 164b6b9f1e
commit accdbdc602
4 changed files with 310 additions and 1 deletions
+5 -1
View File
@@ -13,4 +13,8 @@ For more information see https://github.com/3DTek-xyz/HumanAgent-MCP/blob/master
![HumanAgent MCP Extension Demo](high-res-demo.gif)
*Complete demonstration of the HumanAgent MCP extension in action - showing real-time human-AI collaboration*
*Complete demonstration of the HumanAgent MCP extension in action - showing real-time human-AI collaboration*
## Medium Article
https://medium.com/@harperbenwilliam/stop-the-ai-chaos-why-human-in-the-loop-beats-fully-autonomous-coding-agents-eeb0ae17fde9