Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asynchronous Task Processing in Agentic Workflows #405

Open
rakro101 opened this issue Jan 9, 2025 · 2 comments
Open

Asynchronous Task Processing in Agentic Workflows #405

rakro101 opened this issue Jan 9, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@rakro101
Copy link

rakro101 commented Jan 9, 2025

🚀 Feature

Support for Asynchronous Task Processing in Agentic Workflows.

Provide functionality for asynchronous task management, enabling clients to submit tasks that require extended processing time (e.g., > 60 seconds) and receive responses in an asynchronous manner. This includes mechanisms for queuing tasks, notifying clients upon task completion, and ensuring smooth client-server interaction.

Motivation

In workflows where prediction steps involve significant computation time, it becomes impractical to block client requests for extended durations. This feature would enable the following:

  1. Efficient task queuing and processing for long-running tasks.
  2. Improved client experience by offering non-blocking task submission and flexible result delivery options (polling or push notifications).
  3. Better resource utilization on the server-side, allowing for scalable management of incoming tasks.

Currently, there is no native support in the litserve package to handle such asynchronous workflows, which limits its applicability to real-world, complex AI systems requiring prolonged computation.

Pitch

The proposed functionality would introduce:

  1. Task Submission API:

    • Clients submit requests containing input data (e.g., ID and Document).
    • The server acknowledges the request with an immediate response containing a unique task ID or tracking URL.
  2. Task Processing:

    • The server processes the task asynchronously in the background.
  3. Result Retrieval Options:

    • Option A: Clients can poll the server using the task ID to retrieve the status and result.
    • Option B: Clients can register a callback URL for the server to push the results once processing is complete.
  4. Server Response API:

    • The server sends the final result (e.g., task ID and encoded model output) back to the client.
    • The client acknowledges the result to complete the workflow.
Screenshot 2025-01-09 at 09 33 27

Additional context

This feature would align litserve with modern REST API patterns for long-running workflows, making it more suitable for real-world AI applications. Below is a simple diagram of the workflow:

  1. Client-Server Workflow:

    • Client submits a request: { "id": "123", "document": "text" }.
    • Server responds: { "status": "accepted", "task_id": "123-task" }.
  2. Option A (Polling):

    • Client polls: /status/123-task.
    • Server responds: { "status": "completed", "result": "encoded output" }.
  3. Option B (Webhook):

    • Server sends: { "task_id": "123-task", "result": "encoded output" } to a client-specified URL.

This enhancement would allow seamless integration into systems with asynchronous requirements and complex workflows.
(This request was support by GenAI.)

@rakro101 rakro101 added the enhancement New feature or request label Jan 9, 2025
@aniketmaurya
Copy link
Collaborator

related to #348

@aniketmaurya
Copy link
Collaborator

Thank you for writing such a detailed feature request @rakro101! We are planning to add this sometime soon. Will keep you posted about the progress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants