Local workers fail for non-coroutine awaitable run results

Aperta Adatta ai principianti
#666 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

  • #667 di @Elon-Jiang — chiusa senza merge

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python

Direzione di ricerca

Inizia da agentlightning/controller/local_reconciler.py, in corrispondenza di _run_local_reconciler_worker, e controlla come gestisce i risultati dei metodi sincroni run(). Usa la riproduzione di Deferred dell’issue e il punto di ingresso del worker per verificare il comportamento. Il lavoro è completato quando gli awaitable personalizzati terminano correttamente e i risultati sincroni e delle coroutine continuano a funzionare.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
18.9k
Fork
1.7k
Merge medio
4g 11h
PR unite (30g)
9

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/agent-lightning

Tutte le issue di microsoft/agent-lightning

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.