Local workers fail for non-coroutine awaitable run results

オープン 初心者向け
#666 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

  • #667 @Elon-Jiang による — マージされずにクローズ

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python

調査の方向性

agentlightning/controller/local_reconciler.py の _run_local_reconciler_worker から始め、同期 run() メソッドの結果をどのように処理するか確認してください。issue の Deferred の再現例と worker のエントリーポイントを使って動作を確認します。カスタム awaitable が正常に完了し、同期結果と coroutine の結果も引き続き動作すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Problem

On Python 3.12, the local worker detects results with inspect.isawaitable, but passes them directly to asyncio.run. That entry point requires a coroutine on Python 3.12. A valid custom awaitable returned by an agent's synchronous run() therefore fails with ValueError: a coroutine was expected and the worker exits with code 1 without completing the task. Synchronous results and normal coroutine results work.

Minimal reproduction

Put this in an importable module awaitable_agent.py:

import asyncio

class Deferred:
    def __await__(self):
        async def complete():
            await asyncio.sleep(0)
            print("completed")
        return complete().__await__()

class Agent:
    def run(self):
        return Deferred()

Run the same worker entry point used by the local controller:

from agentlightning.controller.local_reconciler import _run_local_reconciler_worker
assert _run_local_reconciler_worker("awaitable_agent:Agent") == 0

On main 05c7fe133175653e48c990546a3509e52dc56512, the assertion fails; the worker prints the ValueError and returns 1. The awaitable is not executed.

A small coroutine wrapper can await the result before handing the wrapper to asyncio.run. I verified this with real importable agent classes and independent child processes: unchanged source exits 1 without the completion marker; the wrapper exits 0 with the marker. Regression controls cover synchronous and coroutine results. With the focused fix, all 159 CPU tests pass using the frozen dev/verl-cpu environment, whole-repository pyright reports 0 errors, and the lint, pre-commit, headers, strict docs and package checks pass. No browser, model inference, GPU training or cluster was used.

AI assistance: Codex investigated, prepared the fix and ran these checks.

主要言語
Python
スター
18.9k
フォーク
1.7k
平均マージ
4日 11時間
マージ済み PR(30日)
9

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/agent-lightning のほかの issue

microsoft/agent-lightning の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。