Skip to content

[Enhancement] Add Async Context Management for Resource Cleanup #99

@tdan1

Description

@tdan1

Enhancement: Add Async Context Management for Resource Cleanup

Problem

Agents lack proper async context management, leading to:

  • Resource leaks when agents crash
  • Inconsistent cleanup behavior
  • No standardized way to initialize/cleanup async resources

Solution

Implement __aenter__ and __aexit__ methods for proper async context management.

Benefits

  • ✅ Automatic resource cleanup
  • ✅ Exception-safe initialization
  • ✅ Professional async patterns
  • ✅ Prevents memory leaks

Usage

async with SpoonReactAI(name="agent") as agent:
    result = await agent.run("Hello")
# Automatic cleanup happens here

TG : @fastbuild01

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