Skip to content

AgentCore Runtime - get_async_task_info - did not return metadata #258

@wellsiau-aws

Description

@wellsiau-aws

Describe the bug
Method get_async_task_info currently did not return metadata as shown here:

def get_async_task_info(self) -> Dict[str, Any]:
"""Get info about running async tasks."""
running_jobs = []
for t in self._active_tasks.values():
try:
running_jobs.append(
{"name": t.get("name", "unknown"), "duration": time.time() - t.get("start_time", time.time())}
)
except Exception as e:
self.logger.warning("Caught exception, continuing...: %s", e)
continue
return {"active_count": len(self._active_tasks), "running_jobs": running_jobs}

The metadata itself can be injected using method add_async_task as shown here:

# Register task start with same structure as @async_task decorator
task_info = {"name": name, "start_time": time.time()}
if metadata:
task_info["metadata"] = metadata
self._active_tasks[task_id] = task_info

To Reproduce
Create new task with metadata

task_id = app.add_async_task("file_processing", {"file": "data.csv"})
# ... do background work ...
app.complete_async_task(task_id)

Try to fetch metadata:

# Get info about running async tasks
task_info = app.get_async_task_info()
for task in task_info.get('running_jobs', []):
   metadata = task.get('metadata', {})
   print(metadata)

Expected behavior
get_async_task_info should return the metadata

Screenshots
n/a

Additional context
AgentCore SDK v1.2.1

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