Atlas incident investigation with Flow
A plan to run the Flow agent harness inside Atlas. Atlas gives the agent a set of deterministic, scrubbed tools. Central hands off an issue to Atlas and gets back a summary. Central never connects to a host.
1. Problem
Atlas is the regional control plane. It already has dashboards and alerts in Insights. The data comes from Datum, which stores metrics and logs in ClickHouse. When an alert fires, an operator reads the charts, then connects to hosts over SSH to find the cause. This takes time, and the steps are similar each time.
Flow is the agent harness in the Frappe framework. It can run a model in a loop with tools, skills and a knowledge base. We want Flow to do the first part of an investigation.
There are three constraints:
- Small exposure to Central. Central has only an API contract with Atlas. Central must not connect to a host over SSH. Central gets only the result of an investigation.
- No secrets to the model. All command output and log text goes through a deterministic scrubber before the agent reads it.
- A person approves changes. The agent asks before any action that changes state. Termination is never available to the agent.
2. Design: where the agent runs
We considered two options.
| Option | How it works | Result |
|---|---|---|
| A. Agent in Central, Atlas exposes raw read APIs | Central's agent calls many Atlas routes and reads raw output. | Rejected. Central sees raw host data. Each new tool needs a new public route. |
| B. Agent in Atlas, Central hands off an issue | Each region runs its own investigator. Central sends an issue and reads back a scrubbed summary. | Chosen. Raw data stays in the region. The contract is two or three routes. |
In option B, the Central agent uses the Atlas investigator like a subagent: it gives a task and gets a report back.
3. What Flow gives us today
Flow is in frappe/flow. A daemon (flow_harness) runs the agent loop for the bench. Frappe holds the configuration, the transcript and the HTTP API. We checked these facts in the code:
- Models. Flow uses LiteLLM. A
Flow Providerwithprovider=openrouterand aFlow Modelwithmodel_id=deepseek/deepseek-v4.1-flash-1017orz-ai/glm-5.3-flashis enough. Both model IDs exist on OpenRouter. - Tools. An app declares
flow_toolsinhooks.py. Each tool is a function with the@tooldecorator and a keyword argumentctx: ToolContext. The schema comes from type hints. A tool can setrequires_confirmation=True. This value is a plain boolean, not a function of the arguments. - Agents. An app declares
flow_agents. The function returnsAgentobjects with instructions, tools, skills and knowledge bases. - Skills. Flow loads
<app>/skills/<name>/SKILL.mdfrom the app repository root. - Knowledge base.
Flow Knowledge Basewith text, file, URL or DocType sources. Search is hybrid (full text and vector). It needs an embedding model. - Approval. A gated call pauses the
Flow Run. The owner answers withfrappe.flow.api.resume: Approve, Deny or free text.
Gaps that affect this plan:
- Approval decisions are not recorded. Gated tools run as the engineer, so the existing console logs and action records name the person who approved.
- Sessions from triggers always auto-approve. We will not use triggers for investigations.
- The REST API has no completion callback. We start runs from Python with
on_complete, so Atlas knows when a run ends. - A session keeps the tool set from its start. Tool changes apply only to new sessions.
4. The tool set
Each tool is small and deterministic. The agent cannot send free SQL to the database or free shell to a host without a gate. Tools live in a new Atlas module, atlas/investigation/, grouped by subject. Every tool returns scrubbed text or JSON.
4.1 Inventory (read only)
| Tool | Returns |
|---|---|
find_resources | Hosts, VMs and service VMs that match a name, IP, tenant or status. |
get_host | Metal Server state, disks, metald version, recent actions. |
get_virtual_machine | VM state, host, tenant, network, recent actions and migrations. |
list_recent_tasks | Recent SSH Tasks, console logs and failed background jobs for a resource. |
list_error_logs | Recent Atlas Error Log rows, grouped by method. |
4.2 Telemetry (read only)
| Tool | Returns |
|---|---|
list_alert_checks | The checks in the existing Insights alerts (P1, P2 Hosts, P2 Platform, P3) and which ones fail now. |
list_saved_queries | The queries of the Atlas Insights workbook, with key and title. |
run_saved_query | The result of one workbook query, with an optional time range. |
query_telemetry | The result of a SELECT on Datum. It connects as a read-only ClickHouse user (readonly=1), with a row limit and a time limit. |
get_telemetry_freshness | The time of the last metric and the last log line from each host. Old values mean that telemetry is blind for that host. |
The saved queries come first. They are tested and fast. The skill tells the agent to use them before it writes its own SQL.
Telemetry first, host second
Vector already sends most logs to Datum. So the agent reads Datum first. It goes to a host only for data that Datum does not have.
| Data | In Datum |
|---|---|
metald journal (metal.service), all levels | Yes |
Other host journal lines, warning and above (includes metal-vm@<id> units) | Yes |
| Service VM journal, warning and above; proxy nginx errors | Yes |
| Host and VM metrics | Yes |
firecracker.log; journal lines below warning; live state (processes, sockets, WireGuard, disk) | No |
The agent also goes to the host when get_telemetry_freshness shows old data. Then Vector or the network has failed, and Datum cannot show the problem.
4.3 Host and VM diagnostics (fixed commands)
These tools run a fixed script through SSH Task in background mode. Atlas connects to the host over SSH, not through the metald API, so the tools work when metald is down. Each run is a record, so there is an audit trail. The agent chooses only the target and the size.
| Tool | Command on the host |
|---|---|
get_firecracker_log | tail -c of /var/lib/metal/machines/<id>/firecracker/<id>/root/firecracker.log |
get_vm_unit_journal | journalctl -u metal-vm@<id>.service --since |
get_metald_journal | journalctl -u metal.service --since. Only for hosts with stale telemetry; otherwise the agent reads this journal from Datum. |
get_host_health | Load, memory, disk, failed units, kernel messages (dmesg tail), WireGuard handshakes |
The same scripts become buttons for operators. Fetch Firecracker Log and Fetch VM Journal go on Virtual Machine. Fetch metald Journal goes on Metal Server. This fills a gap: today no action fetches these logs.
4.4 Commands and actions (gated)
These tools exist only in the engineer agent (see section 5). The Central investigation agent does not have them.
| Tool | Target | Gate |
|---|---|---|
run_command | Host or tenant-0 VM | Approval for each call. |
run_tenant_vm_command | VM of a customer tenant | Approval for each call. The prompt names the tenant. |
run_action | Metal Server, Virtual Machine, service record | Approval for each call. Allow list of actions; termination is not in the list. |
A third command tool, run_readonly_command, is in both agents. It needs no approval, because a parser refuses every command that is not on a read-only allow list (see section 5).
Commands run through the Metal Server Console, which already logs each run in Metal Server Console Log. Tenant-0 VMs are reached with the existing proxy command through the host network namespace.
5. Permission policy
Flow sets approval per tool, not per argument. So we split the tools by risk, and we use two agents with different tool sets. The model cannot change the policy, because it is fixed by which tools an agent has.
- Atlas Investigator. Central starts it. It has read-only tools only. It never pauses for approval, because no tool in it needs approval.
- Atlas Engineer Assistant. An Atlas engineer starts it in the Atlas desk. It has the read-only tools and the gated tools. The engineer approves each gated call in the chat.
| Action | Central investigation | Engineer in Atlas |
|---|---|---|
| Read inventory, telemetry, logs, docs | Allowed | Allowed |
| Read-only command on a host or tenant-0 VM (allow list) | Allowed, logged | Allowed, logged |
| Other command on a host or tenant-0 VM | Not available | Engineer approves |
| Any SSH to a VM of a customer tenant | Not available | Engineer approves |
| Change actions (restart, stop, migrate, reboot, resize, firewall, upgrade) | Not available | Engineer approves |
terminate, archive_server, delete of any record | Not available | Not available |
The read-only allow list is a parser, not a prompt. It splits the command on ;, &&, || and |. It refuses redirection, command substitution and backticks. Each part must start with an allowed program, for example journalctl, systemctl status, cat, tail, head, grep, ls, df, free, ss, ip, wg show, ps, top -b -n 1, uptime, dmesg. Reads of secret paths, such as /etc/shadow and private keys, are refused.
Central investigations run as a dedicated Atlas user with an Atlas Investigator role. Each read-only tool checks this role. Gated tools also require System Manager, so the investigator user cannot use them even if a session gets them by mistake. Engineer sessions run as the engineer, so the existing console logs and action records name the person who approved.
6. Scrubbing output
A scrubber is a function that replaces sensitive text with a fixed marker. It is deterministic: the same input always gives the same output, and no model is involved. It lives in one place, atlas/core/scrub.py, and every tool calls it on its return value.
It masks credentials only. IP addresses, host names, emails and record names stay, because they are needed to investigate. It replaces, in order:
- PEM blocks (private keys, certificates).
- Known token formats: JWT,
Bearervalues, cloud access keys,sk-API keys, GitHub tokens, WireGuard keys. - Values of secret-like keys in
key=value,key: valueand JSON, for examplepassword,secret,token,api_key. - Credentials in URLs (user info and signed query strings).
- High-entropy words. A word of 20 or more characters from a base64 or hex alphabet, with Shannon entropy above a limit, becomes
[REDACTED:entropy]. UUIDs and Atlas record names are kept, because the agent needs them.
password=hunter2 token: eyJhbGciOi... → password=[REDACTED] token: [REDACTED:jwt]
The Metal Server Console gets a Scrub Output check, on by default. With the check on, the stored output is scrubbed. An operator can turn it off for one run. Agent tools always scrub and cannot turn it off.
A second layer is possible: Flow's daemon has an extension point for a tool_call hook, with a redact_secrets example. We do not need it at first.
7. Central to Atlas handoff
A new DocType Atlas Investigation owns the state of one handoff. Fields: issue, context JSON, requested by, status (Queued, Running, Completed, Failed), Flow Session and summary. The run uses the read-only agent, so it never waits for approval.
Route (under /api/atlas) | Caller | Does |
|---|---|---|
POST /investigations | Central, tenant 0 only | Creates the record and starts a Flow run. Returns the ID. |
GET /investigations/{id} | Central | Status, summary and the full transcript: each tool call, its arguments and its scrubbed result. |
Atlas sends a webhook event on each status change, through the webhook that Central already configures. Central can also poll. Authentication uses the existing Central JWT and require_central_identity. No new token type is needed.
Central gets two Flow tools: start_region_investigation and get_region_investigation. Central gets the whole investigation, with credentials masked. If the cause needs a change, the summary says so. An Atlas engineer then does the change in the Atlas desk.
Knowledge and skill
An incident-investigation skill in atlas/skills/ gives the method: read the failing alert checks, run the saved queries, find the affected resources, read logs, form a hypothesis, check it, then report. It lists the tools to prefer at each step. A short report template sets the output: symptom, evidence, cause, confidence, and suggested next step.
The Atlas knowledge base uses openai/text-embedding-3-small through OpenRouter (0.02 USD per million tokens). It takes the Atlas docs/ folder, the module SPEC.md files and the incident postmortems. A second source takes Frappe Cloud platform docs. A setup command loads them, so a new region gets the same base.
8. Phases
Each phase has a check. A phase is done only when its check passes on atlas.localhost with the development region.
| # | Phase | Depends on | Check |
|---|---|---|---|
| 0 | Flow daemon on the Atlas bench. OpenRouter provider and two models on atlas.localhost. | None | test_connection passes for both models. A plain chat answers. |
| 1 | Scrubber module and tests. Scrub Output check on the Metal Server Console. | None | Tests with real secret shapes pass. A console run that prints a key stores [REDACTED]. |
| 2 | Log fetch scripts and buttons over SSH: Firecracker log, VM journal, metald journal. | 1 | Each button on a development host gives an SSH Task with scrubbed output. |
| 3 | Read-only ClickHouse user on Datum. Read-only tools: inventory, telemetry, freshness, alert checks, saved queries. | 1 | Each tool runs from a Flow chat and returns scrubbed output. An INSERT through query_telemetry fails in ClickHouse. |
| 4 | Read-only command parser and gated tools (run_command, run_tenant_vm_command, run_action). | 1, 2 | Parser tests pass. In an engineer session, a gated call pauses the run; Approve runs it, Deny stops it. terminate is refused. |
| 5 | Investigator role and user. Two agents (investigator, engineer assistant), skill and knowledge base. | 3, 4 | The investigator finds the cause of a staged fault on a development VM (for example, a stopped metald or a full disk). It has no gated tool. |
| 6 | Atlas Investigation DocType, two API routes and webhook event. | 5 | A curl call with a Central token starts a run and reads the summary and transcript. |
| 7 | Central client methods and Flow tools. | 6 | Central's agent hands off an issue and shows the Atlas summary. |
| 8 | Evaluation: replay the causes of past postmortems as staged faults. Record time to cause, tool calls and cost per model. | 7 | A table of measured results for both models. No targets yet. |
Phases 1 to 4 are useful without the agent. The scrubber and the log buttons help operators today.
9. Progress
| # | Phase | Status | Notes |
|---|---|---|---|
| Plan | Survey of Flow, Atlas and Central | Done | This page. |
| 0 | Flow on Atlas bench, models | Done | OpenRouter provider, DeepSeek V4.1 Flash and GLM 5.3 Flash. Embeddings: openai/text-embedding-3-small. |
| 1 | Scrubber, console flag | Done | atlas/core/scrub.py. It works line by line, so streamed console output stays stable. Scrub Output is on by default. |
| 2 | Log fetch actions | Done | New Diagnostics menu: Firecracker Log and VM Journal on a VM; metald Journal and Host Health on a host. Each is a scrubbed console log. Tested on a real host. |
| 3 | Read-only tools | Done | 15 tools. A read-only ClickHouse user for Datum. The saved queries come from the workbook scripts, so Atlas does not need Insights. |
| 4 | Gated tools, command parser | Done | Approval pause, Approve and run tested. The investigator user cannot call a change tool. |
| 5 | Agent, skill, knowledge base | Done | Two agents, the incident-investigation skill, and 127 documents in the knowledge base. |
| 6 | Investigation DocType and API | Done | POST and GET /api/atlas/investigations. Central polls; there is no webhook. Engineers save a chat with save_investigation. |
| 7 | Central tools | Done | start_region_investigation and get_region_investigation. Tested from Central with a real token. |
| 8 | Evaluation | Started | Two real findings (see below). No model comparison yet. |
First real result
The first investigation used the P1 alert "waw-1 has an unavailable VM". The agent found that a VM on that host has been stuck since 14 October. Its Firecracker API no longer answers, but the process is still alive. Because of this, metald still sees the VM as running and does not restart it. The agent gave medium confidence and listed the next checks.
| Run | Tool calls | Model iterations | Cost | Result |
|---|---|---|---|---|
| First try | about 110 | 60 (limit) | 0.14 USD | No report: it kept exploring. |
| After the fix | 42 | 25 | 0.016 USD | Full report with evidence. |
A second investigation started from Central, through the new API with a real Central token. It used the P2 alert "NIC errors on wg0". The agent found that the alert is false: the error counters did not grow. A manual check found the exact cause. The alert query groups the samples by labels but not by metric. Two metrics with the same labels then look like one counter that went from 0 to 3. This is a bug in the alert scripts, not in the agent. It is not fixed yet.
The fix had two parts. The instructions now give a budget of 30 tool calls. If a run reaches the iteration limit, Atlas asks once for the report.
Problems found and fixed on the way
- Atlas refused every Flow callback with 403, because the Flow server calls back as a guest. Atlas now allows that one path. Flow checks its own token there.
- Flow has its own
run_actiontool. The Atlas tool is nowrun_desk_action. - The bench loaded Atlas and Central from older worktrees. It now loads
apps/atlasandapps/central. Both old worktrees were already merged.
Next
- Review the diff and split it into commits.
- Compare DeepSeek and GLM on the same problems.
- Decide whether Central needs its own agent, or only the two tools on its assistant.
10. Decisions
- Who can change things. Only an Atlas engineer, in an Atlas desk session, and only after approving the call. Central investigations never get gated tools.
- What Central receives. The whole investigation: summary and full transcript, with credentials masked.
- What the scrubber masks. Credentials only. IP addresses and host names stay.
- Read-only commands. Allowed without approval in both agents, through the allow-list parser.
- Embedding model.
openai/text-embedding-3-smallthrough OpenRouter. - Telemetry access. A read-only ClickHouse user on Datum for
query_telemetry. - Log access. SSH from Atlas for data not in Datum. A metald log route can come later if needed.
Sources
- Frappe framework:
frappe/flow(tools, agents, skills, knowledge base, approval). - OpenRouter models: model IDs checked on 28 October 2026.
- Atlas repository:
atlas/core/ssh.py,SSH Task,Metal Server Console,scripts/insights/,metal/internal/firecracker/jailer.go,atlas/auth/. - Central repository:
central/integrations/atlas.py,central/sso.py.