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

# Standalone Agent Projects (Experimental)

> Create and run a standalone Agent project using JSON, YAML, or Python.

> [!WARNING]
>
> Standalone Agent projects are experimental. The project schema and loading API may change. This preview requires matching CLI and SDK builds that include this feature; managed deployments also require a compatible Enterprise runtime. The examples do not imply support in an older installed release.

A standalone Agent project defines one Agent and receives its messages at kickoff time. JSON is the default scaffold. YAML and Python are explicit alternatives. You do not need a `main.py`, a Crew, a Flow, or a factory function.

## Create a project

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

Set `OPENAI_API_KEY` in `.env` for the default `openai/gpt-6-luna` model, then install and run:

The scaffold selects the Responses API (`api: responses`) for tool calling with this model. In YAML/JSON projects, edit `llm.model` and `llm.api` in the definition; the Python template reads `MODEL` from `.env` and selects the Responses API.

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

`crewai install` creates `uv.lock`. Commit it with the project. Keep `.env` local and use the deployment's environment settings for provider credentials.

## Local conversations

The scaffold sets `conversational: true`, or `Agent(conversational=True)` in Python. In a terminal, `crewai run` opens the existing conversational chat interface. Each submitted message uses the configured Agent and tools with the session history. Set the flag to false to use independent kickoffs only.

```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)
```

The experimental SDK exposes the same session through `agent.handle_turn(...)` and `agent.as_flow()`. History stays in memory by default; configure Flow persistence explicitly for recovery across processes. Use a separate Agent instance for each independent conversation. The `session_id` option identifies/restores a Flow session; it does not turn one Agent into a concurrent multi-session server.

## Project structure

```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
```

The configuration project has no source package. The scaffold includes three local tools for a fictional support service and an empty skills directory; no extra services or credentials are needed beyond the model provider key.

The generated `pyproject.toml` selects the Agent definition and packages the configuration and any local tools:

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

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

## Define the Agent

The default identity is a general-purpose CrewAI Agent. Edit `role`, `goal`, and `backstory` to specialize it. The included support tools are examples used only when relevant; replace or remove them for other use cases. No skills are installed by default.

Edit `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
}
```

These are Agent constructor fields. Supply the request through `messages` at runtime; do not add a fixed `input` field to the definition.

### Choose YAML or Python

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

The YAML scaffold creates `agent.yaml` with the same fields:

```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
```

The Python scaffold exports `agent = Agent(...)` from `src/python_support/agent.py`. Use it when defining the Agent requires Python logic.

Both `.yml` and `.yaml` are supported. When renaming or moving a configuration, update `definition` and the wheel's `only-include` list together. Definition paths must stay inside the project root.

Without an explicit `definition`, discovery accepts a single root `agent.py`, `agent.json`, `agent.yml`, or `agent.yaml`, or the conventional `src/<package>/agent.py`. Multiple discovered files produce an error; set `definition` to choose one.

## Add tools from the CLI

In a terminal, `crewai create agent` for a JSON or YAML project opens the same tool picker as `crewai create crew`, including CrewAI Platform applications. Run `crewai tool add` in the project to add more tools later, either from the picker or by name:

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

The command appends to the definition's `tools` list and changes the `crewai` dependency to `crewai[tools]` when a tool needs it; run `crewai install` afterwards. CrewAI Platform applications are validated on AMP before they are added, and the Enterprise Action Auth Token is saved to `.env`. Run `crewai tool setup` to validate the platform applications already in the definition, for example after cloning the project. Python agents are edited in `agent.py` instead.

## Add a custom tool

Use the included `tools/support_hours.py` as a starting point for another tool:

```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."
```

The generated definition explicitly registers the tools and skill directory; YAML uses the same string lists:

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

`custom:support_hours` loads a `BaseTool` subclass from `tools/support_hours.py`. Add any tool dependencies to `pyproject.toml` and refresh the lockfile with `crewai install`. Only load trusted project code: custom tools and Python references execute Python during loading.

## Reference tools and skills

The generated examples use local, fictional data. They do not inspect accounts, reset passwords, issue refunds, or create tickets.

| Tool | Input | Result |
| - | - | - |
| `support_hours` | None | Published hours in UTC |
| `lookup_plan` | `plan`: `starter` or `pro` | Seat allowance and support channel |
| `support_checklist` | `topic`: `sign-in` or `billing` | Troubleshooting steps |

The `skills/` directory starts empty, with only `.gitkeep` to preserve it in Git and packaged builds. Add `skills/<name>/SKILL.md` with `name` and `description` frontmatter to create a skill. Added skills are discovered as metadata; the Agent can use `load_skill` to load relevant instructions on demand.

Local skill paths in YAML/JSON resolve against the project root, including when `load_agent_project(path)` is called from another directory. The Python scaffold keeps both `tools/` and `skills/` inside `src/<package>/` and anchors skills to `agent.py`. The wheel and deployment archive include these files.

Try a request that combines the example capabilities:

```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."}'
```

## Pass a message history

`messages` also accepts a non-empty list of role/content messages:

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

Each kickoff creates a fresh Agent and ordinary local custom-tool instances. These projects do not automatically retain conversation history between kickoffs. Existing arbitrary Python references can resolve module-level singleton objects; their mutable state is not isolated by the loader.

For programmatic use, the experimental SDK loader follows the same project selection rules:

```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)
```

## Validate and deploy the preview

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

YAML/JSON validation checks fields, Python-reference syntax, and tool declarations without executing project Python or constructing Agents, tools, or provider clients. Python entrypoints are imported and can execute project code. Validation does not run a kickoff. The normal archive pipeline includes the definition, tools, skills, and lockfile while excluding `.env` and `.venv`.

For a deployment with a compatible preview Enterprise runtime, use the existing deployment workflow described in the [CLI reference](https://docs.crewai.com/edge/en/concepts/cli.md). The managed API accepts the same input:

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

## Conversational managed deployments

With the compatible experimental Enterprise runtime, the internal Agent adapter sets `conversational = True`. Chat uses the configured Agent and its tools for every turn. Start a session, then reuse its `session_id` for subsequent messages:

```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>
```

Each message returns a distinct `kickoff_id`; poll `/status/<kickoff_id>` until the turn completes before sending another message. The session retains user/assistant history and passes it to a fresh Agent each turn. Its transcript contains the public answer, while execution results retain structured Agent output and usage. Session lifetime and persistence depend on the deployed runtime's storage configuration. Separate sessions have separate histories.

`POST /kickoff` remains available for independent executions. Local `crewai run` opens chat, while `crewai run --inputs` remains a single kickoff. The scaffold enables the conversational flag in the Agent definition; you do not need to write a Flow or `main.py`.

This preview has been exercised with a native API and Celery worker. Token streaming, restore/checkpoint support, first-class Agent provisioning, and production container/release compatibility remain outside its verified scope.

## Agent state

Experimental. A conversational Agent can keep a typed state: give `state=` a Pydantic model. The state is saved between turns. Each turn the agent gets it as data, one line per path, in a delimited `<application_data>` message placed just before the user's newest message; that message is rebuilt every turn and never saved to the conversation. The agent also gets two tools to change the state:

* `update_state` replaces whole fields. It has one optional argument per field the agent may change.
* `patch_state` adds, replaces or removes single items at a path the agent was shown, such as `/todos/0/done`, or `/todos/-` to append. Values are JSON text. Every path in one call means what it meant when the agent saw the state: replacements are applied first, then adds and removals from the end backwards.

Every change is validated with your model before it is saved. A refused change tells the agent why.

Fields the agent can change are untrusted input: a user can talk the agent into writing anything into them. Check them in your tools instead of trusting them, and keep values your tools rely on, such as who the user is, in hidden or read-only fields that your server sets.

```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)
```

| Setting | What it does |
| - | - |
| `agent_hidden_state` | The agent can't see or change these fields. A patch aimed at one gets the same answer as a path that doesn't exist, and tool results leave them out. |
| `agent_readonly_state` | The agent sees these fields, marked read-only, but can't change them. |
| `external_editable_state` | A caller of a chat turn may set these fields with `handle_turn(..., state=...)`, as on a [conversational Flow](https://docs.crewai.com/edge/en/guides/flows/conversational-flows.md#letting-callers-set-state). The caller's value is applied at the start of every turn. |

Each list must name fields of the state, and the state can't declare the conversation's own fields (`messages`, `id` and the rest of `ConversationState`); the Agent raises `ValueError` when it is declared. The state is saved with Flow persistence, as `@persist` does: by default a SQLite file. Saving is keyed by the session id and includes the conversation's messages, so two stateful Agents that use the same session id with the same store share one conversation: give each conversation its own session id. An Agent without `state` saves nothing between processes, gets no state tools, no extra instructions and no data message. One-shot `kickoff()` and Agents inside a Crew don't use the state.

### Read the state from your tools

A tool calls `current_state()` to get a copy of the state of the conversation it runs in. The copy is read when it is called, so it includes changes the agent made earlier in the turn, and it includes hidden fields. Changing the copy changes nothing. Outside a turn it raises `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 and YAML agents

Give `state` as a JSON Schema. The three lists take the same field names.

```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]
>
> * The state is saved between turns and appears in traces, so it isn't a place for secrets. Hidden doesn't mean secret: a field is hidden from the agent only, and callers still get it.
> * A field in `external_editable_state` is writable by whoever holds the token.
> * With AG-UI the state arrives from the browser. Your server must set identity fields such as `user_id` on every request it forwards, or an end user's browser could send someone else's identity. When a browser calls AMP directly with an AMP user token, no server sets the state, so don't pass identity that way.
> * Hiding has a side effect: the agent can't correct a user's false claim about themselves. Asked by a sales user for "my finance accounts", an agent listed the user's real accounts but called them finance accounts.


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