Skip to content

[FEATURE] Allow tools to access main event loop resources #1406

@charles-dyfis-net

Description

@charles-dyfis-net

Problem Statement

Strands' current async->sync wrapper executes tools on a separate event loop, so they cannot access resources bound to the application's main loop -- cached tasks, preexisting httpx.AsyncClient instances, and other awaitables that were initialized there.

Proposed Solution

Either:

  • Enable greenback as an explicitly-supported optional dependency, using it in favor of the current approach if-and-only-if (a) greenback is installed, and (b) greenback.ensure_portal() has been called to initialize it; or
  • Provide a supported, non-monkeypatching extension point for application authors to supply their own async→sync wrapper.

Use Case

Integrating Strands into a larger async-native application where tools need access to resources (HTTP/database/other natively-async client connection pools, cached coroutines, etc.) that are bound to the main event loop and cannot be accessed from a secondary loop.

Alternatives Solutions

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-asyncRelated to asynchronous flows or multi-threadingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions