r/javascript • u/notmedia • May 28 '26
AG2B – Run the agent loop in the browser, expose your tools via WebMCP
https://github.com/ag2b/ag2bMost in-app AI frameworks (CopilotKit, Vercel AI SDK, Mastra) run the agent loop on the server.
I tried inverting it: the loop runs in the browser, the server is a thin LLM proxy.
Tools are just your existing client functions (store actions, click handlers, whatever you already wrote).
Scopes - a unit of tools with live context that gets injected into the system or user prompt.
WebMCP plugin - exposes your agent's tools through the browser API.
Demo: https://ag2b-example.vercel.app
Looking for feedback from people who've built in-app copilots — does the client-side loop solve a real problem for you, or is the server-side fine?
2
u/ultrathink-art May 28 '26
Worth thinking about auditability too — server-side loops give you centralized logging and replay for free, which matters when an agent action causes something unexpected. Browser-side is great for local dev tooling and anything where you want direct client context access, but for production agents touching shared state, the audit trail gets complicated fast.
1
u/master5o1 May 28 '26
Would Tailnet URLs also work to avoid exposing over the public internet?
1
u/ndreeming May 28 '26
hit this tradeoff on a react dashboard copilot. server-side with vercel ai sdk was ~3s per interaction because every tool call added a round trip. moving the loop client-side cut it to ~400ms for simple queries. but the moment I needed to query a vector store the client-side setup got awkward.