Skip to content

Local workers fail for non-coroutine awaitable run results #666

Open

Description

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions