Skip to Content
ConceptsArtifacts

Artifacts

Agents produce things that people use: an API, a web front-end, a report to download, live progress to watch. Golem calls these artifacts and serves them from the same deployment as the agents, so an application needs no separate web server, file host, or streaming service. A single golem deploy ships the agents, their tools, and the front-end whose buttons call them.

For example, a reporting application deploys its single-page front-end as static files. The front-end’s buttons call HTTP endpoints on ReportAgent agents, progress streams back to the page while the agent works, and the finished report, a file the agent wrote, is served from the agent’s filesystem. The front-end, the API, the stream, and the file all come from one deployment, and the agents behind them are durable.

HTTP endpoints for agent methods

An agent type can declare an HTTP mount path, and its methods can declare endpoints under it. The mount path contains every constructor parameter, so the URL identifies the agent. With this declaration, POST /counters/alice/increment calls increment on CounterAgent("alice"):

export const CounterAgent = defineAgent({ name: "CounterAgent", id: { name: z.string() }, http: http.mount("/counters/{name}"), methods: { increment: method({ input: {}, returns: z.number(), http: http.post("/increment"), }), }, });

Path, query, and header parameters map to method inputs, and return values map to responses. Each deployment publishes an OpenAPI document for its endpoints. A deployment can claim a subdomain, such as my-app.localhost:9006 locally or my-app.apps.golem.cloud on Golem Cloud.

HTTP routers

When an application needs full control over HTTP, for example to serve an existing web framework or handle streaming uploads, it can define an HTTP router. A router’s handler receives a standard Fetch Request and returns a Response:

export const EchoRouter = defineHttpRouter("EchoRouter") .mount("/echo") .implement((request) => new Response(request.body));

A router calls agents through their clients, so one router can serve a single-page app while typed endpoints answer its API calls on the same origin.

Interactive apps

A web app on Golem is interactive, not static output: its JavaScript runs in the browser and calls the agents’ HTTP endpoints, and each call runs durable agent code with the agent’s state and permissions. An agent can also generate an app at runtime: it writes HTML and JavaScript into its own filesystem, serves them as live files, and the page calls the agent’s endpoints. What Golem does not run is a long-lived server process, such as a development server, inside a tool.

Static and live files

Static filesLive files
WhatFiles deployed with a router, such as a front-end’s HTML, CSS, and JavaScriptFiles in a durable agent’s filesystem, such as a report the agent just wrote
ServedDirectly from storage, without running any agentFrom the agent’s current filesystem, without running a method
CachingCached and revalidated with an ETagNever cached

A live file is never served half-written: the read waits until the agent’s current method call finishes.

Cached read-only responses

Methods marked read-only can be answered from a cache without loading the agent. On a GET endpoint, the response carries an ETag, and a client that already has the current version gets 304 Not Modified.

Streams that survive reconnects

A method that returns a stream, mounted on an HTTP endpoint, is served using the Durable Streams protocol, an open HTTP protocol for resumable streams. The stream belongs to the agent, not to the HTTP connection, so a browser tab that reloads continues from the last position it read. Existing Durable Streams clients work with these endpoints.

Login

Endpoints can require authentication. A single-page app can sign users in with the OAuth2 authorization code flow with PKCE, and Golem checks the token before any agent code runs.

Authentication tells an agent who is calling; it does not decide which agents a user may reach. A user can put any agent’s name in a URL, so a method that serves user data should read the authenticated caller (the principal) and check it against the application’s access rules.

Keeping an existing web app

You do not have to serve your front-end from Golem. An existing application, such as a Next.js app, can call agents from its server through a client library generated for its language or through the REST API, and keep its own UI and hosting.

One agent, many entry points

The same agent can be reached from a browser, an MCP client, the CLI, a generated client library in your own application, the REST API, and other agents. Endpoints are declared in agent code, and they become reachable over HTTP or MCP only when an httpApi or mcp deployment in golem.yaml publishes them.

Clients reaching one agent, ReportAgent("acme", "q3"), which has one identity, one state, and one oplog. A browser and an MCP client connect through public endpoints that exist only because an httpApi or mcp deployment in golem.yaml lists the agent. The CLI and REPL, a bridge library in your application, the REST API, and other agents connect through Golem's own interfaces.Open full-size image in a new tab.
Public endpoints exist only where the manifest declares them. Every entry point reaches the same agent.

Next

Agent lifecycle: how agents are created, suspended, updated, inspected, and scaled.

Related guides: