Skip to content

Async Task Polling for Long-Running Agent Jobs #46

@rbpotter-aws

Description

@rbpotter-aws

Summary

Add support for kicking off long-running agent tasks and polling for completion, leveraging AgentCore Runtime's built-in async processing model. This enables fire-and-forget workflows where a caller can start a multi-minute job, disconnect, and check back for results.

Motivation

Some agent tasks (e.g. data processing, multi-step workflows, report generation) can take several minutes to complete. Today, the caller must hold a connection open for the entire duration. We need a pattern where the caller can:

  1. Submit a task and get an immediate acknowledgment
  2. Poll for status until the task completes
  3. Retrieve the result once ready

Requirements

  • Task submission — Accept a request, start processing in the background, and return an immediate response with a task/session identifier.
  • Status reporting — Expose task status via AgentCore's /ping health endpoint, using HEALTHY_BUSY while processing and HEALTHY when idle/complete.
  • Task lifecycle management — Register tasks on start (add_async_task) and mark them complete (complete_async_task) so the SDK manages ping status automatically.
  • Non-blocking entrypoint — Ensure long-running work runs in a background thread or async method so it doesn't block the /ping health check.
  • Result retrieval — Allow the caller to re-invoke the same session after the task completes to fetch results.

Constraints

  • AgentCore sessions time out after 15 minutes of idle time, so polling must occur within that window.
  • Maximum session lifetime is 8 hours.
  • While a session reports HEALTHY_BUSY, the runtime will not accept new invocations for that session.

Acceptance Criteria

  • A caller can submit a long-running task and receive an immediate response
  • Session status reflects HEALTHY_BUSY while the task is in progress
  • Session status returns to HEALTHY once the task completes
  • Caller can retrieve task results by re-invoking the same session
  • The /ping endpoint remains responsive throughout task execution

Metadata

Metadata

Assignees

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions