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

# Update an agent

> Partially update an existing agent configuration.

Only the fields present in the request body are updated; all other fields
keep their current values.

Args:
    agent_id (`str`): The agent to update.
    body (`UpdateAgentRequest`): Fields to update.
    user_id (`str`): Injected authenticated user ID.
    storage (`StorageBase`): Injected storage backend.

Returns:
    `AgentRecord`: The full agent record after the update.

Raises:
    `HTTPException`: 404 if the agent does not exist or does not belong
        to the authenticated user.



## OpenAPI

````yaml /versions/2.0.2/en/deploy/openapi.json patch /agent/{agent_id}
openapi: 3.1.0
info:
  title: AgentScope
  version: 2.0.1
servers: []
security: []
paths:
  /agent/{agent_id}:
    patch:
      tags:
        - agent
      summary: Update an agent
      description: >-
        Partially update an existing agent configuration.


        Only the fields present in the request body are updated; all other
        fields

        keep their current values.


        Args:
            agent_id (`str`): The agent to update.
            body (`UpdateAgentRequest`): Fields to update.
            user_id (`str`): Injected authenticated user ID.
            storage (`StorageBase`): Injected storage backend.

        Returns:
            `AgentRecord`: The full agent record after the update.

        Raises:
            `HTTPException`: 404 if the agent does not exist or does not belong
                to the authenticated user.
      operationId: update_agent_agent__agent_id__patch
      parameters:
        - name: agent_id
          in: path
          required: true
          schema:
            type: string
            title: Agent 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.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateAgentRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentRecord'
        '404':
          description: Not found
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    UpdateAgentRequest:
      properties:
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          description: New display name.
        system_prompt:
          anyOf:
            - type: string
            - type: 'null'
          title: System Prompt
          description: New system prompt.
        context_config:
          anyOf:
            - $ref: '#/components/schemas/ContextConfig'
            - type: 'null'
          description: New context configuration.
        react_config:
          anyOf:
            - $ref: '#/components/schemas/ReActConfig'
            - type: 'null'
          description: New ReAct loop configuration.
      type: object
      title: UpdateAgentRequest
      description: |-
        Request body for partially updating an agent.

        Omit any field to keep its current value.
    AgentRecord:
      properties:
        id:
          type: string
          title: Id
          description: Unique identifier for the credential.
        updated_at:
          type: string
          format: date-time
          title: Updated At
        created_at:
          type: string
          format: date-time
          title: Created At
        user_id:
          type: string
          title: User Id
        source:
          type: string
          enum:
            - user
            - team
          title: Source
          default: user
        data:
          $ref: '#/components/schemas/AgentData'
      type: object
      required:
        - user_id
        - data
      title: AgentRecord
      description: The agent ORM model.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ContextConfig:
      properties:
        trigger_ratio:
          type: number
          exclusiveMaximum: 0.9
          exclusiveMinimum: 0
          title: Trigger Ratio
          default: 0.8
        reserve_ratio:
          type: number
          exclusiveMaximum: 0.9
          exclusiveMinimum: 0
          title: Reserve Ratio
          default: 0.1
        compression_prompt:
          type: string
          format: textarea
          title: Compression Prompt
          default: >-
            <system-hint>You have been working on the task described above but
            have not yet completed it. Now write a continuation summary that
            will allow you to resume work efficiently in a future context window
            where the conversation history will be replaced with this summary.
            Your summary should be structured, concise, and
            actionable.</system-hint>
        summary_template:
          type: string
          format: textarea
          title: Summary Template
          default: |-
            <system-info>Here is a summary of your previous work
            # Task Overview
            {task_overview}

            # Current State
            {current_state}

            # Important Discoveries
            {important_discoveries}

            # Next Steps
            {next_steps}

            # Context to Preserve
            {context_to_preserve}</system-info>
        summary_schema:
          additionalProperties: true
          type: object
          title: Summary Schema
        tool_result_limit:
          type: integer
          title: Tool Result Limit
          description: >-
            The maximum length of the tool results in tokens. If exceeded, the
            tool result will be truncated.
          default: 3000
      type: object
      title: ContextConfig
      description: The context related configuration in AgentScope
    ReActConfig:
      properties:
        max_iters:
          type: integer
          title: Max Iterations
          description: The maximum number of reasoning-acting iterations in one reply
          default: 20
        stop_on_reject:
          type: boolean
          title: Rejection Handling
          description: Whether to stop replying when being rejected to execute tools.
          default: false
      type: object
      title: ReActConfig
      description: The reasoning related configuration
    AgentData:
      properties:
        id:
          type: string
          title: Id
          description: Unique agent id
        name:
          type: string
          title: Name
          description: The name of the agent.
        system_prompt:
          type: string
          format: textarea
          title: System Prompt
          description: The system prompt for the agent.
          default: You're a helpful assistant.
        context_config:
          $ref: '#/components/schemas/ContextConfig'
          title: Context Config
          description: The context config for the agent.
        react_config:
          $ref: '#/components/schemas/ReActConfig'
          title: React Config
          description: The react config for the agent.
      type: object
      required:
        - name
        - context_config
        - react_config
      title: AgentData
      description: The agent data model.
    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

````