Skip to content

[Bug] get_task_status returns pending for both submitted and running states #488

@sun905

Description

@sun905

Issue 内容有几个格式问题,让我帮你修正:


Title:

get_task_status returns "pending" for both "submitted" and "running" states

Body:

## Bug Description

In `task_engine_mixin.py`, the `get_task_status` method incorrectly maps both "submitted" and "running" internal task states to "pending" status, preventing users from distinguishing between tasks waiting in queue and tasks currently executing.

## Affected Component

- [x] Engine

## Reproduction Steps

1. Submit a background task via the Agent-as-a-Service API
2. Poll task status using `get_task_status(task_id)` immediately after submission
3. Continue polling while task executes
4. Observe that status remains "pending" throughout both "submitted" and "running" phases

## Expected vs Actual Behavior

**Expected:**

- When task is in queue (submitted): `{"status": "pending", "result": None}`
- When task is executing (running): `{"status": "running", "started_at": <timestamp>, "result": None}`

**Actual:**

- Both submitted and running states return `{"status": "pending", "result": None}`

## Error Messages

No error message, but incorrect behavior. The problematic code in `task_engine_mixin.py`:

if task_status in ["submitted", "running"]:
return {"status": "pending", "result": None}


## Environment

- AgentScope Runtime Version: Latest (pip installed)
- Python Version: 3.11
- Installation: pip

## Additional Context

**Impact:**

- Users cannot monitor long-running background tasks properly
- No visibility into task execution progress
- The `started_at` timestamp (already tracked in `task_info`) is not exposed

**Suggested Fix:**

if task_status == "submitted":
return {"status": "pending", "result": None}
elif task_status == "running":
return {
"status": "running",
"started_at": task_info.get("started_at"),
"result": None,
}


This fix correctly distinguishes between pending and running states, exposes the `started_at` timestamp for running tasks, and maintains backward compatibility for completed/failed states.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions