Skip to content

Agents

Agents

Every workspace has Norbius, an assistant inside the app. It reads, writes and starts automations through the same entry points as a person, with the permissions of the person it helps. Envoys are the same agent answering people on a channel such as WhatsApp or email.

Norbius answering which apps the Construction workspace provides.
Norbius describes the apps available in this workspace.

What an agent can do

Norbius works through the same entry points as a person, with the permissions of the person it helps. An envoy works the same way with its own policies. Within those permissions, an agent can:

  • Read records through the outputs and rows the policies grant, and answer questions about them.
  • Create, update and delete records through the same write checks as a form. A change a policy holds for approval waits like anyone's; an agent never decides an approval.
  • Start automations whose agent setting is 'confirm' after the person agrees. Scheduled and event-triggered automations run on their own; an agent does not create schedules.
  • Read and produce files: inspect documents, spreadsheets, images and voice notes people upload or send, and generate downloadable files (CSVs, SVGs, reports) through run_js.
  • Use host tools and MCP servers granted by capabilities.tools, capabilities.mcp, and workspace skills. Read-only browser research runs directly, live-tab page actions confirm once per conversation, parallel steps wait for open approval cards, and subagents never receive approval-gated tools.
  • Keep conversations. Each conversation in the app, and each chat or email thread on a channel, is saved with its turns, so it picks up where it left off.

The brief

src/agent/+agent.md tells Norbius what the business does and how to work: who it serves, what the models mean and which steps to follow. +agent.external.md is the brief for external members such as customers. A brief describes the work, never permissions: those come from policies.

<!-- src/agent/+agent.md (field-operations, opening) -->
# The field-operations workspace

You are Norbius, the general assistant of a dispatch and site-work business. Work flows one way:
a site holds job assignments, one dispatched day job each, carrying the work order and the
contractor it is linked to. Everything else hangs off an assignment.

## Whom you serve and what you are for

In the app you serve the people who run the work: controllers who dispatch it and review what
comes back, and contractors looking at their own jobs.

A workspace skill is a folder src/agent/skill/<name>/ with a +skill.md and optional scripts: know-how the agent loads when it needs it. src/agent/mcp/+<name>.mcp.ts declares a remote MCP server, which a policy grants through capabilities.mcp.

Envoys

An envoy is a record, not a source file. An administrator creates it in the app with a name, an audience, its policies and a task, then deploys it on a connection such as the workspace's WhatsApp number. Pausing the connection pauses the envoy.

  • private answers only senders whose phone number, email or handle matches a member. public answers anyone.
  • In a group chat, or with a sender it does not know, the envoy holds only its own policies.
  • In a direct chat with a known member, dm: 'union' adds that member's own permissions, and dm: 'envoy' keeps the envoy's policies, applied to that member.
  • Rate limits always count against the envoy.

In the field-operations template, contractors report on WhatsApp, and the envoy files their photos and progress under the field_ops_whatsapp policy.

What happens when it runs

  1. A contractor sends a photo and "done, tiles replaced" on WhatsApp.
  2. The envoy matches their phone number to a member and reads their jobs under the field_ops_whatsapp policy.
  3. It files the photo and marks the job completed. The same transform and effect run as when someone saves the form, and it replies with one line confirming the job.

Calling the model from code

An automation can ask a language model for a structured answer with ctx.ai.sys_2.infer. You declare the shape of the answer in output, and the call returns a value of that type.

// in src/automation/+portfolio_agent.automation.ts (portfolio-manager, shortened)
const view = yield* ctx.ai.sys_2.infer({
	label: 'market view',
	system: 'You are a portfolio strategist. Write plain prose; never invent a figure.',
	prompt: [
		`Today is ${ctx.today}. The book is valued in ${base}.`,
		`Net assets ${money(metrics.net_assets)}; cash ${money(metrics.cash)}.`,
		'The market, as the agent read it:',
		market.map((one) => `- ${one.label}: ${one.text.slice(0, 1200)}`).join('\n')
	].join('\n'),
	output: {
		kind: 'object',
		fields: { summary: { kind: 'text' }, market_view: { kind: 'text' } }
	}
});
// view: { summary: string; market_view: string }

This is the market view the portfolio-manager template writes each morning.

What happens when it runs

  1. The automation runs and builds a prompt from today's figures and what it read.
  2. The model drafts an answer and hands it in. If it does not match output, it is sent back with the problems until it does.
  3. The call returns { summary, market_view }, typed. The automation files it in the day's report.

prompt is required. system sets the model's role, files passes stored files, initial gives a starting draft, rules adds checks the answer must pass, steps caps how many turns it may use, and label names the transcript an administrator can read. tools: ['read'] lets the model read workspace records under the automation's policies.

model picks a class: 'default', 'fast' or 'strong'. The host maps each class to a model from its provider; an administrator chooses System 1 (ctx.ai.sys_1.decide) and System 2 (ctx.ai.sys_2.infer) models, allowed chat models and monthly spending limits in Settings → Organization. Every model reads images.

Spending limits are monthly, in US dollars: one for the whole workspace, a default for each member, and optional limits per policy.

Automations can call it with tools. A model's effect can call it without tools. Transforms, verdicts and pages cannot: a page starts an automation instead. ctx.ai.sys_1.decide answers quick choice or yes-or-no questions, and ctx.ai.embed turns text and files into vectors for search. An answer is a proposal: anything it writes still goes through the usual policies, checks and approvals.

An automation can also hand work to a system agent with ctx.ai.sys_2.task({ description, prompt }). It works on its own under the automation’s policies, with no person attending, and files its own results; it is refused anything that needs a person’s confirmation. An administrator turns system agents on or off and sets their spending limits in Settings, under Assistant.

Sending messages from code

Automations and model effects send on a channel in two ways. ctx.send(connection, { to, text, attachments }) sends one message to an address on that channel: a phone number, a WhatsApp group, a Slack or Discord channel, or an existing conversation. ctx.notify sends a notification to members by user, team or policy — delivering to their inbox and push devices, and with via also by email ('email') or on an active workspace channel (including envoy-paired accounts) at the handle on their profile.

// src/automation/+daily_report.automation.ts (a sketch on portfolio-manager)
import { automation, is_instance } from '@norbital-ai/bolt';

const INVESTORS_GROUP = '120363000000000000@g.us'; // the WhatsApp group's id

export default automation({
	description: 'Each morning, send the portfolio summary as a PDF to the investors group and to each owner.',
	on: [{ cron: '0 8 * * *' }],
	policies: ['portfolio_automation'],
	run: function* (_, ctx) {
		// the workspace's own WhatsApp account
		const { sys_integration } = yield* ctx.query({
			sys_integration: {
				where: { integration: { eq: 'whatsapp' }, active: { eq: true }, owner: { is_null: true } },
				fields: ['integration'],
				limit: 1
			}
		});
		const [account] = sys_integration.rows;
		if (account === undefined || !is_instance('whatsapp', account)) return;

		// today's report record, printed as its own view (+representation.svelte)
		const { report } = yield* ctx.query({
			report: { where: { for_date: { eq: ctx.today } }, fields: ['id'], limit: 1 }
		});
		const [today] = report.rows;
		if (today === undefined) return;
		const pdf = yield* ctx.convert.record('report', today.id, {
			to: 'pdf',
			name: `Report ${ctx.today}.pdf`
		});

		// one message with the PDF to the group
		yield* ctx.send(account.id, {
			to: INVESTORS_GROUP,
			text: `Portfolio summary for ${ctx.today}`,
			attachments: [pdf]
		});

		// each portfolio owner's inbox, and their own WhatsApp number
		yield* ctx.notify({
			title: 'Daily portfolio summary',
			to: [{ policy: 'portfolio_manage' }],
			via: [account.id],
			attachments: [pdf]
		});
	}
});

A daily report as a PDF, sent to the investors' WhatsApp group and to each portfolio owner. This is a sketch on the portfolio-manager template.

What happens when it runs

  1. At eight each morning the automation finds the day's report record.
  2. ctx.convert.record prints its view as Report 2026-11-13.pdf. ctx.send queues one message with the PDF to the investors' group.
  3. ctx.notify puts a notice in each portfolio owner's inbox and sends it to their own WhatsApp number. Both go out once the run finishes saving.

Attachments are stored files, or a record printed for this delivery. ctx.convert.record prints a record as the workspace shows it, its own view, to a PDF when +workspace.ts declares convert: { to: ['pdf'] }; the PDF is not stored. A notice can also convert at delivery: { document: { markdown }, to: 'pdf', name }.

A send is queued and goes out after the run's writes are saved. The returned message id means it was queued, not delivered: an account that is not paired yet keeps the message until it connects. Save the id on your record if you need to show whether it was sent.