Skip to content

Commit c933e3a

Browse files
committed
docs: add LangSmith Cloud deployment migration plan
Step-by-step runbook for migrating agent from Render to LangGraph Platform — covers dev deploy, verification, merge, production deploy, rollback, and cleanup.
1 parent 0d3a6e6 commit c933e3a

1 file changed

Lines changed: 235 additions & 0 deletions

File tree

Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
# Deployment Migration — LangSmith Cloud (LangGraph Platform)
2+
3+
## Context
4+
5+
Migrating from a fully self-hosted Render deployment (both agent + frontend) to a split topology: **frontend on Render, agent on LangGraph Platform (LangSmith Cloud)**. The codebase changes are on `feat/deploy-langsmith-cloud` (commit `0d3a6e6`). This plan covers the safe rollout path: branch deploy to dev, verify, merge to main, promote to production.
6+
7+
### What changed (code)
8+
9+
- `render.yaml` — Agent service removed; `LANGGRAPH_DEPLOYMENT_URL` switched from `fromService` to `sync: false`
10+
- `apps/agent/main.py``LANGGRAPH_CLOUD` detection fixed (truthy string bug), startup log added
11+
- `apps/agent/langgraph.json` — Already correct: `"sample_agent": "./main.py:agent"`, no `.env` ref
12+
- `docs/deployment.md` — Rewritten for split deployment with `langgraph deploy` CLI
13+
- `.env.example` — Noted `LANGSMITH_API_KEY` needed on frontend
14+
15+
### Prerequisites
16+
17+
- [ ] LangSmith account (Plus plan or higher)
18+
- [ ] LangSmith API key (`lsv2_...`) — obtain from https://smith.langchain.com/settings
19+
- [ ] `langgraph` CLI installed: `pip install langgraph-cli`
20+
- [ ] Docker installed and running (Apple Silicon: ensure Buildx is available)
21+
- [ ] `OPENAI_API_KEY` ready for agent env vars
22+
- [ ] Render dashboard access for the frontend service
23+
24+
---
25+
26+
## Phase 1: Deploy Branch to Development (LangSmith Cloud)
27+
28+
### 1.1 Create development deployment on LangGraph Platform
29+
30+
```bash
31+
cd apps/agent
32+
langgraph deploy \
33+
--name open-generative-ui-agent-dev \
34+
--deployment-type dev
35+
```
36+
37+
- The CLI builds a Docker image from `langgraph.json` and pushes to the managed registry
38+
- Use `--verbose` if the build fails to see Docker output
39+
- Apple Silicon: the CLI uses Buildx to cross-compile to `linux/amd64`
40+
41+
### 1.2 Configure agent env vars in LangSmith dashboard
42+
43+
Navigate to the deployment in the LangSmith dashboard and set:
44+
45+
| Variable | Value |
46+
|----------|-------|
47+
| `OPENAI_API_KEY` | Your OpenAI key |
48+
| `LANGGRAPH_CLOUD` | `true` |
49+
| `LLM_MODEL` | `gpt-5.4-2026-03-05` (or preferred model) |
50+
| `LANGCHAIN_TRACING_V2` | `true` |
51+
| `LANGCHAIN_PROJECT` | `open-generative-ui-dev` |
52+
53+
### 1.3 Note the deployment URL
54+
55+
After the deployment is live, note the URL:
56+
```
57+
https://<id>.default.us.langgraph.app
58+
```
59+
60+
### 1.4 Point local frontend at dev deployment
61+
62+
Test locally before touching Render:
63+
64+
```bash
65+
LANGGRAPH_DEPLOYMENT_URL=https://<id>.default.us.langgraph.app \
66+
LANGSMITH_API_KEY=lsv2_... \
67+
pnpm dev:app
68+
```
69+
70+
---
71+
72+
## Phase 2: Verify Development Deployment
73+
74+
### 2.1 Smoke tests
75+
76+
- [ ] Frontend loads at `http://localhost:3000`
77+
- [ ] Chat input accepts a message and gets a response
78+
- [ ] Agent can add/update/complete todos (state sync works)
79+
- [ ] Generative UI renders (widgetRenderer, charts)
80+
- [ ] No checkpointer warnings in agent logs (check via `langgraph deploy logs`)
81+
82+
### 2.2 Persistence check
83+
84+
- [ ] Send a message, note the thread ID
85+
- [ ] Refresh the page — conversation state should persist (Postgres-backed)
86+
- [ ] This is the key improvement over BoundedMemorySaver (in-memory, lost on restart)
87+
88+
### 2.3 Tracing check
89+
90+
- [ ] Open LangSmith dashboard → project `open-generative-ui-dev`
91+
- [ ] Verify traces appear for each agent invocation
92+
- [ ] Check for errors or unexpected latency in traces
93+
94+
### 2.4 Auth check
95+
96+
- [ ] Confirm requests without `x-api-key` header are rejected by the platform
97+
- [ ] Confirm requests with valid `LANGSMITH_API_KEY` succeed
98+
99+
### 2.5 Edge cases
100+
101+
- [ ] Rapid successive messages (rate limiting on frontend if enabled)
102+
- [ ] Long-running agent response (streaming works end-to-end)
103+
- [ ] Empty/malformed input handling
104+
105+
---
106+
107+
## Phase 3: Deploy Frontend Branch to Render (Optional)
108+
109+
If you want to test the full split deployment before merging:
110+
111+
### 3.1 Push branch and create preview
112+
113+
Render supports branch-based preview environments. Push the branch:
114+
115+
```bash
116+
git push origin feat/deploy-langsmith-cloud
117+
```
118+
119+
In Render dashboard, create a preview environment or manually set env vars on a staging service:
120+
121+
| Variable | Value |
122+
|----------|-------|
123+
| `LANGGRAPH_DEPLOYMENT_URL` | `https://<id>.default.us.langgraph.app` (dev deployment) |
124+
| `LANGSMITH_API_KEY` | `lsv2_...` |
125+
126+
### 3.2 Verify on Render
127+
128+
- [ ] Frontend health check passes: `GET /api/health` → 200
129+
- [ ] Chat works end-to-end through Render → LangGraph Platform
130+
- [ ] No CORS or network errors in browser console
131+
132+
---
133+
134+
## Phase 4: Merge to Main
135+
136+
### 4.1 PR and merge
137+
138+
```bash
139+
gh pr create \
140+
--title "feat: split deployment — frontend on Render, agent on LangGraph Platform" \
141+
--base main \
142+
--head feat/deploy-langsmith-cloud
143+
```
144+
145+
After review/approval:
146+
```bash
147+
gh pr merge --squash
148+
```
149+
150+
### 4.2 Verify CI passes
151+
152+
- [ ] CI smoke tests pass (build + lint + startup check)
153+
- [ ] No regressions on the frontend build
154+
155+
---
156+
157+
## Phase 5: Deploy Main to Production (LangSmith Cloud)
158+
159+
### 5.1 Create production deployment
160+
161+
```bash
162+
cd apps/agent
163+
langgraph deploy \
164+
--name open-generative-ui-agent \
165+
--deployment-type prod
166+
```
167+
168+
Or update existing deployment:
169+
```bash
170+
langgraph deploy \
171+
--name open-generative-ui-agent \
172+
--deployment-id <existing-deployment-id>
173+
```
174+
175+
### 5.2 Configure production env vars in LangSmith dashboard
176+
177+
| Variable | Value |
178+
|----------|-------|
179+
| `OPENAI_API_KEY` | Production OpenAI key |
180+
| `LANGGRAPH_CLOUD` | `true` |
181+
| `LLM_MODEL` | `gpt-5.4-2026-03-05` |
182+
| `LANGCHAIN_TRACING_V2` | `true` |
183+
| `LANGCHAIN_PROJECT` | `open-generative-ui` |
184+
185+
### 5.3 Note production deployment URL
186+
187+
```
188+
https://<prod-id>.default.us.langgraph.app
189+
```
190+
191+
### 5.4 Update Render production frontend
192+
193+
In the Render dashboard, update the production frontend env vars:
194+
195+
| Variable | Value |
196+
|----------|-------|
197+
| `LANGGRAPH_DEPLOYMENT_URL` | `https://<prod-id>.default.us.langgraph.app` |
198+
| `LANGSMITH_API_KEY` | Production LangSmith API key |
199+
200+
Trigger a redeploy (or it will auto-deploy from the main branch merge).
201+
202+
### 5.5 Production verification
203+
204+
- [ ] `GET /api/health` → 200
205+
- [ ] Chat works end-to-end
206+
- [ ] Todos persist across page refreshes
207+
- [ ] Traces appear in LangSmith project `open-generative-ui`
208+
- [ ] No errors in `langgraph deploy logs`
209+
- [ ] Generative UI (widgets, charts) renders correctly
210+
211+
---
212+
213+
## Rollback
214+
215+
### If agent deployment fails
216+
217+
The previous Render agent service is still defined in the `main` branch prior to merge. If the LangGraph Platform deployment is broken:
218+
219+
1. Revert the `render.yaml` change (restore agent service block)
220+
2. Revert `LANGGRAPH_DEPLOYMENT_URL` to `fromService` in Render dashboard
221+
3. Redeploy on Render
222+
223+
### If frontend deployment fails
224+
225+
The frontend changes are minimal (no code changes to `route.ts`). Rolling back just means pointing `LANGGRAPH_DEPLOYMENT_URL` back to the old agent URL in the Render dashboard.
226+
227+
---
228+
229+
## Post-Migration Cleanup
230+
231+
- [ ] Delete the dev deployment: `langgraph deploy delete <dev-deployment-id>`
232+
- [ ] Remove old Render agent service if it was kept as fallback
233+
- [ ] Confirm LangSmith tracing project is receiving data
234+
- [ ] Update any team runbooks or onboarding docs referencing the old Render agent
235+
- [ ] Consider enabling `RATE_LIMIT_ENABLED=true` on the Render frontend

0 commit comments

Comments
 (0)