> ## 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.

# Get a single background task by id

> Retrieve details of a single background task.

Returns 404 when the task does not exist or belongs to a different
user (no information leakage about task existence).

Args:
    task_id (`str`):
        The unique task identifier.
    user_id (`str`):
        The authenticated user id (from ``X-User-ID`` header).
    bg_manager (`BackgroundTaskManager`):
        The application-wide background task manager.

Returns:
    `BackgroundTaskInfo`:
        The task details.

Raises:
    `HTTPException`:
        404 if the task is not found or not owned by the user.



## OpenAPI

````yaml /en/versions/2.0.12/deploy/openapi.json get /background-tasks/{task_id}
openapi: 3.1.0
info:
  title: AgentScope
  version: 2.0.12
servers: []
security: []
paths:
  /background-tasks/{task_id}:
    get:
      tags:
        - background-tasks
      summary: Get a single background task by id
      description: |-
        Retrieve details of a single background task.

        Returns 404 when the task does not exist or belongs to a different
        user (no information leakage about task existence).

        Args:
            task_id (`str`):
                The unique task identifier.
            user_id (`str`):
                The authenticated user id (from ``X-User-ID`` header).
            bg_manager (`BackgroundTaskManager`):
                The application-wide background task manager.

        Returns:
            `BackgroundTaskInfo`:
                The task details.

        Raises:
            `HTTPException`:
                404 if the task is not found or not owned by the user.
      operationId: get_background_task_background_tasks__task_id__get
      parameters:
        - name: task_id
          in: path
          required: true
          schema:
            type: string
            title: Task Id
        - 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/BackgroundTaskInfo'
        '404':
          description: Not found
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    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.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    TaskStatus:
      type: string
      enum:
        - running
        - completed
        - failed
        - cancelled
      title: TaskStatus
      description: Status of a background task throughout its lifecycle.
    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

````

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