Skip to content

fix(agent): await endExecution in onAgentLoopEnd to ensure cleanup completes#1832

Open
Br1an67 wants to merge 1 commit intobytedance:mainfrom
Br1an67:fix/issue-1061-streaming-end-execution
Open

fix(agent): await endExecution in onAgentLoopEnd to ensure cleanup completes#1832
Br1an67 wants to merge 1 commit intobytedance:mainfrom
Br1an67:fix/issue-1061-streaming-end-execution

Conversation

@Br1an67
Copy link

@Br1an67 Br1an67 commented Mar 1, 2026

Summary

Fixes #1061

In streaming mode, onAgentLoopEnd called endExecution() with .catch() (fire-and-forget) instead of await. This meant cleanup handlers—including the one that sends the agent_run_end event—could complete after the method returned, causing the stream adapter to never receive the completion signal.

Changes:

  • Changed endExecution().catch(...) to try { await endExecution() } catch
  • This ensures cleanup (including agent_run_end event emission) completes before onAgentLoopEnd returns

Checklist

  • Added or updated necessary tests (Optional).
  • Updated documentation to align with changes (Optional).
  • Verified no breaking changes, or prepared solutions for any occurring breaking changes (Optional).
  • My change does not involve the above items.

In streaming mode, onAgentLoopEnd called endExecution() as fire-and-forget
(.catch() without await), so the cleanup handler that sends the
agent_run_end event could complete after the method returned. This caused
the Web UI to never receive the termination signal, leaving it stuck in
a spinning state.

Properly await endExecution() to ensure the agent_run_end event is sent
before the streaming promise chain completes.

Closes bytedance#1061
@netlify
Copy link

netlify bot commented Mar 1, 2026

Deploy Preview for tarko ready!

Name Link
🔨 Latest commit f3ced9c
🔍 Latest deploy log https://app.netlify.com/projects/tarko/deploys/69a46e6627aed100084faba9
😎 Deploy Preview https://deploy-preview-1832--tarko.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Mar 1, 2026

Deploy Preview for agent-tars-docs ready!

Name Link
🔨 Latest commit f3ced9c
🔍 Latest deploy log https://app.netlify.com/projects/agent-tars-docs/deploys/69a46e66a66aed0008eedd33
😎 Deploy Preview https://deploy-preview-1832--agent-tars-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Streaming mode missing executionController.endExecution() call

1 participant