> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentscope.io/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> For AgentScope Python, use https://docs.agentscope.io/stable/en/index for new projects. For existing projects, check the installed agentscope version and use matching versioned documentation.
> The /latest/ alias points to the newest documentation and may move ahead of /stable/ when a development version exists. Do not mix AgentScope 1.x and 2.x APIs.
> State the AgentScope version when providing installation commands or code examples. ReMe uses its own continuously updated /reme/latest/ documentation.

# List background tasks for the current user

> List all background tasks (running and recently-completed) visible
to the authenticated user.

Args:
    session_id (`str | None`, optional):
        If provided, only return tasks belonging to this session.
    user_id (`str`):
        The authenticated user id (from ``X-User-ID`` header).
    bg_manager (`BackgroundTaskManager`):
        The application-wide background task manager.

Returns:
    `ListBackgroundTasksResponse`:
        Tasks and their total count.



## OpenAPI

````yaml /en/versions/2.0.12/deploy/openapi.json get /background-tasks
openapi: 3.1.0
info:
  title: AgentScope
  version: 2.0.12
servers: []
security: []
paths:
  /background-tasks:
    get:
      tags:
        - background-tasks
      summary: List background tasks for the current user
      description: |-
        List all background tasks (running and recently-completed) visible
        to the authenticated user.

        Args:
            session_id (`str | None`, optional):
                If provided, only return tasks belonging to this session.
            user_id (`str`):
                The authenticated user id (from ``X-User-ID`` header).
            bg_manager (`BackgroundTaskManager`):
                The application-wide background task manager.

        Returns:
            `ListBackgroundTasksResponse`:
                Tasks and their total count.
      operationId: list_background_tasks_background_tasks_get
      parameters:
        - name: session_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Optional session filter.
            title: Session Id
          description: Optional session filter.
        - name: x-user-id
          in: header
          required: true
          schema:
            type: string
            description: >-
              Caller's user ID. Temporary header-based identity; will be
              replaced by JWT auth.
            title: X-User-Id
          description: >-
            Caller's user ID. Temporary header-based identity; will be replaced
            by JWT auth.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ListBackgroundTasksResponse'
        '404':
          description: Not found
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    ListBackgroundTasksResponse:
      properties:
        tasks:
          items:
            $ref: '#/components/schemas/BackgroundTaskInfo'
          type: array
          title: Tasks
          description: Background tasks for the requested scope.
        total:
          type: integer
          title: Total
          description: Total number of tasks returned.
      type: object
      required:
        - tasks
        - total
      title: ListBackgroundTasksResponse
      description: Response body for listing background tasks.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    BackgroundTaskInfo:
      properties:
        task_id:
          type: string
          title: Task Id
          description: Unique task identifier.
        session_id:
          type: string
          title: Session Id
          description: Session that owns this task.
        agent_id:
          type: string
          title: Agent Id
          description: Agent that triggered this task.
        tool_name:
          type: string
          title: Tool Name
          description: Name of the offloaded tool.
        summary:
          type: string
          title: Summary
          description: >-
            Short human-readable summary of the tool invocation. May include
            unredacted tool arguments stored in shared task records.
        status:
          $ref: '#/components/schemas/TaskStatus'
          description: Current lifecycle status.
        started_at:
          type: string
          format: date-time
          title: Started At
          description: UTC timestamp when the task was registered.
        execution_started_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Execution Started At
          description: >-
            UTC timestamp when tool execution began, before offload. Null when
            the original start time was not recorded.
        completed_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Completed At
          description: >-
            UTC timestamp when the task reached a terminal state, or null while
            still running.
        error_summary:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Summary
          description: Brief failure description (only for failed tasks).
      type: object
      required:
        - task_id
        - session_id
        - agent_id
        - tool_name
        - summary
        - status
        - started_at
      title: BackgroundTaskInfo
      description: Summary of a single background task for API responses.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    TaskStatus:
      type: string
      enum:
        - running
        - completed
        - failed
        - cancelled
      title: TaskStatus
      description: Status of a background task throughout its lifecycle.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.