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

# Update Sub-Agent

> Update an existing sub-agent. Only fields included in the request are changed.



## OpenAPI

````yaml /api-reference/openapi.json patch /api/sub_agents/{sub_agent_id}
openapi: 3.1.0
info:
  title: Maadify API
  description: Public and admin API endpoints for Maadify.
  version: 1.0.0
servers:
  - url: https://app.maadify.com
    description: Production
security: []
tags:
  - name: Parent agents
    description: Create, update, and configure parent agents.
  - name: Sub-agents
    description: Create sub-agents and assign them to parent agents.
  - name: Tools
    description: Search tools and manage tool assignments.
  - name: Prompt templates
    description: Search and manage prompt templates.
  - name: Users
    description: Search users available to the authenticated tenant.
  - name: Models
    description: Search available LLM models.
  - name: Files
    description: Check file upload status.
paths:
  /api/sub_agents/{sub_agent_id}:
    patch:
      tags:
        - Sub-agents
      summary: Update Sub-Agent
      description: >-
        Update an existing sub-agent. Only fields included in the request are
        changed.
      operationId: update_sub_agent_endpoint_api_sub_agents__sub_agent_id__patch
      parameters:
        - name: sub_agent_id
          in: path
          required: true
          schema:
            type: integer
            title: Sub Agent Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubAgentUpdateRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubAgentMutationResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - BearerAuth: []
components:
  schemas:
    SubAgentUpdateRequest:
      properties:
        sub_agent_name:
          anyOf:
            - type: string
              minLength: 1
            - type: 'null'
          title: Sub Agent Name
          description: >-
            Updated display name for the sub-agent. The API derives the stored
            key from this value when provided.
        agent_type:
          anyOf:
            - $ref: '#/components/schemas/SubAgentType'
            - type: 'null'
          description: Updated sub-agent type.
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
          description: Updated description that explains the sub-agent's intent.
        system_prompt:
          anyOf:
            - type: string
            - type: 'null'
          title: System Prompt
          description: Updated prompt template ID used as the sub-agent system prompt.
        system_prompt_template:
          anyOf:
            - $ref: '#/components/schemas/SystemPromptCreateRequest'
            - type: 'null'
          description: >-
            System prompt template to create when system_prompt ID is not
            provided.
        llm_model:
          anyOf:
            - type: integer
            - type: 'null'
          title: Llm Model
          description: >-
            Updated LLM model ID. If omitted, provide llm_model_name to resolve
            the model by name.
        llm_model_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Llm Model Name
          description: LLM model name to resolve when llm_model ID is not provided.
        model_config:
          anyOf:
            - $ref: '#/components/schemas/SubAgentModelConfigRequest'
            - type: 'null'
          description: Updated assistant-only LLM settings for this sub-agent.
        config:
          anyOf:
            - $ref: '#/components/schemas/SubAgentConfigRequest'
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Config
          description: >-
            Updated sub-agent behavior, visibility, memory, and structured
            output settings.
      type: object
      title: SubAgentUpdateRequest
    SubAgentMutationResponse:
      properties:
        success:
          type: boolean
          title: Success
          description: Whether the request was successful.
        error_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Type
          description: Type of error if the request failed.
        error_message:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Message
          description: Error message or informational message.
        data:
          $ref: '#/components/schemas/SubAgentMutationData'
          description: Sub-agent mutation results.
      type: object
      required:
        - success
        - data
      title: SubAgentMutationResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    SubAgentType:
      type: string
      enum:
        - assistant
        - user_proxy
      title: SubAgentType
    SystemPromptCreateRequest:
      properties:
        name:
          type: string
          minLength: 1
          title: Name
          description: System prompt template name.
        version:
          type: string
          minLength: 1
          title: Version
          description: System prompt template version.
          default: '0.1'
        is_active:
          type: boolean
          title: Is Active
          description: Whether this system prompt template version is active.
          default: true
        content:
          type: string
          minLength: 1
          title: Content
          description: System prompt template content.
        metadata:
          anyOf:
            - $ref: '#/components/schemas/PromptTemplateMetadataRequest'
            - type: 'null'
          description: >-
            Optional system prompt template metadata. Required variables and
            tool IDs are derived automatically.
      type: object
      required:
        - name
        - content
      title: SystemPromptCreateRequest
    SubAgentModelConfigRequest:
      properties:
        temperature:
          anyOf:
            - type: number
            - type: integer
          title: Temperature
          description: LLM temperature for this sub-agent.
          default: 0
      type: object
      title: SubAgentModelConfigRequest
    SubAgentConfigRequest:
      properties:
        human_input_mode:
          type: string
          title: Human Input Mode
          description: Autogen human input mode for this sub-agent.
          default: NEVER
        code_execution_config:
          type: boolean
          title: Code Execution Config
          description: Enable code execution for this sub-agent.
          default: false
        max_consecutive_auto_reply:
          anyOf:
            - type: integer
            - type: 'null'
          title: Max Consecutive Auto Reply
          description: Maximum consecutive auto replies before stopping.
        visible_senders:
          items:
            type: integer
          type: array
          title: Visible Senders
          description: Limit context to messages from these sub-agent IDs.
        hidden_senders:
          items:
            type: integer
          type: array
          title: Hidden Senders
          description: Suppress messages from these sub-agent IDs.
        hide_tool_calls:
          type: boolean
          title: Hide Tool Calls
          description: Hide tool call metadata from this sub-agent.
          default: false
        hide_tool_responses:
          type: boolean
          title: Hide Tool Responses
          description: Hide tool outputs from this sub-agent.
          default: false
        memory_config:
          $ref: '#/components/schemas/SubAgentMemoryConfigRequest'
          description: Memory settings for this sub-agent.
        json_schema:
          additionalProperties: true
          type: object
          title: Json Schema
          description: >-
            Structured output JSON schema for predictable JSON responses. Config
            fields are generated from this schema server-side.
      type: object
      title: SubAgentConfigRequest
    SubAgentMutationData:
      properties:
        items:
          items:
            $ref: '#/components/schemas/SubAgentSearchItem'
          type: array
          title: Items
          description: Created sub-agent rows.
      type: object
      title: SubAgentMutationData
    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
    PromptTemplateMetadataRequest:
      properties:
        tags:
          items:
            type: string
          type: array
          title: Tags
          description: Tags used to organize and search prompt templates.
        description:
          type: string
          title: Description
          description: Prompt template description.
          default: ''
      type: object
      title: PromptTemplateMetadataRequest
    SubAgentMemoryConfigRequest:
      properties:
        enabled:
          type: boolean
          title: Enabled
          description: >-
            Master memory toggle. When off, the sub-agent only sees the current
            conversation.
          default: false
        store_memories:
          type: boolean
          title: Store Memories
          description: Persist this sub-agent's messages after each turn.
          default: true
        use_memory_tools:
          type: boolean
          title: Use Memory Tools
          description: >-
            Register memory query tools so the sub-agent can search, summarize,
            and recall memories.
          default: true
        store_to_scope:
          type: string
          enum:
            - thread
            - agent
            - tenant
          title: Store To Scope
          description: 'Scope where new memories are written: thread, agent, or tenant.'
          default: thread
        search_scopes:
          items:
            type: string
            enum:
              - thread
              - agent
              - tenant
          type: array
          title: Search Scopes
          description: Memory scopes this sub-agent can search and inject from.
        inject_memory_context:
          type: boolean
          title: Inject Memory Context
          description: >-
            Fetch relevant memories from the selected scopes and prepend them
            before the next turn.
          default: true
        memory_context_limit:
          type: integer
          minimum: 0
          title: Memory Context Limit
          description: Maximum number of memories to inject into the sub-agent context.
          default: 3
        allow_compression:
          type: boolean
          title: Allow Compression
          description: >-
            Summarize large messages from other agents and tool responses before
            each turn.
          default: true
        compression_threshold:
          anyOf:
            - type: integer
            - type: 'null'
          title: Compression Threshold
          description: >-
            Message size in characters at which compression can begin. Defaults
            to runtime settings when empty.
        context_limit_mode:
          type: string
          enum:
            - messages
            - tokens
            - chars
          title: Context Limit Mode
          description: How the prompt window is bounded before each turn.
          default: messages
        max_active_messages:
          anyOf:
            - type: integer
            - type: 'null'
          title: Max Active Messages
          description: >-
            Maximum non-system messages kept when context_limit_mode is
            messages.
        max_context_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          title: Max Context Tokens
          description: Maximum prompt tokens kept when context_limit_mode is tokens.
        max_context_chars:
          anyOf:
            - type: integer
            - type: 'null'
          title: Max Context Chars
          description: Maximum prompt characters kept when context_limit_mode is chars.
      additionalProperties: true
      type: object
      title: SubAgentMemoryConfigRequest
    SubAgentSearchItem:
      properties:
        id:
          anyOf:
            - type: integer
            - type: 'null'
          title: Id
          description: Sub-agent ID.
        sub_agent_name_key:
          anyOf:
            - type: string
            - type: 'null'
          title: Sub Agent Name Key
          description: Stored normalized sub-agent key.
        sub_agent_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Sub Agent Name
          description: Human-readable sub-agent name.
        agent_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Agent Type
          description: Sub-agent type.
        tenant:
          anyOf:
            - type: string
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Tenant
          description: Owning tenant ID or joined tenant object.
        tenants:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Tenants
          description: Joined tenant row with id and tenant_name.
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
          description: Sub-agent description.
        system_prompt:
          anyOf:
            - type: string
            - type: 'null'
          title: System Prompt
          description: System prompt template ID.
        llm_model:
          anyOf:
            - type: integer
            - $ref: '#/components/schemas/ParentAgentDetailLLMModel'
            - type: 'null'
          title: Llm Model
          description: LLM model ID or joined model row.
        model_config:
          anyOf:
            - $ref: '#/components/schemas/SubAgentModelConfigRequest'
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Model Config
          description: Sub-agent model configuration.
        config:
          anyOf:
            - $ref: '#/components/schemas/SubAgentConfigRequest'
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Config
          description: Sub-agent runtime configuration.
        prompt_templates:
          anyOf:
            - $ref: '#/components/schemas/PromptTemplateListItem'
            - type: 'null'
          description: Joined system prompt template row.
        agent_groups:
          items:
            $ref: '#/components/schemas/ParentAgentGroupSearchItem'
          type: array
          title: Agent Groups
          description: Parent agents linked to this sub-agent.
        sub_agent_tools:
          items:
            $ref: '#/components/schemas/SubAgentToolSearchItem'
          type: array
          title: Sub Agent Tools
          description: Tools attached to this sub-agent.
        created_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Created At
          description: Creation timestamp.
      type: object
      title: SubAgentSearchItem
    ParentAgentDetailLLMModel:
      properties:
        id:
          anyOf:
            - type: integer
            - type: 'null'
          title: Id
          description: LLM model ID.
        model_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Model Name
          description: Model name.
        model_version:
          anyOf:
            - type: string
            - type: 'null'
          title: Model Version
          description: Model version.
        provider:
          anyOf:
            - type: string
            - type: 'null'
          title: Provider
          description: Model provider.
      type: object
      title: ParentAgentDetailLLMModel
    PromptTemplateListItem:
      properties:
        id:
          anyOf:
            - type: string
            - type: 'null'
          title: Id
          description: Prompt template ID.
        tenant_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Tenant Id
          description: Owning tenant ID.
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          description: Prompt template name.
        version:
          anyOf:
            - type: string
            - type: 'null'
          title: Version
          description: Prompt template version.
        is_active:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Is Active
          description: Whether this prompt template version is active.
        content:
          anyOf:
            - type: string
            - type: 'null'
          title: Content
          description: Prompt template content.
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
          description: Prompt template metadata.
        latest_version:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Latest Version
          description: Whether this row is marked as the latest template version.
        created_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Created At
          description: Creation timestamp.
        updated_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Updated At
          description: Last update timestamp.
      type: object
      title: PromptTemplateListItem
    ParentAgentGroupSearchItem:
      properties:
        parent_agent_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Parent Agent Type
          description: Human-readable parent agent type from agents.agent_displayName.
        parent_agent_type_key:
          anyOf:
            - type: string
            - type: 'null'
          title: Parent Agent Type Key
          description: Parent agent type key from agents.agent_name.
        agent_key:
          anyOf:
            - type: string
            - type: 'null'
          title: Agent Key
          description: Stored parent agent key.
        agent_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Agent Name
          description: >-
            User-facing agent name derived from agent_key with underscores
            converted to spaces.
        full_display_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Full Display Name
          description: Full display name for the parent agent.
        tenant:
          anyOf:
            - type: string
            - type: 'null'
          title: Tenant
          description: Owning tenant ID.
      type: object
      title: ParentAgentGroupSearchItem
    SubAgentToolSearchItem:
      properties:
        id:
          anyOf:
            - type: integer
            - type: 'null'
          title: Id
          description: Sub-agent tool link ID.
        agent_tool_id:
          anyOf:
            - type: integer
            - type: 'null'
          title: Agent Tool Id
          description: Linked agent tool ID.
        option:
          anyOf:
            - type: string
            - type: 'null'
          title: Option
          description: How the sub-agent can use the tool.
        tenant:
          anyOf:
            - type: string
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Tenant
          description: Owning tenant ID or joined tenant object.
        system_agent_tool:
          anyOf:
            - type: integer
            - type: 'null'
          title: System Agent Tool
          description: Linked system tool ID.
        setting_id:
          anyOf:
            - type: integer
            - type: 'null'
          title: Setting Id
          description: Connector settings ID used by this tool.
        default_tool_owner_config:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Default Tool Owner Config
          description: Owner default configuration for quick assignment.
        tool_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Tool Name
          description: Effective system tool name.
        tool_name_display:
          anyOf:
            - type: string
            - type: 'null'
          title: Tool Name Display
          description: Effective display name for the tool.
        tool_description:
          anyOf:
            - type: string
            - type: 'null'
          title: Tool Description
          description: Effective system tool description.
        tool_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Tool Type
          description: Effective system tool type.
        custom_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Custom Name
          description: Tenant-specific tool name override.
        custom_description:
          anyOf:
            - type: string
            - type: 'null'
          title: Custom Description
          description: Tenant-specific tool description override.
        connector_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Connector Name
          description: Connector key from the linked system tool.
        connector_name_display:
          anyOf:
            - type: string
            - type: 'null'
          title: Connector Name Display
          description: Human-readable connector name.
        connector_image:
          anyOf:
            - type: string
            - type: 'null'
          title: Connector Image
          description: Connector image URL.
        custom_connection_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Custom Connection Name
          description: Tenant-specific connection display name.
        custom_connection_description:
          anyOf:
            - type: string
            - type: 'null'
          title: Custom Connection Description
          description: Tenant-specific connection description.
        index_setting_id:
          anyOf:
            - type: integer
            - type: 'null'
          title: Index Setting Id
          description: Linked index store setting ID.
        is_orphaned:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Is Orphaned
          description: Whether the tool is orphaned from its source system tool.
        created_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Created At
          description: Agent tool creation timestamp.
      type: object
      title: SubAgentToolSearchItem
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````