mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-07-04 22:49:23 +00:00
* feat: adopt directory-based docs versioning with Edge channel Switch docs.crewai.com from navigation-only versioning (every version selector entry rendered the same docs/<lang>/* source files) to Mintlify's directory-based versioning so each version selector entry renders its own snapshot. Add an "Edge" channel under docs/edge/<lang>/* that always reflects main HEAD for unreleased work, eliminating pre-release leakage onto frozen release labels. External links to canonical /<lang>/* URLs are preserved via wildcard redirects that always land on the current default version. Layout: - docs/edge/<lang>/* rolling source (you edit here) - docs/edge/enterprise-api.*.yaml - docs/v<X.Y.Z>/<lang>/* frozen, immutable snapshots - docs/v<X.Y.Z>/enterprise-api.*.yaml - docs/images/ shared, append-only - docs/docs.json nav + redirects URLs follow the Mintlify-idiomatic shape: /edge/<lang>/<page> for Edge, /v<X.Y.Z>/<lang>/<page> for every frozen snapshot. The wildcard redirects /<lang>/:slug* -> /<default>/<lang>/:slug* keep stale links working, and every freeze rewrites them (plus all per-section/per-page redirects) so destinations always resolve to the current default without depending on a second redirect hop. Release flow integration (devtools release): - New module crewai_devtools.docs_versioning.freeze() materialises docs/v<X.Y.Z>/ from docs/edge/, rewrites openapi: refs inside the snapshot, inserts the version into every language block in docs.json, and refreshes all redirect destinations. - _update_docs_and_create_pr() in cli.py now calls that freeze during Phase 2 of devtools release. Edge changelogs are updated first (so the snapshot freeze picks them up), then the snapshot is staged alongside docs.json, branched as docs/freeze-v<X.Y.Z>, and the PR is titled [docs-freeze] docs: snapshot and changelog for v<X.Y.Z> — the title prefix the new CI guard reads. - The PR still gates tag, GitHub release, PyPI publish, and the enterprise release as before; no new PRs are added. - Pre-releases (1.X.YaN, 1.X.YbN, ...) skip the snapshot — they ride Edge — and the docs PR title omits the [docs-freeze] prefix. - docs_check (AI-generated docs scaffolding) writes to docs/edge/<lang>/* so newly-generated unreleased docs land in Edge and never accidentally touch a frozen snapshot. Migration scripts (one-shot): - scripts/docs/freeze_historical_versions.py reconstructs all 16 historical snapshots (v1.10.0 .. v1.14.7) from git tags via git archive | tar, rewriting openapi: MDX refs so each snapshot reads its own enterprise-api YAML rather than the live one. - scripts/docs/prefix_version_paths.py one-shot-migrates docs.json: rewrites every page path in 16 versioned blocks to point under docs/v<X.Y.Z>/, inserts a new Edge entry per language, tags v1.14.7 as Latest (default), prunes pages whose target file doesn't exist in the snapshot (e.g. docs/ar/ didn't exist before v1.12.0), and writes the wildcard + per-section redirects. - scripts/docs/freeze_current_edge.py is now a thin CLI wrapper around docs_versioning.freeze for manual one-off freezes (e.g. retroactively snapshotting a forgotten release). CI guards (.github/workflows/docs-snapshots.yml): - Frozen snapshots under docs/v[0-9]*/ are immutable; only PRs whose title contains [docs-freeze] (i.e. release-cut PRs generated by devtools release or the manual wrapper) may modify them. - Images under docs/images/ are append-only since snapshots share a single image directory. Deleting or renaming an image breaks every historical snapshot that still references it. Restored docs/images/crewai-otel-export.png from PR #3673; it was deleted in PR #4908 but v1.10.0 / v1.10.1 snapshots still reference it. Restoring instead of editing the snapshots preserves historical rendering fidelity and validates the new append-only rule retroactively. Tests: - lib/devtools/tests/test_docs_versioning.py covers the freeze: file copy, openapi rewrite, version insertion, default demotion, redirect upserts, per-section redirect rewriting, idempotency, and invalid inputs. Verified locally with mintlify broken-links: 0 broken links across the full site (Edge + 16 frozen versions, 4 locales). AGENTS.md (repo root) is the contributor guide for the new model; RELEASING.md is the release-cut runbook; README's Contribution section links to both. Co-authored-by: Cursor <cursoragent@cursor.com> * style: resolve linter issues --------- Co-authored-by: Cursor <cursoragent@cursor.com>
191 lines
6.9 KiB
Plaintext
191 lines
6.9 KiB
Plaintext
---
|
|
title: "Atualizando o CrewAI"
|
|
description: "Como atualizar o CrewAI no seu projeto e adaptar-se a breaking changes entre versões."
|
|
icon: "arrow-up-circle"
|
|
---
|
|
|
|
## Visão Geral
|
|
|
|
Os lançamentos do CrewAI trazem novos recursos regularmente. Este guia mostra os passos práticos para manter sua instalação atualizada — tanto a CLI quanto o ambiente virtual do seu projeto.
|
|
|
|
Se você está começando do zero, veja [Instalação](/pt-BR/installation). Se está vindo de outro framework, veja [Migrando do LangGraph](/pt-BR/guides/migration/migrating-from-langgraph).
|
|
|
|
---
|
|
|
|
## As Duas Coisas Que Você Pode Querer Atualizar
|
|
|
|
O CrewAI vive em dois lugares na sua máquina, e cada um se atualiza de forma independente:
|
|
|
|
| O quê | Como é instalado | Como atualizar |
|
|
|---|---|---|
|
|
| A **CLI global `crewai`** | `uv tool install crewai` | `uv tool install crewai --upgrade` |
|
|
| O **venv do projeto** (onde seu código roda) | `crewai install` / `uv sync` | `uv add "crewai[...]>=X.Y.Z"` e depois `crewai install` |
|
|
|
|
Esses dois podem — e frequentemente ficam — fora de sincronia. Rodar `crewai --version` mostra a versão da CLI. Rodar `uv pip show crewai` dentro do seu projeto mostra a versão do venv. Se forem diferentes, isso é normal; o que importa para o código em execução é a versão do venv.
|
|
|
|
## Por Que `crewai install` Sozinho Não Atualiza
|
|
|
|
`crewai install` é um wrapper fino em torno de `uv sync`. Ele instala exatamente o que o arquivo `uv.lock` atual diz — ele **não** muda nenhuma restrição de versão.
|
|
|
|
Se seu `pyproject.toml` diz `crewai>=1.11.1` e o lock file resolveu para `1.11.1`, executar `crewai install` vai te manter em `1.11.1` para sempre, mesmo que `1.14.4` esteja disponível.
|
|
|
|
Para realmente atualizar, você precisa:
|
|
|
|
1. Atualizar a restrição de versão em `pyproject.toml`
|
|
2. Re-resolver o lock file
|
|
3. Sincronizar o venv
|
|
|
|
`uv add` faz os três de uma vez só.
|
|
|
|
## Como Atualizar Seu Projeto
|
|
|
|
```bash
|
|
# Aumenta a restrição e re-resolve o lock em um único comando
|
|
uv add "crewai[tools]>=1.14.4"
|
|
|
|
# Sincroniza o venv (crewai install chama uv sync por baixo dos panos)
|
|
crewai install
|
|
|
|
# Verifica
|
|
uv pip show crewai
|
|
# → Version: 1.14.4
|
|
```
|
|
|
|
Substitua `[tools]` por quaisquer extras que seu projeto utilize (ex.: `[tools,anthropic]`). Verifique a lista de `dependencies` do seu `pyproject.toml` se estiver em dúvida.
|
|
|
|
<Note>
|
|
`uv add` atualiza tanto `pyproject.toml` **quanto** `uv.lock` atomicamente. Se você editar `pyproject.toml` manualmente, ainda precisa rodar `uv lock --upgrade-package crewai` para re-resolver o lock file antes que `crewai install` pegue a nova versão.
|
|
</Note>
|
|
|
|
## Atualizando a CLI Global
|
|
|
|
A CLI global é separada do seu projeto. Atualize com:
|
|
|
|
```bash
|
|
uv tool install crewai --upgrade
|
|
```
|
|
|
|
Se seu shell avisar sobre o `PATH` após a atualização, recarregue-o:
|
|
|
|
```bash
|
|
uv tool update-shell
|
|
```
|
|
|
|
Isso **não** mexe no venv do seu projeto — você ainda precisa de `uv add` + `crewai install` dentro do projeto.
|
|
|
|
## Verifique Se Ambos Estão em Sincronia
|
|
|
|
```bash
|
|
# Versão da CLI global
|
|
crewai --version
|
|
|
|
# Versão do venv do projeto
|
|
uv pip show crewai | grep Version
|
|
```
|
|
|
|
Eles não precisam coincidir — mas a versão do venv do projeto é o que importa para o comportamento em runtime.
|
|
|
|
<Note>
|
|
CrewAI requer `Python >=3.10, <3.14`. Se o `uv` foi instalado contra um interpretador mais antigo, recrie o venv do projeto com uma versão suportada do Python antes de rodar `crewai install`.
|
|
</Note>
|
|
|
|
---
|
|
|
|
## Breaking Changes e Notas de Migração
|
|
|
|
A maioria das atualizações requer apenas pequenos ajustes. As áreas abaixo são as que quebram silenciosamente ou com tracebacks confusos.
|
|
|
|
### Caminhos de import: tools e `BaseTool`
|
|
|
|
O caminho canônico para tools é `crewai.tools`. Caminhos antigos ainda aparecem em tutoriais, mas devem ser atualizados.
|
|
|
|
```python
|
|
# Antes
|
|
from crewai_tools import BaseTool
|
|
from crewai.agents.tools import tool
|
|
|
|
# Depois
|
|
from crewai.tools import BaseTool, tool
|
|
```
|
|
|
|
O decorador `@tool` e a subclasse `BaseTool` ambos vivem em `crewai.tools`. `AgentFinish` e outros símbolos internos do agente não fazem mais parte da superfície pública — se você os estava importando, mude para event listeners ou callbacks de `Task`.
|
|
|
|
### Mudanças de parâmetros em `Agent`
|
|
|
|
```python
|
|
from crewai import Agent
|
|
|
|
agent = Agent(
|
|
role="Researcher",
|
|
goal="Find authoritative sources on {topic}",
|
|
backstory="You are a careful, source-driven researcher.",
|
|
llm="gpt-4o-mini", # nome do modelo como string OU um objeto LLM
|
|
verbose=True, # bool, não um nível inteiro
|
|
max_iter=15, # default mudou entre versões — defina explicitamente
|
|
allow_delegation=False,
|
|
)
|
|
```
|
|
|
|
- `llm` aceita tanto um nome de modelo como string (resolvido pelo provedor configurado) quanto um objeto `LLM` para controle granular.
|
|
- `verbose` é um `bool` puro. Passar um inteiro não alterna mais níveis de log.
|
|
- Os defaults de `max_iter` mudaram entre releases. Se seu agente para silenciosamente de iterar após a primeira chamada de tool, defina `max_iter` explicitamente.
|
|
|
|
### Parâmetros de `Crew`
|
|
|
|
```python
|
|
from crewai import Crew, Process
|
|
|
|
crew = Crew(
|
|
agents=[...],
|
|
tasks=[...],
|
|
process=Process.sequential, # ou Process.hierarchical
|
|
memory=True,
|
|
cache=True,
|
|
embedder={"provider": "openai", "config": {"model": "text-embedding-3-small"}},
|
|
)
|
|
```
|
|
|
|
- `process=Process.hierarchical` requer ou `manager_llm=` ou `manager_agent=`. Sem um deles, o kickoff lança erro na validação.
|
|
- `memory=True` com um provedor de embedding não-default precisa de um dicionário `embedder` — veja [Configuração de memória e embedder](#memory-embedder-config) abaixo.
|
|
|
|
### Saída estruturada de `Task`
|
|
|
|
Use `output_pydantic`, `output_json` ou `output_file` para forçar o resultado de uma task em um formato tipado:
|
|
|
|
```python
|
|
from pydantic import BaseModel
|
|
from crewai import Task
|
|
|
|
class Article(BaseModel):
|
|
title: str
|
|
body: str
|
|
|
|
write = Task(
|
|
description="Write an article about {topic}",
|
|
expected_output="A short article with a title and body",
|
|
agent=writer,
|
|
output_pydantic=Article, # a classe, NÃO uma instância
|
|
output_file="output/article.md",
|
|
)
|
|
```
|
|
|
|
`output_pydantic` recebe a **classe** em si. Passar `Article(title="", body="")` é um erro comum e falha com um erro de validação confuso.
|
|
|
|
### Configuração de memória e embedder {#memory-embedder-config}
|
|
|
|
Se `memory=True` e você não está usando os embeddings padrão da OpenAI, é preciso passar um `embedder`:
|
|
|
|
```python
|
|
crew = Crew(
|
|
agents=[...],
|
|
tasks=[...],
|
|
memory=True,
|
|
embedder={
|
|
"provider": "ollama",
|
|
"config": {"model": "nomic-embed-text"},
|
|
},
|
|
)
|
|
```
|
|
|
|
Defina as credenciais do provedor relevante (`OPENAI_API_KEY`, `OLLAMA_HOST`, etc.) no seu arquivo `.env`. Os caminhos de armazenamento de memória são locais ao projeto por default — apague o diretório de memória do projeto se trocar de embedder, já que dimensões diferentes não se misturam.
|