two managed tools
some tools are worth building, some aren't. a managed browser and a managed code sandbox fall in the second category — every team has the same requirements (isolate, clean up, scale, record) and no team wants to run that infrastructure themselves. agentcore ships both as first-class primitives.
- browser a managed headless chromium the agent can drive — navigate, click, extract, screenshot. stateful within a session, torn down at the end. for tasks where the cleanest api is "click the button a human would."
- code interpreter a managed javascript/typescript sandbox. the agent writes code, runs it, gets the result. ephemeral filesystem, no network by default, strict memory/cpu limits. for math, parsing, transformation — the things llms are bad at doing in-head.
when to reach for each
the rule: use gateway (lesson 4) when a real api exists. reach for browser only when the clean path is through a human-facing ui. reach for code interpreter when the agent needs to compute something deterministic — stats, parsing, regex, data transformation — and you don't want the llm to fake its way through it.
browser — navigate, extract, close
in the sandbox we pre-register fake pages so navigation has something to
return. in production you just call navigate(url) and get
the real thing. the api is intentionally small — navigate, extract, click,
screenshot, close — because anything more elaborate belongs to the
agent's logic, not the browser primitive. the real typescript sdk also
ships PlaywrightBrowser for teams that want the full
playwright surface on top.
code interpreter — exec, capture, return
the contract: whatever the code returns is handed back to
the caller. exceptions propagate, but only within the sandbox — your
agent process is untouched. in production the sandbox is a
firecracker
microvm; here it's a plain AsyncFunction because we're
already inside a worker.
combined — browser feeds interpreter
the common pattern: fetch unstructured text with the browser, hand it to the code interpreter for parsing and computation. neither primitive alone is powerful; together they replace what used to take three third-party services.
read the trace end-to-end: app.invoke → browser.navigate
→ browser.extract_text → browser.close →
code_interpreter.execute → code_interpreter.result →
app.done. that's the shape of an agent that reads the web
and reasons about numbers, with zero custom infrastructure.
isolation, scale, cleanup
the things you don't have to think about, per the managed contract: every browser session is isolated (no cross-session cookies, no shared state), scales out to thousands of concurrent instances, and tears down cleanly when the invocation ends. same for code interpreter: fresh namespace per call, ephemeral fs, resource caps enforced by the runtime.
next: observability — reading the trace, and adding your own.