migrate agent-proxy to Netlify Edge Function so long sessions stream end-to-end

The reconnect + events.list backfill in c283d88 is correct but never ran:
the previous v2 Node Function was killed at ~27 s (well before the 20 min
reconnect budget could matter), so streams always died after the first MCP
tool batch.

Move the proxy to a Netlify Edge Function (Deno runtime) which has no
streaming-duration cap as long as we keep writing to the response body.
Same reconnect / backfill / dedupe-by-event-id pattern; same NDJSON wire
protocol to the browser. Implemented with plain fetch() against the
Anthropic REST API (npm packages on Edge are beta) so we have no SDK
runtime dependency.

Frontend now POSTs to /api/agent-proxy. The Anthropic SDK is removed
from the package; @netlify/edge-functions is added for ambient types.

Co-Authored-By: alex <alex@semipublic.co>
This commit is contained in:
Devin AI
2026-05-13 12:40:31 +00:00
parent c283d884cf
commit d1c5be112e
6 changed files with 1984 additions and 196 deletions
+1 -1
View File
@@ -128,7 +128,7 @@ export default function App() {
setIsStreaming(false)
try {
const response = await fetch('/.netlify/functions/agent-proxy', {
const response = await fetch('/api/agent-proxy', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(form),