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

# Create a new agent

> Create and persist a new agent configuration.

Args:
    body (`CreateAgentRequest`):
        Agent configuration to store.
    user_id (`str`):
        Injected authenticated user ID.
    storage (`StorageBase`):
        Injected storage backend.

Returns:
    `CreateAgentResponse`:
        The server-assigned agent identifier.



## OpenAPI

````yaml /versions/2.0.2/en/deploy/openapi.json post /agent/
openapi: 3.1.0
info:
  title: AgentScope
  version: 2.0.1
servers: []
security: []
paths:
  /agent/:
    post:
      tags:
        - agent
      summary: Create a new agent
      description: |-
        Create and persist a new agent configuration.

        Args:
            body (`CreateAgentRequest`):
                Agent configuration to store.
            user_id (`str`):
                Injected authenticated user ID.
            storage (`StorageBase`):
                Injected storage backend.

        Returns:
            `CreateAgentResponse`:
                The server-assigned agent identifier.
      operationId: create_agent_agent__post
      parameters:
        - 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/CreateAgentRequest'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateAgentResponse'
        '404':
          description: Not found
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    CreateAgentRequest:
      properties:
        name:
          type: string
          title: Name
          description: Display name of the agent.
        system_prompt:
          type: string
          title: System Prompt
          description: Base system prompt fed to the agent.
          default: You're a helpful assistant.
        context_config:
          $ref: '#/components/schemas/ContextConfig'
          description: Context-window management configuration.
        react_config:
          $ref: '#/components/schemas/ReActConfig'
          description: ReAct loop configuration.
      type: object
      required:
        - name
      title: CreateAgentRequest
      description: Request body for creating a new agent.
    CreateAgentResponse:
      properties:
        agent_id:
          type: string
          title: Agent Id
          description: Server-assigned agent identifier.
      type: object
      required:
        - agent_id
      title: CreateAgentResponse
      description: Response body after creating an agent.
    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
    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

````