← Portfolio
Live in your browser

agent-graph

A real LangGraph ReAct agent — compiled and executing in this tab, in WebAssembly. Not a recording, not a JS reimplementation: the same StateGraph that runs in CI, picking tools and looping until it can answer.

Booting Python…
// Part 1

Watch it use tools

Ask something. The agent decides which tool to call, sees the result, and decides again — looping agent ⇄ tools until it's done. Every step below is the real trace the graph emitted.

Loading…
// Part 2

Try to break the guardrail

The calculator tool is the agent's most dangerous surface — it takes a string and evaluates it. A naive implementation reaches for eval(), and then anything the agent can be talked into typing becomes code execution. This one walks a parsed AST and permits only arithmetic nodes, so there's nothing to escape into. Try it.

The other guardrail is a step budget: the agent node forces a finish once it hits max_steps, so a policy that never decides to stop still terminates. Both are unit-tested — a broken policy that loops forever is an actual test case.
// Part 3 — they compose

The agent calls the gateway

An agent is a chatty LLM client: one model call per turn, and multi-step runs repeat near-identical prompts constantly. So this agent points its LLM calls at llm-gateway — the companion project — which then authenticates, caches, retries and cost-accounts every one of them, without the agent knowing any of it happened.

Both projects are running in this one tab. This page installs the gateway's own published wheel — the same artifact its CI ships — so the arrow below isn't a diagram, it's a function call. Ask the same question twice and watch the gateway serve the agent from cache.

Honest about the split: the tool selection stays deterministic (the rule-based planner, so the graph stays reproducible and testable) — the gateway governs the compose call, where a model turns tool results into an answer. Swap in LLMPolicy and the model picks tools too, through the same gateway. And if the gateway is unreachable, the policy degrades to composing locally rather than throwing away work the tools already did — that's a tested path.