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

# 독립형 Agent 프로젝트 (실험적)

> JSON, YAML 또는 Python으로 독립형 Agent 프로젝트를 만들고 실행합니다.

> [!WARNING]
>
> 독립형 Agent 프로젝트는 실험적 기능입니다. 프로젝트 스키마와 로딩 API는 변경될 수 있습니다. 이 미리 보기를 사용하려면 해당 기능이 포함된 서로 호환되는 CLI 및 SDK 빌드가 필요하며, 관리형 배포에는 호환되는 Enterprise 런타임도 필요합니다. 이 예제가 이전에 설치한 릴리스에서도 지원된다는 의미는 아닙니다.

독립형 Agent 프로젝트는 하나의 Agent를 정의하고 kickoff 시점에 메시지를 받습니다. 기본 프로젝트 형식은 JSON이며, YAML과 Python은 명시적으로 선택할 수 있는 대안입니다. `main.py`, Crew, Flow 또는 팩터리 함수가 필요하지 않습니다.

## 프로젝트 만들기

```shell Terminal theme={null}
crewai create agent support_agent
cd support_agent
cp .env.example .env
```

기본 모델인 `openai/gpt-6-luna`를 사용하도록 `.env`에 `OPENAI_API_KEY`를 설정한 다음 설치하고 실행합니다:

스캐폴드는 이 모델의 도구 호출에 Responses API(`api: responses`)를 사용합니다. YAML/JSON 프로젝트에서는 정의 파일의 `llm.model`과 `llm.api`를 수정하세요. Python 템플릿은 `.env`에서 `MODEL`을 읽고 Responses API를 사용합니다.

```shell Terminal theme={null}
crewai install
crewai run
crewai run --inputs '{"messages":"What are the support hours?"}'
```

`crewai install`은 `uv.lock`을 생성합니다. 이 파일을 프로젝트와 함께 커밋하세요. `.env`는 로컬에 보관하고, 공급자 인증 정보는 배포 환경 설정에 지정하세요.

## 로컬 대화

스캐폴드는 `conversational: true`를 설정하며 Python에서는 `Agent(conversational=True)`를 사용합니다. 터미널에서 `crewai run`을 실행하면 기존 대화형 채팅 인터페이스가 열립니다. 각 메시지는 설정된 Agent와 도구에 세션 기록을 전달합니다. 독립적인 kickoff만 사용하려면 플래그를 false로 설정하세요.

```shell Terminal theme={null}
crewai run
```

```python theme={null}
from crewai.project import load_agent_project

agent = load_agent_project("./support_agent")
agent.handle_turn("Remember that my project is Cedar Finch.")
reply = agent.handle_turn("What is my project's name?")
print(reply.raw)
```

실험적 SDK는 `agent.handle_turn(...)`과 `agent.as_flow()`로 같은 세션을 제공합니다. 기록은 기본적으로 메모리에 유지되며, 프로세스 간 복구를 위해서는 Flow 영속성을 명시적으로 설정해야 합니다. 독립적인 대화마다 별도의 Agent 인스턴스를 사용하세요. `session_id` 옵션은 Flow 세션을 식별하거나 복원하며 하나의 Agent를 동시 다중 세션 서버로 만들지는 않습니다.

## 프로젝트 구조

```text theme={null}
support_agent/
├── agent.json
├── pyproject.toml
├── uv.lock
├── .env.example
├── .gitignore
├── README.md
├── tools/
│   ├── __init__.py
│   ├── support_hours.py
│   ├── lookup_plan.py
│   └── support_checklist.py
└── skills/
    └── .gitkeep
```

설정 기반 프로젝트에는 소스 패키지가 없습니다. 스캐폴드에는 가상의 지원 서비스를 위한 로컬 도구 세 개와 빈 스킬 디렉터리가 포함됩니다. 모델 공급자 키 외에 추가 서비스나 인증 정보가 필요하지 않습니다.

생성된 `pyproject.toml`은 Agent 정의를 선택하고 설정과 로컬 도구를 패키지에 포함합니다:

```toml theme={null}
[tool.crewai]
type = "agent"
definition = "agent.json"

[tool.hatch.build.targets.wheel]
only-include = ["agent.json", "tools", "skills"]
```

## Agent 정의하기

기본 정체성은 범용 CrewAI Agent입니다. `role`, `goal`, `backstory`를 편집해 특화할 수 있습니다. 포함된 지원 도구는 관련이 있을 때만 사용하는 예시이므로 다른 용도에서는 교체하거나 제거하세요. 기본으로 설치된 스킬은 없습니다.

`agent.json`을 편집합니다:

```json theme={null}
{
  "conversational": true,
  "role": "General-purpose AI agent",
  "goal": "Help users accomplish tasks accurately using the available tools and skills.",
  "backstory": "# Identity\nYou are a general-purpose AI agent powered by CrewAI.\n\n# Customization\nYour behavior and capabilities are defined by this project's agent definition, tools, and skills. Customize these files for the user's needs. The included support tools are examples; use them only when relevant. Be clear about the capabilities available in this project and do not claim external actions without a tool result.",
  "llm": {
    "model": "openai/gpt-6-luna",
    "api": "responses"
  },
  "tools": [
    "custom:support_hours",
    "custom:lookup_plan",
    "custom:support_checklist"
  ],
  "skills": [
    "./skills"
  ],
  "max_iter": 8
}
```

이 항목들은 Agent 생성자 필드입니다. 요청은 실행 시 `messages`로 전달하세요. 정의에 고정된 `input` 필드를 추가하지 마세요.

### YAML 또는 Python 선택하기

```shell Terminal theme={null}
crewai create agent yaml_support --format yaml
crewai create agent python_support --format python
```

YAML 프로젝트 템플릿은 동일한 필드를 가진 `agent.yaml`을 생성합니다:

```yaml theme={null}
conversational: true
role: General-purpose AI agent
goal: Help users accomplish tasks accurately using the available tools and skills.
backstory: |-
  # Identity
  You are a general-purpose AI agent powered by CrewAI.

  # Customization
  Your behavior and capabilities are defined by this project's agent definition, tools, and skills. Customize these files for the user's needs. The included support tools are examples; use them only when relevant. Be clear about the capabilities available in this project and do not claim external actions without a tool result.
llm:
  model: openai/gpt-6-luna
  api: responses
tools:
  - custom:support_hours
  - custom:lookup_plan
  - custom:support_checklist
skills:
  - ./skills
max_iter: 8
```

Python 프로젝트 템플릿은 `src/python_support/agent.py`에서 `agent = Agent(...)`를 내보냅니다. Agent를 정의하는 데 Python 로직이 필요한 경우 사용하세요.

`.yml`과 `.yaml`을 모두 지원합니다. 설정 파일의 이름이나 위치를 변경할 때는 `definition`과 wheel의 `only-include` 목록을 함께 수정하세요. 정의 경로는 프로젝트 루트 안에 있어야 합니다.

`definition`을 명시하지 않으면 루트의 `agent.py`, `agent.json`, `agent.yml`, `agent.yaml` 또는 일반적인 `src/<package>/agent.py` 중 하나를 검색합니다. 여러 파일이 발견되면 오류가 발생하므로 `definition`을 설정해 하나를 선택하세요.

## CLI로 도구 추가하기

터미널에서 JSON 또는 YAML 프로젝트에 대해 `crewai create agent`를 실행하면 CrewAI Platform 애플리케이션을 포함하여 `crewai create crew`와 동일한 도구 선택기가 열립니다. 나중에 도구를 더 추가하려면 프로젝트에서 `crewai tool add`를 실행하고, 선택기에서 고르거나 이름으로 지정하세요:

```shell Terminal theme={null}
crewai tool add
crewai tool add SerperDevTool platform:gmail/send-email
```

이 명령은 정의의 `tools` 목록에 도구를 추가하고, 도구에 필요한 경우 `crewai` 의존성을 `crewai[tools]`로 변경합니다. 그런 다음 `crewai install`을 실행하세요. CrewAI Platform 애플리케이션은 추가되기 전에 AMP에서 검증되며, Enterprise Action Auth Token은 `.env`에 저장됩니다. 프로젝트를 클론한 후처럼 정의에 이미 있는 플랫폼 애플리케이션을 검증하려면 `crewai tool setup`을 실행하세요. Python Agent는 대신 `agent.py`에서 편집합니다.

## 사용자 지정 도구 추가하기

포함된 `tools/support_hours.py`를 새 도구의 출발점으로 사용하세요:

```python theme={null}
from crewai.tools import BaseTool


class SupportHoursTool(BaseTool):
    name: str = "support_hours"
    description: str = "Return the fictional service's published support hours."

    def _run(self) -> str:
        return "Support is available Monday to Friday, 09:00-17:00 UTC."
```

생성된 정의는 도구와 스킬 디렉터리를 명시적으로 등록합니다. YAML도 동일한 문자열 목록을 사용합니다:

```json theme={null}
{
  "tools": [
    "custom:support_hours",
    "custom:lookup_plan",
    "custom:support_checklist"
  ],
  "skills": [
    "./skills"
  ]
}
```

`custom:support_hours`는 `tools/support_hours.py`에서 `BaseTool` 하위 클래스를 로드합니다. 도구에 필요한 의존성을 `pyproject.toml`에 추가하고 `crewai install`로 잠금 파일을 갱신하세요. 신뢰할 수 있는 프로젝트 코드만 로드하세요. 사용자 지정 도구와 Python 참조는 로딩 중 Python 코드를 실행합니다.

## 참조 도구와 스킬

생성된 예제는 로컬의 가상 데이터를 사용합니다. 실제 계정을 조회하거나 비밀번호를 재설정하거나 환불하거나 티켓을 만들지 않습니다.

| 도구 | 입력 | 결과 |
| - | - | - |
| `support_hours` | 없음 | UTC 기준으로 공지된 지원 시간 |
| `lookup_plan` | `plan`: `starter` 또는 `pro` | 좌석 수와 지원 채널 |
| `support_checklist` | `topic`: `sign-in` 또는 `billing` | 문제 해결 단계 |

`skills/` 디렉터리는 Git과 빌드된 패키지에서 유지하기 위한 `.gitkeep`만 포함하며 비어 있습니다. 스킬을 만들려면 `name`과 `description` 프런트매터를 포함한 `skills/<name>/SKILL.md`를 추가하세요. 추가된 스킬은 메타데이터로 검색되며 Agent는 `load_skill`로 관련 지침을 필요할 때 로드할 수 있습니다.

YAML/JSON의 로컬 스킬 경로는 프로젝트 루트를 기준으로 해석됩니다. 다른 디렉터리에서 `load_agent_project(path)`를 호출해도 동일합니다. Python 스캐폴드는 `tools/`와 `skills/`를 모두 `src/<package>/` 안에 두고 `agent.py`를 기준으로 스킬 경로를 지정합니다. wheel과 배포 아카이브에 이 파일들이 포함됩니다.

예제 기능을 함께 사용하는 요청을 실행해 보세요:

```shell Terminal theme={null}
crewai run --inputs '{"messages":"I use the Pro plan and cannot sign in. Use the available tools to explain what I should try and when support is available. Write a short customer reply."}'
```

## 메시지 기록 전달하기

`messages`는 role/content 메시지로 구성된 비어 있지 않은 목록도 받습니다:

```shell Terminal theme={null}
crewai run --inputs '{"messages":[{"role":"user","content":"Use support_hours to verify the published support hours."}]}'
```

각 kickoff는 새로운 Agent와 일반적인 로컬 사용자 지정 도구 인스턴스를 생성합니다. 이 프로젝트는 kickoff 간에 대화 기록을 자동으로 유지하지 않습니다. 기존의 임의 Python 참조는 모듈 수준의 싱글턴 객체로 해석될 수 있으며, 로더는 해당 객체의 변경 가능한 상태를 격리하지 않습니다.

프로그램에서 사용할 경우, 실험적 SDK 로더도 동일한 프로젝트 선택 규칙을 따릅니다:

```python theme={null}
from crewai.project import load_agent_project

agent = load_agent_project("./support_agent")
result = agent.kickoff("What are the support hours?")
print(result.raw)
```

## 미리 보기 검증 및 배포하기

```shell Terminal theme={null}
crewai deploy validate
```

YAML/JSON 검증은 프로젝트 Python 코드를 실행하거나 Agent, 도구 또는 공급자 클라이언트를 생성하지 않고 필드, Python 참조 구문 및 도구 선언을 확인합니다. Python 진입점은 가져오며 프로젝트 코드를 실행할 수 있습니다. 검증은 kickoff를 실행하지 않습니다. 일반 아카이브 파이프라인은 `.env`와 `.venv`를 제외하고 정의, 도구, 스킬 및 잠금 파일을 포함합니다.

호환되는 미리 보기 Enterprise 런타임에 배포하려면 [CLI 참조](https://docs.crewai.com/edge/ko/concepts/cli.md)에 설명된 기존 배포 절차를 사용하세요. 관리형 API는 동일한 입력을 받습니다:

```json theme={null}
{"inputs": {"messages": "What are the support hours?"}}
```

## 대화형 관리형 배포

호환되는 실험적 Enterprise 런타임에서 내부 Agent 어댑터는 `conversational = True`를 설정합니다. 채팅은 매 턴마다 설정된 Agent와 도구를 사용합니다. 세션을 시작한 뒤 후속 메시지에 같은 `session_id`를 사용하세요:

```http theme={null}
POST /chat/start
Authorization: Bearer <deployment-token>
Content-Type: application/json

{}
```

```http theme={null}
POST /chat/<session_id>/message
Authorization: Bearer <deployment-token>
Content-Type: application/json

{"message": "Remember that my project is Cedar Finch.", "stream": false}
```

```http theme={null}
GET /chat/<session_id>/history
Authorization: Bearer <deployment-token>
```

각 메시지는 서로 다른 `kickoff_id`를 반환합니다. 다음 메시지를 보내기 전에 `/status/<kickoff_id>`를 조회하여 턴이 완료될 때까지 기다리세요. 세션은 사용자/어시스턴트 기록을 보존하고 매 턴 새 Agent에 전달합니다. 대화 기록에는 사용자에게 보여 줄 답변만 포함되며, 실행 결과에는 구조화된 Agent 출력과 사용량이 유지됩니다. 세션 수명과 영속성은 배포된 런타임의 저장소 설정에 따라 달라집니다. 세션별 기록은 분리됩니다.

`POST /kickoff`는 독립적인 실행에 계속 사용할 수 있습니다. 로컬 `crewai run`은 채팅을 열고 `crewai run --inputs`는 kickoff를 한 번 실행합니다. 스캐폴드는 Agent 정의에서 대화 플래그를 활성화하므로 Flow나 `main.py`를 작성할 필요가 없습니다.

이 미리 보기는 네이티브 API와 Celery 워커로 검증되었습니다. 토큰 스트리밍, 복원/체크포인트 지원, Agent 전용 프로비저닝, 프로덕션 컨테이너 및 릴리스 호환성은 검증된 범위에 포함되지 않습니다.

## 에이전트 상태

실험적 기능입니다. 대화형 Agent는 타입이 지정된 상태를 가질 수 있습니다. `state=`에 Pydantic 모델을 지정하세요. 상태는 턴 사이에 저장됩니다. 에이전트는 매 턴 사용자의 최신 메시지 바로 앞에 놓이는 구분된 `<application_data>` 메시지에서 경로마다 한 줄씩 데이터로 상태를 받습니다. 이 메시지는 매 턴 새로 만들어지며 대화에 저장되지 않습니다. 에이전트는 상태를 바꾸는 도구 두 개도 받습니다.

* `update_state`는 필드 전체를 교체합니다. 에이전트가 바꿀 수 있는 필드마다 선택적 인수가 하나씩 있습니다.
* `patch_state`는 에이전트에게 보여 준 경로(예: `/todos/0/done`, 끝에 추가하려면 `/todos/-`)에서 항목 하나를 추가, 교체 또는 제거합니다. 값은 JSON 텍스트입니다. 한 번의 호출에 담긴 모든 경로는 에이전트가 상태를 보았을 때의 의미 그대로입니다. 교체가 먼저 적용되고, 그다음 추가와 제거가 끝에서부터 거꾸로 적용됩니다.

모든 변경은 저장되기 전에 개발자의 모델로 검증됩니다. 거부된 변경은 에이전트에게 그 이유를 알려 줍니다.

에이전트가 바꿀 수 있는 필드는 신뢰할 수 없는 입력입니다. 사용자는 에이전트를 설득해 그 필드에 무엇이든 쓰게 할 수 있습니다. 도구에서는 그 값을 믿지 말고 확인하세요. 사용자가 누구인지처럼 도구가 의존하는 값은 서버가 설정하는 숨김 필드나 읽기 전용 필드에 두세요.

```python theme={null}
from pydantic import BaseModel

from crewai import Agent


class Todo(BaseModel):
    text: str
    done: bool = False


class DeskState(BaseModel):
    user_id: str | None = None
    groups: list[str] = []
    plan_tier: str = "free"
    todos: list[Todo] = []


agent = Agent(
    role="Desk assistant",
    goal="Keep track of what the user needs to do",
    backstory="You are concise and accurate.",
    conversational=True,
    state=DeskState,
    external_editable_state=["user_id", "groups", "plan_tier"],
    agent_hidden_state=["user_id", "groups"],
    agent_readonly_state=["plan_tier"],
)
agent.handle_turn(
    "Add 'call Acme' to my todos.",
    state={"user_id": "u-123", "groups": ["sales"], "plan_tier": "pro"},
)
print(agent.as_flow().state.todos)
```

| 설정 | 하는 일 |
| - | - |
| `agent_hidden_state` | 에이전트는 이 필드를 보거나 바꿀 수 없습니다. 이 필드를 겨냥한 patch는 존재하지 않는 경로와 같은 답을 받고, 도구 결과에서도 빠집니다. |
| `agent_readonly_state` | 에이전트는 이 필드를 읽기 전용 표시와 함께 보지만 바꿀 수는 없습니다. |
| `external_editable_state` | 채팅 턴을 호출하는 쪽이 `handle_turn(..., state=...)`로 이 필드를 설정할 수 있습니다. [대화형 Flow](https://docs.crewai.com/edge/ko/guides/flows/conversational-flows.md)와 같습니다. 호출하는 쪽의 값은 매 턴이 시작될 때 적용됩니다. |

각 목록은 상태의 필드 이름이어야 하며, 상태는 대화 자체의 필드(`messages`, `id` 및 나머지 `ConversationState` 필드)를 선언할 수 없습니다. 위반하면 Agent를 선언할 때 `ValueError`가 발생합니다. 상태는 `@persist`와 마찬가지로 Flow 영속성으로 저장되며, 기본값은 SQLite 파일입니다. 저장은 세션 ID를 키로 하며 대화 메시지도 함께 저장하므로, 상태가 있는 두 Agent가 같은 저장소에서 같은 세션 ID를 쓰면 하나의 대화를 공유합니다. 대화마다 고유한 세션 ID를 사용하세요. `state`가 없는 Agent는 프로세스 사이에 아무것도 저장하지 않고, 상태 도구, 추가 지시사항, 데이터 메시지도 받지 않습니다. 단발성 `kickoff()`와 Crew 안의 Agent는 상태를 사용하지 않습니다.

### 도구에서 상태 읽기

도구는 `current_state()`를 호출해 자신이 실행 중인 대화의 상태 사본을 얻습니다. 사본은 호출 시점에 읽히므로 같은 턴에서 에이전트가 앞서 한 변경과 숨겨진 필드가 포함됩니다. 사본을 바꿔도 아무것도 바뀌지 않습니다. 턴 밖에서 호출하면 `RuntimeError`가 발생합니다.

```python theme={null}
from crewai.tools import BaseTool, current_state

ACCOUNTS = {"sales": ["Acme Corp", "Globex"], "finance": ["Initech payroll"]}


class ListMyAccounts(BaseTool):
    name: str = "list_my_accounts"
    description: str = "List the accounts the current user may see."

    def _run(self) -> str:
        state = current_state()
        return ", ".join(a for group in state.groups for a in ACCOUNTS.get(group, []))
```

### JSON 및 YAML 에이전트

`state`를 JSON Schema로 지정하세요. 세 목록은 같은 필드 이름을 사용합니다.

```json agent.json theme={null}
{
  "role": "Desk assistant",
  "goal": "Keep track of what the user needs to do",
  "backstory": "You are concise and accurate.",
  "conversational": true,
  "state": {
    "type": "object",
    "properties": {
      "user_id": {"type": "string", "default": ""},
      "todos": {"type": "array", "items": {"type": "string"}, "default": []}
    }
  },
  "external_editable_state": ["user_id"],
  "agent_hidden_state": ["user_id"]
}
```

> [!WARNING]
>
> * 상태는 턴 사이에 저장되고 트레이스에 나타나므로 비밀 정보를 두는 곳이 아닙니다. 숨김은 비밀을 뜻하지 않습니다. 필드는 에이전트에게만 숨겨지며 호출하는 쪽은 여전히 그 필드를 받습니다.
> * `external_editable_state`에 있는 필드는 토큰을 가진 누구나 쓸 수 있습니다.
> * AG-UI에서는 상태가 브라우저에서 옵니다. 고객의 서버는 전달하는 모든 요청에서 `user_id` 같은 신원 필드를 직접 설정해야 합니다. 그러지 않으면 최종 사용자의 브라우저가 다른 사람의 신원을 보낼 수 있습니다. 브라우저가 AMP 사용자 토큰으로 AMP를 직접 호출하면 상태를 설정하는 서버가 없으므로, 그런 방식으로 신원을 전달하지 마세요.
> * 숨김에는 부작용이 있습니다. 에이전트는 사용자가 자신에 대해 한 잘못된 주장을 바로잡을 수 없습니다. 영업 사용자가 "내 재무 계정"을 요청하자, 에이전트는 사용자의 실제 계정을 나열하면서 그것을 재무 계정이라고 불렀습니다.


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