Skip to content

fix(controller): await non-coroutine local worker results - #667

Closed
Elon-Jiang (Elon-Jiang) wants to merge 1 commit into
microsoft:mainfrom
Elon-Jiang:fix/local-worker-awaitable-results
Closed

Elon-Jiang (Elon-Jiang) wants to merge 1 commit into
microsoft:mainfrom
Elon-Jiang:fix/local-worker-awaitable-results

Conversation

@Elon-Jiang

Copy link
Copy Markdown

A local agent returning a valid non-coroutine awaitable currently exits as failed on Python 3.12: inspect.isawaitable accepts the result, but asyncio.run rejects it before it runs. Await the result inside a coroutine wrapper, preserving existing synchronous and ordinary coroutine behavior. Add three real importable agent regressions and document the completion semantics.

Fixes #666.

Validation on Python 3.12.13 with frozen development and verl-cpu dependencies:

  • Before the fix: 1 new regression failed (custom awaitable), 2 controls passed.
  • Independent real child process: original exit 1/no marker; fixed exit 0/marker present.
  • uv run --locked --no-sync pytest -v --durations=20 tests: 159 passed, 3 warnings, no skipped tests.
  • uv run --locked --no-sync pyright: 0 errors.
  • All-files pre-commit, whole-repository Ruff lint/format and copyright headers: passed.
  • Strict MkDocs build and uv build --no-sources sdist/wheel: passed.

No browser, model inference, GPU training or cluster was used. AI assistance: Codex helped investigate, implement and validate this fix.

Copilot AI balanced review requested due to automatic review settings October 31, 2026 04: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.

🟢 Approval recommended

No active review issues were identified for the change supporting non-coroutine awaitables in local workers.

No open issues 🎉

What changed in this PR

Fixes #666 by allowing local controller workers to complete non-coroutine awaitables on Python 3.12 while preserving synchronous and ordinary coroutine behavior.

Changes:

  • Wraps awaitable results in a coroutine before passing them to asyncio.run.
  • Adds regression coverage for synchronous, coroutine, and custom awaitable results.
  • Documents that workers await results before reporting successful completion.
File Description
tests/​controller/​test_local_worker_results.py Tests completion using real importable agents for all three result types.
docs/​30-controller-configuration.md Clarifies local worker completion semantics.
agentlightning/​controller/​local_reconciler.py Adds a coroutine wrapper to support non-coroutine awaitables.

Review effort: Balanced

@hzy46

Copy link
Copy Markdown
Contributor

It is too defensive. In practice, we do not encounter such error.

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.

Local workers fail for non-coroutine awaitable run results

3 participants