Skip to content

[Feature Request] Refactor WorkforceCallback and all related callbacks to async interface #3352

@coolbeevip

Description

@coolbeevip

Required prerequisites

Motivation

WorkforceCallback and its implementations (e.g., WorkforceLogger) are all synchronous (def). However, callbacks are frequently triggered inside async workflows. As async usage grows (logging, DB writes, async HTTP), synchronous callbacks may block the event loop and negatively impact scalability.

Solution

Refactor the WorkforceCallback interface and all implementations to be fully asynchronous:

  • Change all callback methods to async def
  • Update internal callback implementations and examples (e.g., WorkforceLogger)
  • Replace all callback invocation sites with await cb.xxx(...)
  • Update related tests and documentation

This ensures callbacks support non-blocking I/O and align with the async-first direction of the Workforce architecture.

Impact Scope

  • workforce_callback.py (interface updates)
  • WorkforceLogger and other built-in callbacks
  • Callback invocation logic within Workforce
  • Example callback usages and tests
  • Public API docs & typing

Benefits

  • Non-blocking callbacks allow async DB/logging/HTTP operations
  • More consistent async API surface across Workforce
  • Prevents unintended event-loop blocking

If maintainers agree with this direction, I’d be happy to submit the PR.

Alternatives

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

Status

No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions