generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 80
Open
Description
Describe the bug
Method get_async_task_info currently did not return metadata as shown here:
bedrock-agentcore-sdk-python/src/bedrock_agentcore/runtime/app.py
Lines 223 to 235 in 9bd2623
| 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:
bedrock-agentcore-sdk-python/src/bedrock_agentcore/runtime/app.py
Lines 259 to 264 in 9bd2623
| # 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels