{
  "openapi": "3.1.0",
  "info": {
    "title": "Sierra 팀 Chat API",
    "version": "1.0.0",
    "description": "팀 Bearer token과 X-User-ID로 호출하는 Chat·Session·Memory API입니다. /docs에서 Python 온보딩 가이드, /docs/playground에서 JSON·SSE 요청, /docs/swagger에서 상세 schema를 확인합니다."
  },
  "servers": [
    {
      "url": "https://sierra-agent-dev.bittersweet.ai",
      "description": "공식 Sierra API 서버"
    },
    {
      "url": "/",
      "description": "현재 Sierra 서버 (로컬·검증 환경)"
    }
  ],
  "security": [
    {
      "TeamBearer": []
    }
  ],
  "paths": {
    "/api/v1/admin/users": {
      "get": {
        "summary": "등록된 사용자 목록",
        "operationId": "get_admin_users",
        "description": "팀 운영용 목록입니다. Bearer token이 필요하고 user header는 사용하지 않습니다.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "성공",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "users": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/User"
                      }
                    }
                  },
                  "required": [
                    "users"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "입력 오류",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "팀 토큰 누락/불일치",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "선택한 사용자에게 없는 리소스",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "같은 사용자 실행 중, 멱등 key 충돌 또는 오래된 revision",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "DB 또는 실행 서비스 이용 불가",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "교차 Origin 변경 요청 거부",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/chat": {
      "post": {
        "summary": "사용자 현재 대화에 메시지 전송",
        "operationId": "post_chat",
        "description": "첫 chat는 user와 session을 등록합니다. 이후 latest CREATED session을 재사용합니다. 모델은 기본 gpt-6-luna입니다. 재시도 key는 원래 run/session에 고정됩니다. stream=true는 SSE입니다.",
        "parameters": [
          {
            "name": "X-User-ID",
            "in": "header",
            "required": true,
            "description": "호출 backend가 선택한 case-sensitive external user ID (1~256자). UUID가 아니어도 됩니다. 이 header만 사용자 식별에 사용하며 body나 이전 header로 덮어쓸 수 없습니다.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "docs-demo"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "동일 요청 재시도에는 동일 key를 재사용합니다. 다른 message로 재사용하면 409입니다.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            }
          }
        ],
        "responses": {
          "200": {
            "description": "성공",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Run"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "각 frame의 data는 Event JSON. 빈 줄이 frame 경계입니다."
                },
                "x-event-schema": {
                  "$ref": "#/components/schemas/Event"
                },
                "example": "data: {\"version\":1,\"type\":\"text.delta\",\"user_id\":\"junseong\",\"session_id\":\"session-id\",\"run_id\":\"run-id\",\"data\":{\"text\":\"안녕하세요\"}}\n\n"
              }
            }
          },
          "400": {
            "description": "입력 오류",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "팀 토큰 누락/불일치",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "선택한 사용자에게 없는 리소스",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "같은 사용자 실행 중, 멱등 key 충돌 또는 오래된 revision",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "DB/메모리 저장 불가 또는 서버 종료 중(server_draining)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "교차 Origin 변경 요청 거부",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatRequest"
              },
              "example": {
                "message": "안녕하세요",
                "stream": false
              }
            }
          }
        },
        "tags": [
          "Chat"
        ]
      }
    },
    "/api/v1/clear": {
      "post": {
        "summary": "기억을 보존하며 새 대화 생성",
        "operationId": "post_clear",
        "description": "기존 대화와 memory를 삭제하지 않습니다. 같은 사용자 실행 중에는 409이며 취소/완료 뒤 다시 요청합니다. 첫 chat 전에는 current session이 없으므로 404입니다.",
        "parameters": [
          {
            "name": "X-User-ID",
            "in": "header",
            "required": true,
            "description": "호출 backend가 선택한 case-sensitive external user ID (1~256자). UUID가 아니어도 됩니다. 이 header만 사용자 식별에 사용하며 body나 이전 header로 덮어쓸 수 없습니다.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "docs-demo"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "동일 요청 재시도에는 동일 key를 재사용합니다. 다른 message로 재사용하면 409입니다.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            }
          }
        ],
        "responses": {
          "201": {
            "description": "성공",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Clear"
                }
              }
            }
          },
          "400": {
            "description": "입력 오류",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "팀 토큰 누락/불일치",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "선택한 사용자에게 없는 리소스",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "같은 사용자 실행 중, 멱등 key 충돌 또는 오래된 revision",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "DB/메모리 저장 불가 또는 서버 종료 중(server_draining)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "교차 Origin 변경 요청 거부",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false
              },
              "example": {}
            }
          }
        },
        "tags": [
          "Chat"
        ]
      }
    },
    "/api/v1/session": {
      "get": {
        "summary": "현재 latest CREATED 세션",
        "operationId": "get_session",
        "description": "현재 세션의 생성 정보와 전체 SDK entries/messages 및 active context를 반환합니다. 첫 chat 전에는 404입니다.",
        "parameters": [
          {
            "name": "X-User-ID",
            "in": "header",
            "required": true,
            "description": "호출 backend가 선택한 case-sensitive external user ID (1~256자). UUID가 아니어도 됩니다. 이 header만 사용자 식별에 사용하며 body나 이전 header로 덮어쓸 수 없습니다.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "docs-demo"
          }
        ],
        "responses": {
          "200": {
            "description": "성공",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionDetail"
                },
                "example": {
                  "user_id": "team-user-001",
                  "session_id": "11111111-1111-4111-8111-111111111111",
                  "generation": 1,
                  "created_at": "2026-10-05T12:00:00.000Z",
                  "entries": [
                    {
                      "type": "message",
                      "id": "entry-001",
                      "parentId": null,
                      "timestamp": "2026-10-05T12:00:00.000Z",
                      "message": {
                        "role": "user",
                        "content": [
                          {
                            "type": "text",
                            "text": "안녕하세요"
                          }
                        ],
                        "timestamp": 1791201600000
                      }
                    },
                    {
                      "type": "message",
                      "id": "entry-002",
                      "parentId": "entry-001",
                      "timestamp": "2026-10-05T12:00:01.000Z",
                      "message": {
                        "role": "assistant",
                        "content": [
                          {
                            "type": "text",
                            "text": "안녕하세요!"
                          }
                        ],
                        "api": "openai-responses",
                        "provider": "openai",
                        "model": "gpt-6-luna",
                        "usage": {
                          "input": 0,
                          "output": 0,
                          "cacheRead": 0,
                          "cacheWrite": 0,
                          "totalTokens": 0,
                          "cost": {
                            "input": 0,
                            "output": 0,
                            "cacheRead": 0,
                            "cacheWrite": 0,
                            "total": 0
                          }
                        },
                        "stopReason": "stop",
                        "timestamp": 1791201601000
                      }
                    }
                  ],
                  "messages": [
                    {
                      "role": "user",
                      "content": [
                        {
                          "type": "text",
                          "text": "안녕하세요"
                        }
                      ],
                      "timestamp": 1791201600000
                    },
                    {
                      "role": "assistant",
                      "content": [
                        {
                          "type": "text",
                          "text": "안녕하세요!"
                        }
                      ],
                      "api": "openai-responses",
                      "provider": "openai",
                      "model": "gpt-6-luna",
                      "usage": {
                        "input": 0,
                        "output": 0,
                        "cacheRead": 0,
                        "cacheWrite": 0,
                        "totalTokens": 0,
                        "cost": {
                          "input": 0,
                          "output": 0,
                          "cacheRead": 0,
                          "cacheWrite": 0,
                          "total": 0
                        }
                      },
                      "stopReason": "stop",
                      "timestamp": 1791201601000
                    }
                  ],
                  "context": [
                    {
                      "role": "user",
                      "content": [
                        {
                          "type": "text",
                          "text": "안녕하세요"
                        }
                      ],
                      "timestamp": 1791201600000
                    },
                    {
                      "role": "assistant",
                      "content": [
                        {
                          "type": "text",
                          "text": "안녕하세요!"
                        }
                      ],
                      "api": "openai-responses",
                      "provider": "openai",
                      "model": "gpt-6-luna",
                      "usage": {
                        "input": 0,
                        "output": 0,
                        "cacheRead": 0,
                        "cacheWrite": 0,
                        "totalTokens": 0,
                        "cost": {
                          "input": 0,
                          "output": 0,
                          "cacheRead": 0,
                          "cacheWrite": 0,
                          "total": 0
                        }
                      },
                      "stopReason": "stop",
                      "timestamp": 1791201601000
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "입력 오류",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "팀 토큰 누락/불일치",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "선택한 사용자에게 없는 리소스",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "같은 사용자 실행 중, 멱등 key 충돌 또는 오래된 revision",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "DB 또는 실행 서비스 이용 불가",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "교차 Origin 변경 요청 거부",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "tags": [
          "Sessions"
        ]
      }
    },
    "/api/v1/messages": {
      "get": {
        "summary": "현재 세션의 대화",
        "operationId": "get_messages",
        "description": "",
        "parameters": [
          {
            "name": "X-User-ID",
            "in": "header",
            "required": true,
            "description": "호출 backend가 선택한 case-sensitive external user ID (1~256자). UUID가 아니어도 됩니다. 이 header만 사용자 식별에 사용하며 body나 이전 header로 덮어쓸 수 없습니다.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "docs-demo"
          }
        ],
        "responses": {
          "200": {
            "description": "성공",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "user_id": {
                      "type": "string"
                    },
                    "session_id": {
                      "type": "string"
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Message"
                      }
                    }
                  },
                  "required": [
                    "user_id",
                    "session_id",
                    "messages"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "입력 오류",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "팀 토큰 누락/불일치",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "선택한 사용자에게 없는 리소스",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "같은 사용자 실행 중, 멱등 key 충돌 또는 오래된 revision",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "DB 또는 실행 서비스 이용 불가",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "교차 Origin 변경 요청 거부",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "tags": [
          "Sessions"
        ]
      }
    },
    "/api/v1/sessions": {
      "get": {
        "summary": "생성 순서의 세션 목록",
        "operationId": "get_sessions",
        "description": "사용자 세션을 최신 생성 순으로 반환합니다. current_session_id와 각 is_current를 함께 제공합니다. 조회는 current를 변경하지 않습니다.",
        "parameters": [
          {
            "name": "X-User-ID",
            "in": "header",
            "required": true,
            "description": "호출 backend가 선택한 case-sensitive external user ID (1~256자). UUID가 아니어도 됩니다. 이 header만 사용자 식별에 사용하며 body나 이전 header로 덮어쓸 수 없습니다.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "docs-demo"
          }
        ],
        "responses": {
          "200": {
            "description": "성공",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionList"
                },
                "example": {
                  "user_id": "team-user-001",
                  "current_session_id": "22222222-2222-4222-8222-222222222222",
                  "sessions": [
                    {
                      "user_id": "team-user-001",
                      "session_id": "22222222-2222-4222-8222-222222222222",
                      "generation": 2,
                      "created_at": "2026-10-05T12:05:00.000Z",
                      "is_current": true
                    },
                    {
                      "user_id": "team-user-001",
                      "session_id": "11111111-1111-4111-8111-111111111111",
                      "generation": 1,
                      "created_at": "2026-10-05T12:00:00.000Z",
                      "is_current": false
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "입력 오류",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "팀 토큰 누락/불일치",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "선택한 사용자에게 없는 리소스",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "같은 사용자 실행 중, 멱등 key 충돌 또는 오래된 revision",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "DB 또는 실행 서비스 이용 불가",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "교차 Origin 변경 요청 거부",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "tags": [
          "Sessions"
        ]
      }
    },
    "/api/v1/sessions/{session_id}": {
      "get": {
        "summary": "소유 세션의 읽기 전용 기록",
        "operationId": "get_sessions_session_id",
        "description": "선택한 사용자가 소유한 세션의 전체 SDK entries/messages/context를 읽습니다. 과거 세션 조회가 current pointer를 변경하지 않습니다. 없는 ID와 다른 사용자 소유 ID는 모두 404입니다.",
        "parameters": [
          {
            "name": "X-User-ID",
            "in": "header",
            "required": true,
            "description": "호출 backend가 선택한 case-sensitive external user ID (1~256자). UUID가 아니어도 됩니다. 이 header만 사용자 식별에 사용하며 body나 이전 header로 덮어쓸 수 없습니다.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "docs-demo"
          },
          {
            "name": "session_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "성공",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionDetail"
                },
                "example": {
                  "user_id": "team-user-001",
                  "session_id": "11111111-1111-4111-8111-111111111111",
                  "generation": 1,
                  "created_at": "2026-10-05T12:00:00.000Z",
                  "entries": [
                    {
                      "type": "message",
                      "id": "entry-001",
                      "parentId": null,
                      "timestamp": "2026-10-05T12:00:00.000Z",
                      "message": {
                        "role": "user",
                        "content": [
                          {
                            "type": "text",
                            "text": "안녕하세요"
                          }
                        ],
                        "timestamp": 1791201600000
                      }
                    },
                    {
                      "type": "message",
                      "id": "entry-002",
                      "parentId": "entry-001",
                      "timestamp": "2026-10-05T12:00:01.000Z",
                      "message": {
                        "role": "assistant",
                        "content": [
                          {
                            "type": "text",
                            "text": "안녕하세요!"
                          }
                        ],
                        "api": "openai-responses",
                        "provider": "openai",
                        "model": "gpt-6-luna",
                        "usage": {
                          "input": 0,
                          "output": 0,
                          "cacheRead": 0,
                          "cacheWrite": 0,
                          "totalTokens": 0,
                          "cost": {
                            "input": 0,
                            "output": 0,
                            "cacheRead": 0,
                            "cacheWrite": 0,
                            "total": 0
                          }
                        },
                        "stopReason": "stop",
                        "timestamp": 1791201601000
                      }
                    }
                  ],
                  "messages": [
                    {
                      "role": "user",
                      "content": [
                        {
                          "type": "text",
                          "text": "안녕하세요"
                        }
                      ],
                      "timestamp": 1791201600000
                    },
                    {
                      "role": "assistant",
                      "content": [
                        {
                          "type": "text",
                          "text": "안녕하세요!"
                        }
                      ],
                      "api": "openai-responses",
                      "provider": "openai",
                      "model": "gpt-6-luna",
                      "usage": {
                        "input": 0,
                        "output": 0,
                        "cacheRead": 0,
                        "cacheWrite": 0,
                        "totalTokens": 0,
                        "cost": {
                          "input": 0,
                          "output": 0,
                          "cacheRead": 0,
                          "cacheWrite": 0,
                          "total": 0
                        }
                      },
                      "stopReason": "stop",
                      "timestamp": 1791201601000
                    }
                  ],
                  "context": [
                    {
                      "role": "user",
                      "content": [
                        {
                          "type": "text",
                          "text": "안녕하세요"
                        }
                      ],
                      "timestamp": 1791201600000
                    },
                    {
                      "role": "assistant",
                      "content": [
                        {
                          "type": "text",
                          "text": "안녕하세요!"
                        }
                      ],
                      "api": "openai-responses",
                      "provider": "openai",
                      "model": "gpt-6-luna",
                      "usage": {
                        "input": 0,
                        "output": 0,
                        "cacheRead": 0,
                        "cacheWrite": 0,
                        "totalTokens": 0,
                        "cost": {
                          "input": 0,
                          "output": 0,
                          "cacheRead": 0,
                          "cacheWrite": 0,
                          "total": 0
                        }
                      },
                      "stopReason": "stop",
                      "timestamp": 1791201601000
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "입력 오류",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "팀 토큰 누락/불일치",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "선택한 사용자에게 없는 리소스",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "같은 사용자 실행 중, 멱등 key 충돌 또는 오래된 revision",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "DB 또는 실행 서비스 이용 불가",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "교차 Origin 변경 요청 거부",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "tags": [
          "Sessions"
        ]
      }
    },
    "/api/v1/runs/{run_id}": {
      "get": {
        "summary": "run 상태 확인",
        "operationId": "get_runs_run_id",
        "description": "불확실한 응답이나 스트림 단절 뒤 원래 run의 상태를 확인합니다.",
        "parameters": [
          {
            "name": "X-User-ID",
            "in": "header",
            "required": true,
            "description": "호출 backend가 선택한 case-sensitive external user ID (1~256자). UUID가 아니어도 됩니다. 이 header만 사용자 식별에 사용하며 body나 이전 header로 덮어쓸 수 없습니다.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "docs-demo"
          },
          {
            "name": "run_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "성공",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Run"
                }
              }
            }
          },
          "400": {
            "description": "입력 오류",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "팀 토큰 누락/불일치",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "선택한 사용자에게 없는 리소스",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "같은 사용자 실행 중, 멱등 key 충돌 또는 오래된 revision",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "DB 또는 실행 서비스 이용 불가",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "교차 Origin 변경 요청 거부",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "tags": [
          "Runs"
        ]
      }
    },
    "/api/v1/runs/{run_id}/cancel": {
      "post": {
        "summary": "run 취소 요청",
        "operationId": "post_runs_run_id_cancel",
        "description": "취소 요청 뒤 running이면 상태를 다시 확인합니다. 최종 상태를 받기 전에는 새 run을 시작하지 않습니다.",
        "parameters": [
          {
            "name": "X-User-ID",
            "in": "header",
            "required": true,
            "description": "호출 backend가 선택한 case-sensitive external user ID (1~256자). UUID가 아니어도 됩니다. 이 header만 사용자 식별에 사용하며 body나 이전 header로 덮어쓸 수 없습니다.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "docs-demo"
          },
          {
            "name": "run_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "성공",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Run"
                }
              }
            }
          },
          "400": {
            "description": "입력 오류",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "팀 토큰 누락/불일치",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "선택한 사용자에게 없는 리소스",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "같은 사용자 실행 중, 멱등 key 충돌 또는 오래된 revision",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "DB/메모리 저장 불가 또는 서버 종료 중(server_draining)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "교차 Origin 변경 요청 거부",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {}
            }
          }
        },
        "tags": [
          "Runs"
        ]
      }
    },
    "/api/v1/memory": {
      "get": {
        "summary": "사용자 memory와 학습 작업",
        "operationId": "get_memory",
        "description": "대화가 완료되어도 memory 작업은 queued/running일 수 있습니다. revision은 낙관적 동시성 token이며 clear 뒤에도 유지됩니다.",
        "parameters": [
          {
            "name": "X-User-ID",
            "in": "header",
            "required": true,
            "description": "호출 backend가 선택한 case-sensitive external user ID (1~256자). UUID가 아니어도 됩니다. 이 header만 사용자 식별에 사용하며 body나 이전 header로 덮어쓸 수 없습니다.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "docs-demo"
          }
        ],
        "responses": {
          "200": {
            "description": "성공",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Memory"
                }
              }
            }
          },
          "400": {
            "description": "입력 오류",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "팀 토큰 누락/불일치",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "선택한 사용자에게 없는 리소스",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "같은 사용자 실행 중, 멱등 key 충돌 또는 오래된 revision",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "DB 또는 실행 서비스 이용 불가",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "교차 Origin 변경 요청 거부",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "tags": [
          "Memory"
        ]
      }
    },
    "/api/v1/memory/{record_id}": {
      "get": {
        "summary": "검토할 기록과 revision",
        "operationId": "get_memory_record_id",
        "description": "",
        "parameters": [
          {
            "name": "X-User-ID",
            "in": "header",
            "required": true,
            "description": "호출 backend가 선택한 case-sensitive external user ID (1~256자). UUID가 아니어도 됩니다. 이 header만 사용자 식별에 사용하며 body나 이전 header로 덮어쓸 수 없습니다.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "docs-demo"
          },
          {
            "name": "record_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "성공",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MemoryDetail"
                }
              }
            }
          },
          "400": {
            "description": "입력 오류",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "팀 토큰 누락/불일치",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "선택한 사용자에게 없는 리소스",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "같은 사용자 실행 중, 멱등 key 충돌 또는 오래된 revision",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "DB 또는 실행 서비스 이용 불가",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "교차 Origin 변경 요청 거부",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "tags": [
          "Memory"
        ]
      }
    },
    "/api/v1/memory/{record_id}/history": {
      "get": {
        "summary": "메모리 변경 이력",
        "operationId": "get_memory_record_id_history",
        "description": "비활성화 이전 기록과 저장된 revision history를 포함합니다.",
        "parameters": [
          {
            "name": "X-User-ID",
            "in": "header",
            "required": true,
            "description": "호출 backend가 선택한 case-sensitive external user ID (1~256자). UUID가 아니어도 됩니다. 이 header만 사용자 식별에 사용하며 body나 이전 header로 덮어쓸 수 없습니다.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "docs-demo"
          },
          {
            "name": "record_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "성공",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "입력 오류",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "팀 토큰 누락/불일치",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "선택한 사용자에게 없는 리소스",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "같은 사용자 실행 중, 멱등 key 충돌 또는 오래된 revision",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "DB 또는 실행 서비스 이용 불가",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "교차 Origin 변경 요청 거부",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "tags": [
          "Memory"
        ]
      }
    },
    "/api/v1/memory/{record_id}/correct": {
      "post": {
        "summary": "출처를 갖는 메모리 정정",
        "operationId": "post_memory_record_id_correct",
        "description": "detail에서 받은 commit을 base_commit으로 전송합니다. 오래된 검토 revision은 409입니다. 실패/대기 상태를 저장 완료로 처리하지 않습니다.",
        "parameters": [
          {
            "name": "X-User-ID",
            "in": "header",
            "required": true,
            "description": "호출 backend가 선택한 case-sensitive external user ID (1~256자). UUID가 아니어도 됩니다. 이 header만 사용자 식별에 사용하며 body나 이전 header로 덮어쓸 수 없습니다.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "docs-demo"
          },
          {
            "name": "record_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "성공",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MutationResult"
                }
              }
            }
          },
          "400": {
            "description": "입력 오류",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "팀 토큰 누락/불일치",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "선택한 사용자에게 없는 리소스",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "같은 사용자 실행 중, 멱등 key 충돌 또는 오래된 revision",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "DB/메모리 저장 불가 또는 서버 종료 중(server_draining)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "교차 Origin 변경 요청 거부",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "base_commit": {
                    "type": "string",
                    "minLength": 1
                  },
                  "content": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "base_commit",
                  "content"
                ]
              },
              "example": {
                "base_commit": "<GET memory record 응답의 commit>",
                "content": "정정할 기억 내용"
              }
            }
          }
        },
        "tags": [
          "Memory"
        ]
      }
    },
    "/api/v1/memory/{record_id}/deactivate": {
      "post": {
        "summary": "메모리 검색에서 제외",
        "operationId": "post_memory_record_id_deactivate",
        "description": "detail에서 받은 commit을 base_commit으로 전송합니다. 오래된 검토 revision은 409입니다. 실패/대기 상태를 저장 완료로 처리하지 않습니다.",
        "parameters": [
          {
            "name": "X-User-ID",
            "in": "header",
            "required": true,
            "description": "호출 backend가 선택한 case-sensitive external user ID (1~256자). UUID가 아니어도 됩니다. 이 header만 사용자 식별에 사용하며 body나 이전 header로 덮어쓸 수 없습니다.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "docs-demo"
          },
          {
            "name": "record_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "성공",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MutationResult"
                }
              }
            }
          },
          "400": {
            "description": "입력 오류",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "팀 토큰 누락/불일치",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "선택한 사용자에게 없는 리소스",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "같은 사용자 실행 중, 멱등 key 충돌 또는 오래된 revision",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "DB/메모리 저장 불가 또는 서버 종료 중(server_draining)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "교차 Origin 변경 요청 거부",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "base_commit": {
                    "type": "string",
                    "minLength": 1
                  },
                  "content": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "base_commit"
                ]
              },
              "example": {
                "base_commit": "<GET memory record 응답의 commit>"
              }
            }
          }
        },
        "tags": [
          "Memory"
        ]
      }
    },
    "/api/v1/memory/{record_id}/reactivate": {
      "post": {
        "summary": "메모리 다시 활성화",
        "operationId": "post_memory_record_id_reactivate",
        "description": "detail에서 받은 commit을 base_commit으로 전송합니다. 오래된 검토 revision은 409입니다. 실패/대기 상태를 저장 완료로 처리하지 않습니다.",
        "parameters": [
          {
            "name": "X-User-ID",
            "in": "header",
            "required": true,
            "description": "호출 backend가 선택한 case-sensitive external user ID (1~256자). UUID가 아니어도 됩니다. 이 header만 사용자 식별에 사용하며 body나 이전 header로 덮어쓸 수 없습니다.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "docs-demo"
          },
          {
            "name": "record_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "성공",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MutationResult"
                }
              }
            }
          },
          "400": {
            "description": "입력 오류",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "팀 토큰 누락/불일치",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "선택한 사용자에게 없는 리소스",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "같은 사용자 실행 중, 멱등 key 충돌 또는 오래된 revision",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "DB/메모리 저장 불가 또는 서버 종료 중(server_draining)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "교차 Origin 변경 요청 거부",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "base_commit": {
                    "type": "string",
                    "minLength": 1
                  },
                  "content": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "base_commit"
                ]
              },
              "example": {
                "base_commit": "<GET memory record 응답의 commit>"
              }
            }
          }
        },
        "tags": [
          "Memory"
        ]
      }
    },
    "/api/v1/memory/sources/{observation_id}": {
      "get": {
        "summary": "보존된 원본 근거",
        "operationId": "get_memory_sources_observation_id",
        "description": "선택한 사용자에 속한 original user/tool evidence만 반환합니다. assistant 요약을 사용자 발언으로 취급하지 않습니다.",
        "parameters": [
          {
            "name": "X-User-ID",
            "in": "header",
            "required": true,
            "description": "호출 backend가 선택한 case-sensitive external user ID (1~256자). UUID가 아니어도 됩니다. 이 header만 사용자 식별에 사용하며 body나 이전 header로 덮어쓸 수 없습니다.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "docs-demo"
          },
          {
            "name": "observation_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "성공",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "입력 오류",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "팀 토큰 누락/불일치",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "선택한 사용자에게 없는 리소스",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "같은 사용자 실행 중, 멱등 key 충돌 또는 오래된 revision",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "DB 또는 실행 서비스 이용 불가",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "교차 Origin 변경 요청 거부",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "tags": [
          "Memory"
        ]
      }
    },
    "/api/v1/memory/jobs/{job_id}/retry": {
      "post": {
        "summary": "실패한 memory job 재시도",
        "operationId": "post_memory_jobs_job_id_retry",
        "description": "",
        "parameters": [
          {
            "name": "X-User-ID",
            "in": "header",
            "required": true,
            "description": "호출 backend가 선택한 case-sensitive external user ID (1~256자). UUID가 아니어도 됩니다. 이 header만 사용자 식별에 사용하며 body나 이전 header로 덮어쓸 수 없습니다.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "docs-demo"
          },
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "성공",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MutationResult"
                }
              }
            }
          },
          "400": {
            "description": "입력 오류",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "팀 토큰 누락/불일치",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "선택한 사용자에게 없는 리소스",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "같은 사용자 실행 중, 멱등 key 충돌 또는 오래된 revision",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "DB/메모리 저장 불가 또는 서버 종료 중(server_draining)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "교차 Origin 변경 요청 거부",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {}
            }
          }
        },
        "tags": [
          "Memory"
        ]
      }
    },
    "/health/live": {
      "get": {
        "summary": "프로세스 생존 확인",
        "security": [],
        "responses": {
          "200": {
            "description": "정상",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          },
          "503": {
            "description": "준비되지 않음"
          }
        },
        "tags": [
          "System"
        ]
      }
    },
    "/health/ready": {
      "get": {
        "summary": "DB와 실행 준비 확인",
        "security": [],
        "responses": {
          "200": {
            "description": "정상",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          },
          "503": {
            "description": "DB 불가 또는 서버 종료 중",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "status": {
                          "const": "draining"
                        }
                      },
                      "required": [
                        "status"
                      ]
                    }
                  ]
                }
              }
            }
          }
        },
        "description": "인증 없이 최소 준비 상태만 제공합니다. DB 준비 실패 또는 서버 종료 중이면 503이며 DB 정보나 credential은 노출하지 않습니다.",
        "tags": [
          "System"
        ]
      }
    },
    "/api/v1/openapi.json": {
      "get": {
        "summary": "공개 OpenAPI 계약",
        "security": [],
        "responses": {
          "200": {
            "description": "OpenAPI 3.1 document",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "tags": [
          "System"
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "TeamBearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "서버의 SIERRA_API_TOKEN. 사용자별 token이 아닌 신뢰하는 호출 서비스용 팀 token입니다."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "request_id": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message",
              "request_id"
            ]
          }
        },
        "required": [
          "error"
        ],
        "description": "모든 HTTP 오류는 code, message, request_id를 포함합니다. code 목록과 복구 절차는 팀 API 문서를 참조하세요."
      },
      "User": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "user_id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "user_id",
          "name",
          "created_at"
        ]
      },
      "ChatRequest": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100000
          },
          "stream": {
            "type": "boolean",
            "default": false
          }
        },
        "required": [
          "message"
        ],
        "additionalProperties": false,
        "examples": [
          {
            "message": "안녕하세요",
            "stream": false
          }
        ]
      },
      "Run": {
        "type": "object",
        "properties": {
          "user_id": {
            "type": "string"
          },
          "session_id": {
            "type": "string"
          },
          "run_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "completed",
              "failed",
              "interrupted",
              "cancelled"
            ]
          },
          "reply": {
            "type": "string"
          },
          "error": {}
        },
        "required": [
          "user_id",
          "session_id",
          "run_id",
          "status",
          "reply"
        ]
      },
      "Message": {
        "type": "object",
        "properties": {
          "role": {
            "type": "string",
            "description": "SDK role: user, assistant, toolResult 또는 custom 등"
          },
          "content": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            ]
          },
          "timestamp": {
            "type": "integer",
            "description": "SDK message의 Unix epoch milliseconds"
          },
          "api": {
            "type": "string"
          },
          "provider": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "stopReason": {
            "type": "string"
          },
          "usage": {
            "type": "object",
            "additionalProperties": true
          },
          "toolCallId": {
            "type": "string"
          },
          "toolName": {
            "type": "string"
          },
          "isError": {
            "type": "boolean"
          }
        },
        "required": [
          "role"
        ],
        "description": "SDK 메시지를 그대로 반환합니다. role에 따라 text, thinking, toolCall, toolResult, summary 등의 추가 field가 있을 수 있습니다.",
        "additionalProperties": true
      },
      "Clear": {
        "type": "object",
        "properties": {
          "user_id": {
            "type": "string"
          },
          "session_id": {
            "type": "string"
          },
          "previous_session_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "generation": {
            "type": "integer"
          },
          "memory_preserved": {
            "type": "boolean",
            "const": true
          }
        },
        "required": [
          "user_id",
          "session_id",
          "previous_session_id",
          "generation",
          "memory_preserved"
        ]
      },
      "Event": {
        "type": "object",
        "properties": {
          "version": {
            "type": "integer",
            "const": 1
          },
          "type": {
            "type": "string",
            "enum": [
              "run.started",
              "text.delta",
              "run.completed",
              "run.failed",
              "run.interrupted",
              "memory.status",
              "run.cancelled"
            ]
          },
          "user_id": {
            "type": "string"
          },
          "session_id": {
            "type": "string"
          },
          "run_id": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "additionalProperties": true,
            "description": "text.delta는 text, terminal은 reply/status/error를 포함합니다."
          }
        },
        "required": [
          "version",
          "type",
          "user_id",
          "session_id",
          "run_id",
          "data"
        ]
      },
      "MemoryRecord": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "facts": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        },
        "required": [
          "id"
        ],
        "additionalProperties": true
      },
      "MemoryJob": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "error": {}
        },
        "required": [
          "id",
          "status"
        ],
        "additionalProperties": true
      },
      "Memory": {
        "type": "object",
        "properties": {
          "available": {
            "type": "boolean"
          },
          "scope": {
            "type": "object",
            "properties": {
              "user_id": {
                "type": "string"
              }
            },
            "required": [
              "user_id"
            ]
          },
          "records": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MemoryRecord"
            }
          },
          "jobs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MemoryJob"
            }
          },
          "revision": {}
        },
        "required": [
          "available",
          "scope",
          "records",
          "jobs",
          "revision"
        ]
      },
      "MemoryDetail": {
        "type": "object",
        "properties": {
          "record": {
            "$ref": "#/components/schemas/MemoryRecord"
          },
          "commit": {
            "type": "string"
          }
        },
        "required": [
          "record",
          "commit"
        ]
      },
      "MemoryMutation": {
        "type": "object",
        "properties": {
          "base_commit": {
            "type": "string",
            "minLength": 1
          },
          "content": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "base_commit"
        ]
      },
      "MutationResult": {
        "type": "object",
        "properties": {
          "job_id": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "commit": {
            "type": [
              "string",
              "null"
            ]
          },
          "record_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "error": {}
        },
        "additionalProperties": true
      },
      "Health": {
        "type": "object",
        "additionalProperties": true
      },
      "SessionInfo": {
        "type": "object",
        "properties": {
          "user_id": {
            "type": "string"
          },
          "session_id": {
            "type": "string",
            "format": "uuid"
          },
          "generation": {
            "type": "integer",
            "minimum": 1
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "user_id",
          "session_id",
          "generation",
          "created_at"
        ],
        "description": "세션의 사용자·ID·불변 생성 순서 정보입니다."
      },
      "SessionListItem": {
        "allOf": [
          {
            "$ref": "#/components/schemas/SessionInfo"
          },
          {
            "type": "object",
            "properties": {
              "is_current": {
                "type": "boolean",
                "description": "현재 chat/clear가 기준으로 사용하는 세션인지 여부"
              }
            },
            "required": [
              "is_current"
            ]
          }
        ]
      },
      "SessionEntry": {
        "type": "object",
        "description": "원본 SDK journal entry. message, model_change, thinking_level_change, compaction, context_edit, custom 등 entry type별 추가 field를 그대로 보존합니다.",
        "properties": {
          "type": {
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "parentId": {
            "type": [
              "string",
              "null"
            ]
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          },
          "message": {
            "$ref": "#/components/schemas/Message"
          }
        },
        "required": [
          "type",
          "id",
          "parentId",
          "timestamp"
        ],
        "additionalProperties": true
      },
      "SessionDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/SessionInfo"
          },
          {
            "type": "object",
            "properties": {
              "entries": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/SessionEntry"
                },
                "description": "원본 SDK journal 전체. entry ID·parent tree·생성 순서·compaction·context/model 변경을 보존합니다."
              },
              "messages": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Message"
                },
                "description": "보존된 journal의 모든 message entry에서 추출한 SDK 메시지 history. UI 대화 기록에 사용합니다."
              },
              "context": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Message"
                },
                "description": "현재 active leaf와 compaction/context edit를 반영한 SDK 모델 context projection. 전체 history와 다를 수 있습니다."
              }
            },
            "required": [
              "entries",
              "messages",
              "context"
            ]
          }
        ],
        "examples": [
          {
            "user_id": "team-user-001",
            "session_id": "11111111-1111-4111-8111-111111111111",
            "generation": 1,
            "created_at": "2026-10-05T12:00:00.000Z",
            "entries": [
              {
                "type": "message",
                "id": "entry-001",
                "parentId": null,
                "timestamp": "2026-10-05T12:00:00.000Z",
                "message": {
                  "role": "user",
                  "content": [
                    {
                      "type": "text",
                      "text": "안녕하세요"
                    }
                  ],
                  "timestamp": 1791201600000
                }
              },
              {
                "type": "message",
                "id": "entry-002",
                "parentId": "entry-001",
                "timestamp": "2026-10-05T12:00:01.000Z",
                "message": {
                  "role": "assistant",
                  "content": [
                    {
                      "type": "text",
                      "text": "안녕하세요!"
                    }
                  ],
                  "api": "openai-responses",
                  "provider": "openai",
                  "model": "gpt-6-luna",
                  "usage": {
                    "input": 0,
                    "output": 0,
                    "cacheRead": 0,
                    "cacheWrite": 0,
                    "totalTokens": 0,
                    "cost": {
                      "input": 0,
                      "output": 0,
                      "cacheRead": 0,
                      "cacheWrite": 0,
                      "total": 0
                    }
                  },
                  "stopReason": "stop",
                  "timestamp": 1791201601000
                }
              }
            ],
            "messages": [
              {
                "role": "user",
                "content": [
                  {
                    "type": "text",
                    "text": "안녕하세요"
                  }
                ],
                "timestamp": 1791201600000
              },
              {
                "role": "assistant",
                "content": [
                  {
                    "type": "text",
                    "text": "안녕하세요!"
                  }
                ],
                "api": "openai-responses",
                "provider": "openai",
                "model": "gpt-6-luna",
                "usage": {
                  "input": 0,
                  "output": 0,
                  "cacheRead": 0,
                  "cacheWrite": 0,
                  "totalTokens": 0,
                  "cost": {
                    "input": 0,
                    "output": 0,
                    "cacheRead": 0,
                    "cacheWrite": 0,
                    "total": 0
                  }
                },
                "stopReason": "stop",
                "timestamp": 1791201601000
              }
            ],
            "context": [
              {
                "role": "user",
                "content": [
                  {
                    "type": "text",
                    "text": "안녕하세요"
                  }
                ],
                "timestamp": 1791201600000
              },
              {
                "role": "assistant",
                "content": [
                  {
                    "type": "text",
                    "text": "안녕하세요!"
                  }
                ],
                "api": "openai-responses",
                "provider": "openai",
                "model": "gpt-6-luna",
                "usage": {
                  "input": 0,
                  "output": 0,
                  "cacheRead": 0,
                  "cacheWrite": 0,
                  "totalTokens": 0,
                  "cost": {
                    "input": 0,
                    "output": 0,
                    "cacheRead": 0,
                    "cacheWrite": 0,
                    "total": 0
                  }
                },
                "stopReason": "stop",
                "timestamp": 1791201601000
              }
            ]
          }
        ]
      },
      "SessionList": {
        "type": "object",
        "properties": {
          "user_id": {
            "type": "string"
          },
          "current_session_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "sessions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SessionListItem"
            },
            "description": "generation/생성 순서가 가장 최신인 세션부터 반환합니다."
          }
        },
        "required": [
          "user_id",
          "current_session_id",
          "sessions"
        ],
        "examples": [
          {
            "user_id": "team-user-001",
            "current_session_id": "22222222-2222-4222-8222-222222222222",
            "sessions": [
              {
                "user_id": "team-user-001",
                "session_id": "22222222-2222-4222-8222-222222222222",
                "generation": 2,
                "created_at": "2026-10-05T12:05:00.000Z",
                "is_current": true
              },
              {
                "user_id": "team-user-001",
                "session_id": "11111111-1111-4111-8111-111111111111",
                "generation": 1,
                "created_at": "2026-10-05T12:00:00.000Z",
                "is_current": false
              }
            ]
          }
        ]
      }
    }
  },
  "tags": [
    {
      "name": "Chat",
      "description": "메시지 실행과 새 대화"
    },
    {
      "name": "Sessions",
      "description": "현재·과거 대화 조회"
    },
    {
      "name": "Runs",
      "description": "진행 상태 조회와 취소"
    },
    {
      "name": "Memory",
      "description": "사용자 장기 기억과 revision 관리"
    },
    {
      "name": "Admin",
      "description": "팀 운영용 사용자 목록"
    },
    {
      "name": "System",
      "description": "공개 health와 OpenAPI"
    }
  ]
}
