|
| 1 | +# First-party frameworks |
| 2 | + |
| 3 | +A framework is delivered as a **template you scaffold from**, not as an extension you install. The template carries its own `agents-cli-extension.yaml`, so the project gets the framework's command overrides with nothing installed machine-wide. |
| 4 | + |
| 5 | +| Framework | What it does | |
| 6 | +|--------|--------------| |
| 7 | +| [LangChain](#langchain) | Run a LangChain agent through the `agents-cli` lifecycle. | |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +## LangChain |
| 12 | + |
| 13 | +The LangChain template runs a [LangChain](https://python.langchain.com) agent through the `agents-cli` lifecycle. It overrides only the framework-coupled commands and leaves everything else — `deploy`, `infra`, `eval grade` — running natively. |
| 14 | + |
| 15 | +!!! warning "Experimental: deploy to Cloud Run or GKE" |
| 16 | + |
| 17 | + On Agent Runtime the container serves and traces normally, but the integrations that |
| 18 | + expect an ADK app do not work, because this project serves A2A and no `reasoning_engine` |
| 19 | + routes: `publish gemini-enterprise` is refused (registration invokes `:streamQuery`), the |
| 20 | + Console playground cannot invoke the agent, and the Console's session and trace views stay |
| 21 | + empty. Traces still reach Cloud Trace. |
| 22 | + |
| 23 | +### Create a project |
| 24 | + |
| 25 | +```bash |
| 26 | +agents-cli create my-agent \ |
| 27 | + --agent google/agents-cli/extensions/langchain/template@v1.5.0 \ |
| 28 | + -d cloud_run |
| 29 | +cd my-agent && agents-cli install |
| 30 | +``` |
| 31 | + |
| 32 | +The scaffolded project contains `agents-cli-extension.yaml` at its root. That file is auto-loaded at project scope, so the overrides below are active in this project and nowhere else. Commit it. |
| 33 | + |
| 34 | +### What it overrides |
| 35 | + |
| 36 | +| Command | Behavior in a LangChain project | |
| 37 | +|---------|---------------------------------| |
| 38 | +| `playground` | `uv run langgraph dev` — the local LangGraph dev server (also serves A2A). | |
| 39 | +| `publish gemini-enterprise` | Runs the built-in, except on Agent Runtime, where it refuses with the reason. | |
| 40 | +| `run` | Invokes the compiled graph in-process. | |
| 41 | +| `eval generate` | Produces the standard `EvaluationDataset` shape, so `eval grade` is unchanged. | |
| 42 | +| `eval dataset synthesize`, `eval optimize` | Refused with an explanation: both drive the agent through ADK. | |
| 43 | + |
| 44 | +Everything else stays native — **do not override** `deploy` (the target-appropriate native deploy, e.g. `gcloud run deploy --source .` on Cloud Run), `eval grade` / `compare` / `analyze` (framework-agnostic), `infra`, or `publish`. |
| 45 | + |
| 46 | +### The scaffolded agent |
| 47 | + |
| 48 | +The default `app/agent.py` is a Gemini ReAct agent built with `langchain.agents.create_agent` and a sample `get_weather` tool. It calls Gemini via Vertex AI using Application Default Credentials; set `GOOGLE_API_KEY` or `GEMINI_API_KEY` in `.env` to use AI Studio instead (the scaffolded `.env.example` names the latter). |
| 49 | + |
| 50 | +Because the project rides the framework-neutral `empty_py` substrate, the generated code contains **no ADK dependency**, and the template ships its own coding-agent skill. |
| 51 | + |
| 52 | +### Serving over A2A |
| 53 | + |
| 54 | +The deployed agent is served over the [Agent2Agent (A2A) protocol](https://a2a-protocol.org) — the same contract the rest of the toolchain expects — so it works unchanged: |
| 55 | + |
| 56 | +- **Entrypoint:** `uvicorn app.fast_api_app:app` (the scaffold Dockerfile `CMD`). |
| 57 | +- **Endpoints:** JSON-RPC at `POST /a2a/app`; Agent Card at `/a2a/app/.well-known/agent-card.json`. |
| 58 | +- **Streaming:** the executor streams LLM token chunks as incremental A2A task artifacts (`capabilities.streaming=True`), so a real chat model streams token-by-token. Graphs whose nodes don't stream tokens fall back to a single final artifact. |
| 59 | + |
| 60 | +Query a deployed (or locally served) agent over A2A. Because the project overrides `run` with in-process graph invocation, set `AGENTS_CLI_DISABLE_OVERRIDES=1` to reach the built-in A2A client: |
| 61 | + |
| 62 | +```bash |
| 63 | +AGENTS_CLI_DISABLE_OVERRIDES=1 agents-cli run --url https://<service-url> --mode a2a --app-name app "hello" |
| 64 | +``` |
| 65 | + |
| 66 | +### Full journey |
| 67 | + |
| 68 | +```bash |
| 69 | +agents-cli create my-agent --agent google/agents-cli/extensions/langchain/template@v1.5.0 -d cloud_run |
| 70 | +cd my-agent && agents-cli install |
| 71 | +agents-cli run "what's the weather in San Francisco?" # in-process graph |
| 72 | +agents-cli eval generate --dataset tests/eval/datasets/basic-dataset.json -o tests/eval/output/ |
| 73 | +agents-cli eval grade --traces tests/eval/output/<dataset>.json --config tests/eval/eval_config.yaml |
| 74 | +agents-cli deploy # native Cloud Run deploy |
| 75 | +``` |
| 76 | + |
| 77 | +### Notes |
| 78 | + |
| 79 | +- **Credentials:** `run` and `eval` call Gemini, so they need credentials — `GOOGLE_CLOUD_PROJECT` plus ADC, or `GOOGLE_API_KEY` / `GEMINI_API_KEY` for AI Studio. |
| 80 | +- **Run the built-in instead of an override:** prefix with `AGENTS_CLI_DISABLE_OVERRIDES=1` (e.g. `AGENTS_CLI_DISABLE_OVERRIDES=1 agents-cli run "hi"`). |
| 81 | +- **Deploy contract:** `app/fast_api_app.py` must keep exposing `app`. If you restructure the agent, keep that import working. |
| 82 | +- **Compatibility:** the template's manifest declares no `requires` range, so its overrides apply on any CLI version. See [Authoring → Compatibility](authoring.md#compatibility) for declaring one in your own. |
0 commit comments