Repository navigation
Fix UI/streaming timeouts for long running LLM requests - #907
Conversation
Signed-off-by: Brian Fox <878612+onematchfox@users.noreply.github.com>
Signed-off-by: Brian Fox <878612+onematchfox@users.noreply.github.com>
Signed-off-by: Brian Fox <878612+onematchfox@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR addresses timeout issues for long-running LLM requests by increasing timeout values and implementing keep-alive mechanisms. The changes ensure that requests taking longer than 60 seconds (such as gpt-5) don't timeout prematurely.
- Increases timeout values from 60 seconds to 10 minutes across the streaming pipeline
- Implements keep-alive mechanism in the UI A2A proxy to maintain streaming connections
- Adds proper timeout handling and abort signal support to the client-side streaming code
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| ui/src/lib/a2aClient.ts | Adds AbortSignal support to the streaming client method |
| ui/src/components/chat/ChatInterface.tsx | Implements proper timeout handling with 10-minute timeout and abort controller integration |
| ui/src/app/a2a/[namespace]/[agentName]/route.ts | Adds keep-alive mechanism to prevent premature connection closure |
| helm/kagent/values.yaml | Increases controller streaming timeout from 60s to 600s |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| keepAliveTimer = setTimeout(sendKeepAlive, KEEP_ALIVE_INTERVAL_MS); | ||
| }; | ||
|
|
||
| const pump = (): Promise<void> => { |
There was a problem hiding this comment.
The keep-alive timer is never initialized. The resetKeepAliveTimer() function should be called after setting up the pump function to start the keep-alive mechanism.
There was a problem hiding this comment.
Keep-alive timer is reset (aka started) once the first event is processed (and after every event thereafter).
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Brian Fox <878612+onematchfox@users.noreply.github.com>
| maxBufSize: 1Mi # 1024 * 1024 | ||
| initialBufSize: 4Ki # 4 * 1024 | ||
| timeout: 60s # 60 seconds | ||
| timeout: 600s # 600 seconds |
| if (keepAliveTimer) clearTimeout(keepAliveTimer); | ||
| controller.close(); | ||
| isClosed = true; | ||
| console.log('A2A Proxy: Backend connection closed.'); |
There was a problem hiding this comment.
leftover from debugging/testjng?
There was a problem hiding this comment.
Yeah leftover but intentionally so - had to add logging to try understand when and why various connections were closed. Left it as it may prove useful to others in future.
Whilst API interaction with Agents may use a streaming connection the agents themselves [do not use streaming](https://github.com/kagent-dev/kagent/blob/5c99583b505cbc205bcf1503ffdb1b241abf08c9/python/packages/kagent-adk/src/kagent/adk/converters/request_converter.py#L32) when communicating with the model .Thus, if a model takes longer than 60s to run (looking at you `gpt-5`) then things start timing out. This PR: - increases the default timeout on the A2A streaming connections in the controller to 10mins (this is a thumbsuck number and was chosen to match the [default timeout](https://github.com/google/adk-python/blame/main/src/google/adk/agents/remote_a2a_agent.py#L86) used by Google on non-streaming `RemoteA2AAgent` calls) - adds a keep-alive implementation to the UI A2A proxy to prevent the streaming connection from being closed prematurely - fixes the streaming timeout in the UI client-side code (again using 10 minutes before timing out) Closes kagent-dev#869 Potentially also related to/resolves kagent-dev#892? --------- Signed-off-by: Brian Fox <878612+onematchfox@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Whilst API interaction with Agents may use a streaming connection the agents themselves do not use streaming when communicating with the model .Thus, if a model takes longer than 60s to run (looking at you
gpt-5) then things start timing out.This PR:
RemoteA2AAgentcalls)Closes #869
Potentially also related to/resolves #892?