Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:ANative Lab EvoAgentX AsyncUtils

From Leeroopedia
Knowledge Sources
Domains Utils, Async
Last Updated 2026-10-21 00:00 GMT

Overview

Concrete async/sync bridging utilities enabling the framework's dual sync/async execution model.

Description

The `evoagentx/utils/async_utils.py` module provides critical infrastructure for the framework's dual sync/async execution model:

  • run_coroutine_sync — Runs async coroutines from sync code, handling nested event loops via `ThreadPoolExecutor`.
  • is_method_overridden — Checks if a method is overridden from a base class.
  • call_maybe_async — Awaits async functions and runs sync functions in a thread.

Used by `Agent`, `WorkFlow`, and operators for seamless sync/async execution.

Usage

  • Sync execution of async code: Use `run_coroutine_sync` to call async methods from sync context.
  • Method detection: Use `is_method_overridden` to check if a subclass overrides a method.
  • Universal calling: Use `call_maybe_async` to call functions regardless of sync/async.

Code Reference

Source Location

Signature

def run_coroutine_sync(coro: Coroutine, ...) -> Any
def is_method_overridden(base_cls: type, sub_cls: type, method_name: str) -> bool
async def call_maybe_async(func: Callable, *args, **kwargs) -> Any

Import

from evoagentx.utils.async_utils import run_coroutine_sync, is_method_overridden, call_maybe_async

I/O Contract

Inputs

Name Type Required Description
coro Coroutine Yes Async coroutine to run
func Callable Yes Sync or async function

Outputs

Name Type Description
run_coroutine_sync returns Any Result of the coroutine
is_method_overridden returns bool Whether method is overridden

Usage Examples

Run Async from Sync

import asyncio
from evoagentx.utils.async_utils import run_coroutine_sync

async def my_async_func():
    await asyncio.sleep(1)
    return "done"

# Call from sync code
result = run_coroutine_sync(my_async_func())

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment