Skip to content

fix(runtime): await in-flight task promises in AgentRuntime.stop() - #280

Merged
David-patrick-chuks-02 merged 2 commits into
Lilly-Protocol:mainfrom
Senthemodder:fix/issue-259-await-in-flight-tasks
Sep 6, 2026
Merged

fix(runtime): await in-flight task promises in AgentRuntime.stop()#280
David-patrick-chuks-02 merged 2 commits into
Lilly-Protocol:mainfrom
Senthemodder:fix/issue-259-await-in-flight-tasks

Conversation

@Senthemodder

Copy link
Copy Markdown
Contributor

Fixes #259

  • Replaced busy-polling while loop in drainInFlightTasks() with event-driven Promise.race([Promise.allSettled(...), this.sleep(timeoutMs)]).
  • Added inFlightPromises Map tracking active task execution promises with guaranteed lifecycle cleanup in finally.
  • Added reproduction test suite verifying zero busy-polling sleep cycles and immediate promise unblocking.

Summary

Describe the change and why it belongs in the runtime foundation.

Checklist

  • Tests added or updated
  • Public interfaces remain intentionally extendable
  • Documentation updated where relevant
  • Scope stays focused on one architectural concern

Fixes Lilly-Protocol#259

- Replaced busy-polling while loop in `drainInFlightTasks()` with event-driven `Promise.race([Promise.allSettled(...), this.sleep(timeoutMs)])`.
- Added `inFlightPromises` Map tracking active task execution promises with guaranteed lifecycle cleanup in `finally`.
- Added reproduction test suite verifying zero busy-polling sleep cycles and immediate promise unblocking.
Senthemodder

This comment was marked as spam.

@David-patrick-chuks-02
David-patrick-chuks-02 merged commit 38ad7d7 into Lilly-Protocol:main Sep 6, 2026
0 of 2 checks passed
@Senthemodder

Copy link
Copy Markdown
Contributor Author

Hi @David-patrick-chuks-02! Thank you for the review and merge!

USDC Payout Address (BSC BEP-20 / EVM): 0xad4215910eb90f2d5c948cdb074a6c1487c4136f

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.

[Bounty: $100] Await in-flight task promises in AgentRuntime.stop() instead of busy-polling

3 participants