What goes in /app
In serve mode (ADR-064) one container is one app. The app is a folder, /app in the image, that ships with the image and is read only. Everything golem writes goes somewhere else, on a volume. This page is the whole of that folder, so you do not have to piece it together from the settings, the run guide and the Serve API.
The layout
/app
├── config.toml # settings: the default model, providers, [serve]
├── agents/ # one NAME.md for each agent. The names are the models of chat completions
├── workflows/ # one NAME.py for each workflow. The names are what POST /v1/workflows/NAME/runs starts
├── measure/ # one NAME.toml for each Measure set, run by golem serve measure before a deploy
└── skills/ # one folder for each skill, with a SKILL.md in itEvery part is optional. An app that only serves workflows has config.toml and workflows/. examples/serve/app is a small one.
golem does not write into /app. A write that would land there is refused with the name of the variable that moved it.
config.toml
The same file as the settings, with the keys that serve mode needs:
default_model = "anthropic/<model-id>" # a model of a provider below, or a [models.<name>] you define
[providers.anthropic]
api_key_env = "ANTHROPIC_API_KEY" # the variable the key is read from. The key itself is never in this file
[serve]
ask = "deny" # "deny": a review is answered "reject" at once. "app": the app's user answers it
drain_seconds = 25 # after SIGTERM, how long open requests and streams may finish
keep_events_days = 30 # how long a run's stored events are kept after it ends. 0 keeps them for ever
keep_days = 0 # 0 keeps runs for ever; 30 removes ended runs, and what belongs to them, after 30 days
metrics = false # true turns on GET /metrics (needs a key of the app)
[serve.limits] # all optional; what is shown is the default, and the two money limits have none
requests_per_minute = 600 # per key, kept by the gateway
streams_at_once = 64 # open event and chat streams per key, kept by the gateway
runs_at_once = 4 # per user, runs and chat turns that are executing
runs_at_once_total = 32 # the whole deployment
# user_usd_per_day = 2.00 # per user, per UTC day
# key_usd_per_day = 200.00 # per key, per UTC day
# [serve.webhooks] # optional; leave it out and golem sends nothing
# url = "https://app.example/hooks/golem"
# secret = "secret:webhook/app" # whsec_ and base64, read from /run/secrets/webhook_app
# events = ["run.completed", "run.failed", "run.canceled", "run.input_required"]- The default model is the model every agent and workflow uses unless its own file names another. A model is reached by an endpoint, so a provider with no endpoint (a local
ollamawith nobase_url) is a problem forgolem serve check: serve mode starts no local model server. - A provider has
api_key_env, the name of an environment variable. A key written in the file is refused, and the file does not load. [serve]is read from your file only.askis"app"when the app's own user should answer a review (the API).keep_events_daysis how long events live.keep_daysremoves old runs and what belongs to them (deleting a user and the sweep);golem serve checkrefuses akeep_events_daysthat is longer.metrics = trueturns onGET /metrics(Watching a served golem).[serve.limits]keeps one user or one leaked key from running up the bill or starving the others: a caller over a limit gets429withRetry-After(Limits, the table).golem serve checkreports values that make no sense.[serve.webhooks]tells your app when a run ends or needs an answer, so it does not have to poll (Webhooks).golem serve checkrefuses a URL that is nothttps(plainhttpis forlocalhostand private names, with a warning), a secret that is not set or notwhsec_and base64, and an unknown event name.
Agents, workflows and skills
| Folder | A file is | Used by |
|---|---|---|
agents/ | NAME.md: a header (description, model, tools) and the system prompt. Only the tools serve mode has: no shell, no file writes | POST /v1/chat/completions with "model": "NAME", and run.agent in a workflow |
workflows/ | NAME.py: a function marked @workflow(inputs={...}, required=[...]). See workflows | POST /v1/workflows/NAME/runs |
skills/ | NAME/SKILL.md, as in skills | an agent or a workflow step that names it |
GET /v1/models lists the agents. A workflow file that does not load is not startable, and golem serve check says why.
Secrets
A secret is never in /app. In serve mode golem reads secrets from files and variables and never writes them. A secret named mcp/github is the file $GOLEM_SECRETS_DIR/mcp_github (the folder is /run/secrets unless set), else the variable GOLEM_SECRET_MCP_GITHUB. A provider's key is its api_key_env variable. The rule for the names is in settings.
Checking the folder
GOLEM_APP=./app golem serve checkIt starts nothing and calls no model. It prints one line for each problem and exits 1: a config.toml that does not parse, an agent or workflow that does not load, a tool an agent names that serve mode does not have, a secret that is named and not set, a model with no endpoint, [serve] ask = "owner", and a [serve.webhooks] with a url that is not https, a secret that is not set, or an event golem does not have, and a keep_events_days that is longer than keep_days. Run it in CI before you build the image. It reads the Measure sets too (see Measure before you deploy).
Keys
The API is called with a key. Make one inside the running container:
docker compose exec golem golem serve keys create --name demo # prints the key once
docker compose exec golem golem serve keys list
docker compose exec golem golem serve keys revoke demogolem keeps only a digest of a key, so a lost key is revoked and made again.
The three variables
The image sets them. Set them yourself when you run golem serve outside it.
| Variable | In the image | Is |
|---|---|---|
GOLEM_APP | /app | The definition: the folder on this page. Read only. Without it, the definition is GOLEM_HOME |
GOLEM_HOME | /data | The state: databases, logs, anything golem writes. Put it on a volume. One replica uses one |
GOLEM_RUN | /run/golem | The socket between the listener and the daemon, and the pid lock |
The socket is a file under GOLEM_RUN, and an operating system limits its path: about 100 bytes (104 on macOS, 108 on Linux). Keep GOLEM_RUN short. /run/golem is. A long path under a build directory or a temporary folder is the usual cause of a daemon that will not start.
Measure before you deploy
A Measure set is a file measure/NAME.toml in the app folder. It lists cases. A case asks one of the app's agents a question, or starts one of its workflows, and checks the text that comes back. golem serve measure runs the sets before the new version takes traffic and stops the deploy when the agents got worse.
description = "the support agent still answers"
pass_mark = 0.8 # optional: the share of cases that must pass. Without it --min-score is used
[[case]]
name = "refund"
agent = "support" # an agent of the app. Or: workflow = "NAME" with inputs = { n = 4 }
ask = "How do I get a refund?"
contains = ["30 days"] # every text must appear (case does not matter)
not_contains = ["sorry"] # none may appear
matches = "\\d+ days" # a regular expression that must matchA case passes when all its checks hold. The score of a set is the share of its cases that pass, from 0 to 1. A set passes when its score reaches its pass mark: its own pass_mark, else --min-score, else 1 (every case).
GOLEM_APP=./app golem serve measure --min-score 0.8| Option | Does |
|---|---|
--set NAME | Runs only this set. Repeat it for more |
--min-score N | The pass mark of a set that has none (0 to 1) |
--max-usd N | Stops the run when the spend reaches N dollars. The sets not run yet fail |
--json | Prints one JSON document instead of lines |
--home DIR | Keeps the state in DIR, so two runs can be compared. Without it a temporary folder is used and removed |
The exit code is the verdict: 0 every set passed, 1 a set failed (or --max-usd stopped the run), 2 it could not run: a set that does not load, an agent or workflow a case names that is not in the app, a model key that is not set, or a state folder that is the live one. It prints one line for each set (score, cases passed, cost) with the failed cases named under it, then the cost of the whole run and the verdict.
It runs with the app's own agents, workflows and config.toml, in serve mode (no ask waits for a person, only the tools serve mode has), and it calls the model for real, so it costs money. It starts no listener and takes no traffic. It runs a daemon of its own on a state folder of its own and never opens the data of the live deployment; --home may not be the live GOLEM_HOME. Each run writes its report to DIR/evals/gate/. golem serve check reads the sets too.
The image runs any command you put after its name instead of the server, so the gate is a one-off container of the image you are about to ship. With --read-only, give it a --tmpfs /tmp for its temporary state folder.
In GitHub Actions, run it on the image you are about to ship, with the provider key as a secret:
- name: Measure before deploy
run: |
docker run --rm -e ANTHROPIC_API_KEY=${{ secrets.ANTHROPIC_API_KEY }} \
ghcr.io/example/my-app:${{ github.sha }} golem serve measure --min-score 0.8 --max-usd 2
- name: Deploy
run: ./deploy.sh # runs only when the step above exited 0In compose, run it as a one-off before you bring the new version up. The app service is the same as the one that serves:
docker compose run --rm app golem serve measure --min-score 0.8 --max-usd 2 \
&& docker compose up -d appNext
- Serve your agent, a guide that goes from this folder to a running container that your app calls.
- Watching a served golem, the metrics page, trace ids in the logs and the load test.
- Running:
golem serve, the command, its probes and how it stops. - The Serve API and its contract.
examples/serve: compose, an example app folder,fly.toml, client snippets andcurlscripts.