Files
crewAI/lib/cli
João MouraandClaude Opus 5.5 0b84f8e18b fix(core): send AMP requests through the proxy the environment names (#8186)
* fix(core): send AMP requests through the proxy the environment names

PlusAPI built its httpx clients with trust_env=False, so HTTP(S)_PROXY,
NO_PROXY and SSL_CERT_FILE were ignored and every AMP call tried a direct
connection. On a corporate network or inside a coding-agent sandbox
(Claude Code, Codex), which only allow traffic through that proxy, deploy,
eval, org, triggers, trace upload, skills and repository agents all failed
with "[Errno 8] nodename nor servname provided", while `crewai login`
(module-level httpx.post) worked.

trust_env=False dates from #1455, when the client used requests, where it
also stopped ~/.netrc credentials from replacing the AMP bearer token.
httpx 0.28 no longer reads .netrc, so the flag now only disables proxy and
CA-bundle variables. Remove it from the three clients (core request and
multipart, and the CLI's multipart override).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(core): keep the direct-request proxy test off the OS proxy settings

With no proxy variables set, httpx falls back to urllib's getproxies(),
which reads the macOS or Windows system proxy settings. On a machine
with a system proxy configured, the "no proxy variables" test would have
routed through it. Model a machine with none configured.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(cli): keep a project's .env from choosing how crewai eval sends the login

crewai eval already refuses to send the saved login to an AMP host that only
the project's .env names. With AMP requests now honoring proxy and CA
variables, the same .env could still pick the route: its own proxy and its own
CA bundle, past that check. eval and eval --models now leave *_proxy,
SSL_CERT_FILE and SSL_CERT_DIR out when they load the project's .env, say so,
and keep the machine's own settings (shell exports, OS proxy).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(core): take AMP's proxy and CA from the machine, not a project's .env

AMP requests carry the saved login. Honoring HTTP(S)_PROXY and SSL_CERT_FILE
from the live environment let a cloned project's .env choose both: `crewai run`
on a JSON crew or a declarative flow loads it with override=True, and
`crewai.llm` loads it again on import, which also undid the filter `crewai eval`
applied to its own loader.

PlusAPI now pins the proxy and CA variables when crewai_core.plus_api is first
imported, which the CLI does at startup, and hands them to httpx explicitly with
trust_env=False. With none set, the OS proxy settings apply, read live. The eval
loader goes back to main's, since the client now covers every command.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(cli): pin AMP's proxy and CA in the JSON-crew runner too

`crewai run` runs a JSON crew in a fresh `uv run python -c` interpreter that
never imports cli.py, and `_run_json_crew` loads the project's .env with
override=True before tracing first imports crewai_core.plus_api, so the pin
recorded the project's proxy and CA. The runner now imports plus_api before
anything else. Declarative flows re-run through `uv run crewai run`, which
already pins in cli.py.

Also keeps `_requests_sent_by` off machine and OS proxies, so a developer's
proxy can't mount a real transport ahead of its MockTransport.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(core): keep urllib's CGI proxy rule, and surface a broken plus_api import

The pinned proxy map dropped urllib's REQUEST_METHOD rule: in a CGI process
an uppercase HTTP_PROXY can come from a client's Proxy header, and AMP's
login and deployment ZIPs would follow it. REQUEST_METHOD is now pinned with
the other transport variables, and the map is read exactly as urllib reads it.

The JSON-crew runner skipped any ImportError from crewai_core.plus_api. It now
skips only a crewai-core too old to have the module; any other failure stops
the run with its own error instead of running with nothing pinned.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(cli): import the proxy pin with the project folder off sys.path

`python -c` puts the working directory, the project, first on sys.path, so a
project folder named crewai_core could supply the module that pins where the
saved login travels. The JSON-crew runner now imports the pin with the project
off the path and restores the path right after, so project code (custom tools
importing their neighbours) still finds its own modules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(core): pin AMP's proxy and CA first thing in `import crewai`

A crew run in its own process (`uv run run_crew`) never imports the CLI, so
`import crewai` is where the pin happens there. It already preceded the
project's .env, loaded by crewai.llm on import, but only by import order. The
pin is now the first import in crewai/__init__.py, and a test runs a fresh
interpreter in a project whose .env names a proxy and CA: the .env loads, and
the pin still holds only what the machine set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(cli): keep the machine's proxy and CA for the crew `crewai eval` runs

`crewai eval` loads the project's .env into its own process and then runs
the crew in a child that inherits that environment. The child pins what it
inherits, so a .env naming HTTPS_PROXY and SSL_CERT_FILE became the run's
machine transport, and that run's traces carry the saved login.

The proxy and CA variables go back to the machine's pin right after the
.env loads; the rest of the .env still applies, and the run loads the .env
itself after its own pin, as under `crewai run`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(core): keep a project's UV_ENV_FILE out of the crew `crewai eval` runs

`crewai eval` loads the project's .env and starts the crew with `uv run`.
A .env naming itself as UV_ENV_FILE had uv load it into the run before
Python started, so the run pinned the project's proxy and CA anyway.
UV_ENV_FILE now counts among the variables restored to the machine's.

The pin test starts the run through `uv run`, as the CLI does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 12:28:26 -03:00
..

crewai-cli

CLI for CrewAI — scaffold, run, deploy and manage AI agent crews without installing the full framework.

Installation

pip install crewai-cli

This pulls in crewai-core (shared utilities) but not the crewai framework itself, so commands that don't need a crew loaded — crewai version, crewai login, crewai org list, crewai config *, crewai traces *, crewai create, crewai template * — work standalone.

Commands that load a user's crew or flow (crewai run, crewai train, crewai test, crewai chat, crewai replay, crewai reset-memories, crewai deploy push, crewai tool publish) require crewai to be installed in the project's environment. They print a clear error if it is missing.

To install both at once:

pip install crewai[cli]