Skip to content

Fix UI/streaming timeouts for long running LLM requests - #907

Merged
EItanya merged 4 commits into
kagent-dev:mainfrom
onematchfox:bf/fix-ui-timeouts
Sep 18, 2025
Merged

EItanya merged 4 commits into
kagent-dev:mainfrom
onematchfox:bf/fix-ui-timeouts

Conversation

@onematchfox

@onematchfox onematchfox commented Sep 17, 2025 •

Copy link
Copy Markdown
Contributor

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:

  • 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 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 #869

Potentially also related to/resolves #892?

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>
Copilot AI review requested due to automatic review settings September 17, 2025 13:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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> => {

Copilot AI Sep 17, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Comment thread helm/kagent/values.yaml
maxBufSize: 1Mi # 1024 * 1024
initialBufSize: 4Ki # 4 * 1024
timeout: 60s # 60 seconds
timeout: 600s # 600 seconds

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

if (keepAliveTimer) clearTimeout(keepAliveTimer);
controller.close();
isClosed = true;
console.log('A2A Proxy: Backend connection closed.');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover from debugging/testjng?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@EItanya
EItanya merged commit 2b5ea5c into kagent-dev:main Sep 18, 2025
peterj added a commit that referenced this pull request Sep 18, 2025
* main:
  Fix UI/streaming timeouts for long running LLM requests (#907)
  fix helm value for env (#910)
  feat: allow per-agent header configuration for tools (#884)
  feat: Set system message from ConfigMap or Secrets (#894)

Signed-off-by: Peter Jausovec <peter.jausovec@solo.io>
@onematchfox
onematchfox deleted the bf/fix-ui-timeouts branch September 22, 2025 09:09
Raghavendiran-2002 pushed a commit to Raghavendiran-2002/kagent that referenced this pull request Apr 30, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants