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

# Edit one pending user turn

> Replace a pending item; started items produce HTTP 409.

Args:
    item_id (`str`):
        Stable id of the pending item to update.
    request (`UpdateChatQueueItemRequest`):
        Target session and replacement message payload.
    user_id (`str`):
        Injected authenticated user id.
    storage (`StorageBase`):
        Injected persistent session storage.
    message_bus (`MessageBus`):
        Injected message bus containing the pending FIFO.

Returns:
    `ChatQueueResponse`:
        Complete editable queue after the update.

Raises:
    `HTTPException`:
        HTTP 404 if the session is not owned by the caller, HTTP 409
        if the item is no longer pending, or HTTP 503 if the queue is
        busy.



## OpenAPI

````yaml /en/versions/2.0.12/deploy/openapi.json patch /chat/queue/{item_id}
openapi: 3.1.0
info:
  title: AgentScope
  version: 2.0.12
servers: []
security: []
paths:
  /chat/queue/{item_id}:
    patch:
      tags:
        - chat
      summary: Edit one pending user turn
      description: |-
        Replace a pending item; started items produce HTTP 409.

        Args:
            item_id (`str`):
                Stable id of the pending item to update.
            request (`UpdateChatQueueItemRequest`):
                Target session and replacement message payload.
            user_id (`str`):
                Injected authenticated user id.
            storage (`StorageBase`):
                Injected persistent session storage.
            message_bus (`MessageBus`):
                Injected message bus containing the pending FIFO.

        Returns:
            `ChatQueueResponse`:
                Complete editable queue after the update.

        Raises:
            `HTTPException`:
                HTTP 404 if the session is not owned by the caller, HTTP 409
                if the item is no longer pending, or HTTP 503 if the queue is
                busy.
      operationId: update_chat_queue_item_chat_queue__item_id__patch
      parameters:
        - name: item_id
          in: path
          required: true
          schema:
            type: string
            description: Stable id of the pending item to update.
            title: Item Id
          description: Stable id of the pending item to update.
        - 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.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateChatQueueItemRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatQueueResponse'
        '404':
          description: Not found
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    UpdateChatQueueItemRequest:
      properties:
        agent_id:
          type: string
          title: Agent Id
          description: Agent that owns the target session.
        session_id:
          type: string
          title: Session Id
          description: Session whose pending item will be updated.
        input:
          anyOf:
            - $ref: '#/components/schemas/Msg'
            - items:
                $ref: '#/components/schemas/Msg'
              type: array
              minItems: 1
          title: Input
          description: Replacement message or non-empty message list.
      type: object
      required:
        - agent_id
        - session_id
        - input
      title: UpdateChatQueueItemRequest
      description: Replace the input carried by one pending queue item.
    ChatQueueResponse:
      properties:
        items:
          items:
            $ref: '#/components/schemas/ChatQueueItem'
          type: array
          title: Items
          description: Editable pending turns in FIFO execution order.
      type: object
      required:
        - items
      title: ChatQueueResponse
      description: Current editable FIFO snapshot for a session.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    Msg:
      properties:
        name:
          type: string
          title: Name
        content:
          items:
            anyOf:
              - $ref: '#/components/schemas/TextBlock'
              - $ref: '#/components/schemas/ThinkingBlock'
              - $ref: '#/components/schemas/HintBlock'
              - $ref: '#/components/schemas/ToolCallBlock'
              - $ref: '#/components/schemas/ToolResultBlock'
              - $ref: '#/components/schemas/DataBlock'
          type: array
          title: Content
        role:
          type: string
          enum:
            - user
            - assistant
            - system
          title: Role
        id:
          type: string
          title: Id
        metadata:
          additionalProperties: true
          type: object
          title: Metadata
        created_at:
          type: string
          title: Created At
        usage:
          anyOf:
            - $ref: '#/components/schemas/Usage'
            - type: 'null'
        finished_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Finished At
        finished_reason:
          anyOf:
            - $ref: '#/components/schemas/ReplyFinishedReason'
            - type: 'null'
        structured_output:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Structured Output
        error:
          anyOf:
            - $ref: '#/components/schemas/ErrorInfo'
            - type: 'null'
      type: object
      required:
        - name
        - content
        - role
      title: Msg
      description: |-
        The message class in AgentScope, responsible for information storage
        and transmission among different agents.
    ChatQueueItem:
      properties:
        id:
          type: string
          title: Id
          description: Stable id used to edit, delete, or reorder this item.
        created_at:
          type: string
          title: Created At
          description: UTC ISO-8601 timestamp recorded when the item queued.
        input:
          anyOf:
            - $ref: '#/components/schemas/Msg'
            - items:
                $ref: '#/components/schemas/Msg'
              type: array
              minItems: 1
          title: Input
          description: One message or non-empty ordered message list.
        state:
          type: string
          enum:
            - queued
            - steering
            - failed
          title: State
          description: Current deferred-send or steering state.
          default: queued
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
          description: Visible steering failure, when state is failed.
      type: object
      required:
        - id
        - created_at
        - input
      title: ChatQueueItem
      description: One ordinary user turn that has not started execution.
    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
    TextBlock:
      properties:
        type:
          type: string
          const: text
          title: Type
          default: text
        text:
          type: string
          title: Text
        id:
          type: string
          title: Id
        created_at:
          type: string
          title: Created At
        finished_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Finished At
      type: object
      required:
        - text
      title: TextBlock
      description: The text block.
    ThinkingBlock:
      properties:
        type:
          type: string
          const: thinking
          title: Type
          default: thinking
        thinking:
          type: string
          title: Thinking
        id:
          type: string
          title: Id
        created_at:
          type: string
          title: Created At
        finished_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Finished At
      additionalProperties: true
      type: object
      required:
        - thinking
      title: ThinkingBlock
      description: |-
        The thinking block.

        Allows extra provider-specific fields (e.g. Anthropic's ``signature``,
        ``redacted_thinking_data``) via ``extra="allow"`` so that model
        implementations can pass arbitrary metadata without subclassing.

        .. note::
            Anthropic's ``redacted_thinking`` blocks are also stored as
            ``ThinkingBlock`` instances with ``thinking=""`` and the
            encrypted payload in the ``redacted_thinking_data`` extra
            field. Callers filtering by ``type=="thinking"`` (e.g.
            ``get_content_blocks``) will receive both visible and
            redacted blocks.
    HintBlock:
      properties:
        type:
          type: string
          const: hint
          title: Type
          default: hint
        hint:
          anyOf:
            - type: string
            - items:
                anyOf:
                  - $ref: '#/components/schemas/TextBlock'
                  - $ref: '#/components/schemas/DataBlock'
              type: array
          title: Hint
        id:
          type: string
          title: Id
        source:
          anyOf:
            - type: string
            - type: 'null'
          title: Source
        created_at:
          type: string
          title: Created At
        finished_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Finished At
      type: object
      required:
        - hint
      title: HintBlock
      description: |-
        A block used to provide instructions or hints to the LLM during the
        reasoning-acting loop. When passed to the LLM API, the hint block is
        converted into a user message.

        The ``hint`` field can be a plain string (text-only) or a list of
        :class:`TextBlock` / :class:`DataBlock` for multimodal content
        (e.g. a background tool result containing both text and an image).
    ToolCallBlock:
      properties:
        type:
          type: string
          const: tool_call
          title: Type
          default: tool_call
        id:
          type: string
          title: Id
        name:
          type: string
          title: Name
        input:
          type: string
          title: Input
        state:
          $ref: '#/components/schemas/ToolCallState'
          default: pending
        suggested_rules:
          items:
            $ref: '#/components/schemas/PermissionRule'
          type: array
          title: Suggested Rules
        created_at:
          type: string
          title: Created At
        finished_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Finished At
      type: object
      required:
        - id
        - name
        - input
      title: ToolCallBlock
      description: The tool call block.
    ToolResultBlock:
      properties:
        type:
          type: string
          const: tool_result
          title: Type
          default: tool_result
        id:
          type: string
          title: Id
        name:
          type: string
          title: Name
        output:
          anyOf:
            - type: string
            - items:
                anyOf:
                  - $ref: '#/components/schemas/TextBlock'
                  - $ref: '#/components/schemas/DataBlock'
              type: array
          title: Output
        state:
          $ref: '#/components/schemas/ToolResultState'
          default: running
        metadata:
          additionalProperties: true
          type: object
          title: Metadata
        created_at:
          type: string
          title: Created At
        finished_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Finished At
      type: object
      required:
        - id
        - name
        - output
      title: ToolResultBlock
      description: The tool result block.
    DataBlock:
      properties:
        type:
          type: string
          const: data
          title: Type
          default: data
        id:
          type: string
          title: Id
        source:
          anyOf:
            - $ref: '#/components/schemas/Base64Source'
            - $ref: '#/components/schemas/URLSource'
          title: Source
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
        created_at:
          type: string
          title: Created At
        finished_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Finished At
      additionalProperties: true
      type: object
      required:
        - source
      title: DataBlock
      description: |-
        The data block for binary content (images, audio, video, etc.).

        Allows extra provider-specific fields (e.g. OpenAI's ``detail``,
        DashScope's ``fps``) via ``extra="allow"`` so users can attach media
        processing parameters without subclassing. Formatters decide where these
        extras belong in the target API payload because providers use different
        nesting rules.
    Usage:
      properties:
        input_tokens:
          type: integer
          title: Input Tokens
        output_tokens:
          type: integer
          title: Output Tokens
        cache_input_tokens:
          type: integer
          title: Cache Input Tokens
          default: 0
        cache_creation_input_tokens:
          type: integer
          title: Cache Creation Input Tokens
          default: 0
      type: object
      required:
        - input_tokens
        - output_tokens
      title: Usage
      description: The token usage information of a message.
    ReplyFinishedReason:
      type: string
      enum:
        - completed
        - interrupted
        - exceed_max_iters
        - error
      title: ReplyFinishedReason
      description: The reason a reply finished.
    ErrorInfo:
      properties:
        type:
          $ref: '#/components/schemas/ErrorType'
          default: unknown
        message:
          type: string
          title: Message
      type: object
      required:
        - message
      title: ErrorInfo
      description: Structured, UI-facing description of a fatal reply error.
    ToolCallState:
      type: string
      enum:
        - pending
        - asking
        - allowed
        - submitted
        - finished
      title: ToolCallState
      description: The state of the tool call.
    PermissionRule:
      properties:
        tool_name:
          type: string
          title: Tool Name
        rule_content:
          anyOf:
            - type: string
            - type: 'null'
          title: Rule Content
        behavior:
          $ref: '#/components/schemas/PermissionBehavior'
        source:
          type: string
          title: Source
      type: object
      required:
        - tool_name
        - rule_content
        - behavior
        - source
      title: PermissionRule
      description: >-
        Permission rule for tool usage.


        A permission rule defines whether a specific tool or tool operation

        should be allowed, denied, or require user confirmation. The

        rule_content field has different semantics depending on the tool_name:


        - For "Bash": rule_content is a substring pattern matched against the
          command Example: rule_content="npm install" matches "npm install express"

        - For "Write"/"Read": rule_content is a glob pattern matched against
        file
          paths Example: rule_content="src/**" matches "src/main.py"

        - For other tools: rule_content is a tool-specific filter pattern
    ToolResultState:
      type: string
      enum:
        - success
        - error
        - interrupted
        - denied
        - running
      title: ToolResultState
      description: The tool result state.
    Base64Source:
      properties:
        type:
          type: string
          const: base64
          title: Type
          default: base64
        data:
          type: string
          title: Data
        media_type:
          type: string
          title: Media Type
      type: object
      required:
        - data
        - media_type
      title: Base64Source
      description: The base64 source.
    URLSource:
      properties:
        type:
          type: string
          const: url
          title: Type
          default: url
        url:
          type: string
          minLength: 1
          format: uri
          title: Url
        media_type:
          type: string
          title: Media Type
      type: object
      required:
        - url
        - media_type
      title: URLSource
      description: The URL source.
    ErrorType:
      type: string
      enum:
        - authentication
        - permission
        - rate_limit
        - invalid_request
        - upstream
        - connection
        - internal
        - setup
        - unknown
      title: ErrorType
      description: |-
        Classification of a fatal error that terminated a reply.

        Not model-specific: the status-derived members apply to any upstream
        service reached during a reply (chat model, embedding, TTS, MCP).
    PermissionBehavior:
      type: string
      enum:
        - allow
        - deny
        - ask
        - passthrough
      title: PermissionBehavior
      description: |-
        The behavior of permission.

        Attributes:
            ALLOW: Allow the operation
            DENY: Deny the operation
            ASK: Ask the user for permission
            PASSTHROUGH: Let the permission engine continue with rule matching
                (used by tools to defer decision to the engine)

````

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