OpenLegion · Docsllms.txt
Docs pages

Template spec

A template version is what POST /templates/{slug}/versions takes, and what npx openlegion templates push sends. Each version is immutable: to change a template, push a new version, then promote it. This page has the rules for each field, in the order of the spec's schema. The API reference has the request's full shape.

The agent's fields: name, role, soul, instructions, model_tier, tools, schedules, core_blocks, max_concurrent_runs

A template seeds one agent from these fields at the top level, or several from agents, whose items take the same fields plus a key (see agents). Not both: a version with top-level agent fields and agents is refused (400 parameter_invalid, param: "agents"). The top-level agent's key is main.

  • name: the agent's display name, 1 to 80 characters. Absent: the template's name.
  • role: one line on what the agent is for, 1 to 200 characters.
  • soul: up to 4,000 characters.
  • instructions: up to 8,000 characters.
  • model_tier: the model preset the agent runs on: background, fast, reasoning or frontier. Absent: fast. A budget.run_credits above 0 must cover the floor of the highest tier among the template's agents (see budget).
  • tools: platform tool ids, at most 64, and at most 15 of them resident, e.g. agent.finish, memory.search. Platform tools lists every id, and its Loaded column says which kind each is. A resident tool's definition goes with every step of every run; OpenLegion keeps at most 15 resident, and they are agent.finish, agent.schedule, agent.note_to_user, memory.search, memory.timeline, memory.write_candidate, web.search, web.fetch, files.read, files.write, sandbox.run, sandbox.code_run, team.hand_off, team.ask and team.complete. Every other tool is deferred: a run starts with a short index that names it, a call by name runs from the first step, and its definitions are sent from the step after. A list past either number is refused (400 parameter_invalid on tools), naming both numbers and the resident tools it lists. Each is checked, and refused (400 parameter_invalid on tools[i]) if it isn't a platform tool, isn't available yet, or is a workspace-admin power (team.admin.*). One refusal names every id that was refused, on the first one's tools[i], with the nearest id that exists when one is close. A connector tool (mcp.…) is refused here too: declare it under connectors, and every agent is granted it. When policy_envelope.tools is present, every tool must be in it.
  • schedules: at most 20, each {key, cron, instructions, description?}.
    • key: unique within the agent: a lower-case letter, then up to 63 lower-case letters, digits, - or _. A later version updates the schedule with the same key. One the previous version wrote and a later version drops is cancelled. The agent's own schedules and your end customers' are never the template's to cancel.
    • cron: five fields, read in the workspace's time_zone.
    • instructions: what the agent is asked to do when the schedule fires, 1 to 1,000 characters.
    • description: up to 200 characters.
  • core_blocks: at most 8 (7 when customizable.instructions is set: the eighth is the end customer's), each {label, text}, written into the agent's core memory.
    • label: SOUL, INSTRUCTIONS, or your own: an upper-case letter, then up to 31 upper-case letters, digits or _. Never OWNER_INSTRUCTIONS, which holds an end customer's own instructions.
    • text: up to 4,000 characters.
  • max_concurrent_runs: at most this many of the agent's runs at once, 1 to 32, its own scheduled and inbound work included. Absent: 1, every run one at a time. One thread's runs are always one at a time, in order. Runs at once aren't on yet: the value is stored and checked now, and every run stays one at a time until they are. It can't be made customizable. A value above your plan's limit on runs at once is accepted: the plan's limit applies when runs start.

A template is written into every workspace's core memory, so a version holding anything shaped like a secret key, in any field, is refused (400 parameter_invalid, param: "body"). Agents get keys from the credential vault, never from their instructions.

agents

  • agents: several agents from one template, 1 to 10. Each item is {key, …} with the agent's fields (agent.md). Leave the top-level agent fields out when you use it: a version with both is refused (400 parameter_invalid, param: "agents").
    • key: the agent's handle across versions: a lower-case letter, then up to 31 lower-case letters, digits, - or _. Two agents may not share a key. Applying a later version to a workspace updates the agent with the same key in place, so its id, threads, memory and history stay. A key a later version adds is created, and one it drops is archived. A version that drops a key your end customers' created agents still follow is refused (409 template_agent_in_use), and nothing is applied.
    • blueprint: true (default false): the agent is a blueprint. No workspace gets it until one of your users makes one from it with POST /agents, so a starter can have its own tools, model_tier and schedules without being made for everyone. Its tools are the platform's; which of your own tools it gets is connectors[].tools.<name>.agents. A version is refused (400 parameter_invalid) when a blueprint is not in customizable.agents.creatable (agents[i].blueprint: nobody could ever make it), when every agent is a blueprint (agents: a new workspace would have no agent), or when a trigger names one (triggers[i].agent). A later version that makes an existing agent a blueprint archives the template's own agent in each workspace and keeps the ones your users made from it; the reverse makes it in each workspace.
    • The first agent that is not a blueprint is the default: a trigger without agent starts it, and an event no trigger matches is recorded on its inbound thread (see triggers).
    • A budget.run_credits above 0 must cover the floor of the highest model_tier among all the agents (see budget).

budget

  • budget.run_credits: the credits a run holds up front, in whole credits. Set it to what one run should spend. A run starts only when its workspace has that much under its caps and grants. Above 0 it must be at least the floor of the highest model_tier among the template's agents, or the version is refused (400 parameter_invalid on budget.run_credits, and the message names the floor). Absent or 0, a run holds the per-run ceiling of the dearest tier it may reach: the agent's model_tier or any tier its policy allows. The ceilings are background 10, fast 50, reasoning 250 and frontier 1,000 credits, so a fast agent that may escalate to reasoning holds 250, and a run that may use frontier holds 1,000 credits ($1.00) up front, many times what most runs spend. ol dev warns when it pushes a template that allows frontier with no budget.run_credits. A workspace's usage_period.run_credits_required says what its runs hold. Every model call in a run is sized to what the run's budget has left, so a run ends at its budget rather than past it.

    Or one budget per preset: a map, run_credits: { fast: 40, reasoning: 250 }. A run holds, and stops at, the entry of the preset it starts on, a person's pick (model_tier on a message) included. The rungs its policy allows add nothing (a template agent is pinned; an Auto run's step-up spends from the same entry). A preset left out, or at 0, holds its ceiling. Each key must be a preset an agent is on or a person may pick (customizable.model_tier.allowed), and each entry above 0 at least that preset's floor; otherwise 400 parameter_invalid on that entry (budget.run_credits.reasoning), naming the floor. A workspace's caps must cover the largest entry a person may pick, as they must the one number.

  • budget.agent_daily_run_cap and budget.agent_daily_credit_cap (optional): each agent's limits in any trailing 24 hours, in whole runs (1 to 10,000) and whole credits (at least 1). Without agent_daily_run_cap, a backstop against a runaway agent applies. Without agent_daily_credit_cap there is no per-agent money limit, and the workspace's caps bind. A run past either limit is refused (402 cap_reached), and its partner_message names the limit and the field to raise. A promote or re-pin applies a change.

default_limits

  • default_limits: {period_credit_cap?, daily_credit_cap?, cap_mode?, soft_overage_pct?}, the caps a workspace gets when it is created without any, in a workspace's own limit fields. A hard period_credit_cap above 0, or any daily_credit_cap, below one run's hold on the agents this version seeds is refused (400 parameter_invalid on that field), because it would refuse every run. A version pushed before this check is refused at POST /workspaces instead (param: "template").

policy_envelope

  • policy_envelope.tools: {<tool id>: {status, limits?}}, the outer bound on every agent's tools. When it is present, every tool an agent lists must be in it (400 parameter_invalid otherwise); when it is absent, every listed tool is allowed. An end customer can only tighten inside it.
    • status: allowed; held, where each call waits for a person's approval; or limited, where its limits become that tool's config, which its executor enforces.
    • limits: only for a limited tool.
    • limits.allowCredentials, which web.fetch and vault.request_credential read: the names of the workspace's saved credentials the tool may use. web.fetch sends one in a request header as {{cred:<name>}}, and vault.request_credential gives the agent a handle to one. Some secrets no tool opens by name, so naming one here refuses the version (400 parameter_invalid at policy_envelope.tools.<tool>.limits.allowCredentials[i], and the message says which kind it is): a connected account's own key, an app's OAuth client secret, a connected channel's own secret, the workspace's own model key, or one of the workspace's own system secrets (a trigger's or a webhook's). An agent uses a connected account only through its connection's tools (connectors.* or mcp.*). To call a model provider's API with your own key, save the key again under an ordinary name and list that name.
    • limits.sites and limits.personSites, which browser.open reads: the websites the agent's browser may open, each one with its subdomains (["example.com"]), and whether a person may add more. With personSites: true, an open of a website on neither list does not fail: it waits for a person's approval, a browser_site_grant approval titled "Let ‹agent› use ‹site› in the browser?". A person's Allow adds that website to the agent, for every conversation in the workspace, until someone removes it; "Not now" adds nothing, and the agent does not ask about that website again until a person writes in that conversation again. sites may be empty when personSites is true. The template's websites and the person's together are at most 50. A public suffix (co.uk, github.io), an IP address, a local name or one of OpenLegion's own hosts is never opened and never asked for.
      • This widens the agent. One person's Allow lets the agent open that website in every conversation, including other people's. Under the usual rule, a member may Allow a website their own conversation asked for. To keep that decision for owners and admins, set approver: "admin" on browser.open.
    • approver: requester (the default) or admin. Who may approve or reject a held call of the tool, besides the workspace's owners and admins: requester is the member whose conversation asked for it, and admin is nobody else. It goes with any status, because an allowed tool can still be held for its cost or for whom it reaches. It is read when a person decides, from the version the workspace runs then, so a new version that sets it covers the approvals already waiting. A member reading such an approval gets can_decide: false, and their decision is 403 insufficient_role.
    • A connector tool is keyed mcp.<slug>.<local>, and is allowed or held, never limited: its limits are your server's to enforce.

connectors

  • connectors: up to 10, each {connector: "con_…", tools?: {<tool name>: {trust?, effect?}}}. Every agent of the template is granted each declared tool, or only the agents the tool's agents lists; a tool not declared isn't granted. Each connector is listed once (400 parameter_invalid on a second entry). The tools must be pinned on that connector in your organization when the version is created. In policy_envelope.tools, a declared tool's id is mcp.<slug>.<local>.
    • trust, of its results: tool_verified (your own product's data) or web_low (text people outside your product wrote). Default web_low.
    • effect, of calling it: read, draft (nothing leaves your product), write (changes your product) or egress (reaches people or systems outside it). Default egress.
    • approval_title (optional, 1 to 200 characters): the sentence a person reads as the approval's title when a call of the tool waits for them, e.g. Email you "{subject}"?. Each {name} is replaced by that field of the call's input (text or a number, one line, at most 80 characters); a field the call left out is replaced by nothing. Without it the title is the tool's title and a question mark, or its name in words. The kit writes it from approvalTitle on defineTool.
    • approval_fields (optional, at most 20 names, none twice): the fields of the call's input that the approval shows up front, in this order. Every other field stays in the approval's fields, marked detail: true, for the card's details: the list moves facts and removes none. [] marks them all. Without it no field is marked. The kit writes it from approvalFields on defineTool.
    • agents (optional, 1 to 10 agent keys, none twice): the template agents that get this tool, and so the agents POST /agents makes from them. Left out, every agent gets it. An agent that is not listed is never offered the tool and a call of it is refused. A key that is not an agent of this version is refused (400 parameter_invalid on connectors[i].tools.<name>.agents[j]); a blueprint's key is allowed. A later version that changes the list takes the tool from an agent, or gives it, from that agent's next run. To give a tool to no agent, leave it out. The kit writes it from toolAgents on defineTemplate.

apps

Which catalog apps your workspace's users may connect, and which of your agents may use each one. At most 50 entries, each {app, agents?, tools?}:

  • app: a catalog app (GET /connector_catalog), or custom: your users may add MCP servers of their own by address, up to 10 a workspace. Every tool of such a server asks before it runs. Left out, nobody may.
  • agents: the template agents, by key (1 to 100), that may use the app, and so the agents POST /agents makes from them. Left out, every agent may.
  • tools: {<catalog tool id>: {allowed: true}}: those of the app's tools that run without asking first.

A version is refused (400 parameter_invalid) when:

  • apps[i].app is listed twice, or is neither in the catalog nor custom;
  • apps[i].agents[j] is not an agent of this version;
  • apps[i].tools names a tool that is not one of the app's, or any tool of a vendor_mcp app or of custom (their tools are their servers' own).

The list applies with the version. An app a later version drops stays connected and grants no agent.

A version that lists no apps grants no agent a connected account, and opens no connect session, until a version that lists apps is applied. A workspace on a version made before apps existed is in that state.

customizable

  • customizable (optional): what an end customer may change on the template's agents, and within which bounds. Absent: nothing. Every field is optional, and a field left out can't be changed. No list may repeat an entry.
    • name, role, instructions: {max_length?}, at most 80, 200 and 4,000 characters (the default and the ceiling). instructions are the end customer's own, added after the template's as one more core block (OWNER_INSTRUCTIONS, a label a template may not use); the template's soul and instructions are never replaced and never returned. With it, each agent has at most 7 core_blocks.
    • model_tier: {allowed: [tier, …]}: the presets an end customer may pick. When budget.run_credits is above 0, each must fit it, as the agents' own tiers do (400 parameter_invalid on customizable.model_tier.allowed[i]).
    • tools: {optional: [tool, …], labels?: {tool: label}}: tools an end customer may switch off. Each must be on some agent's tools, and is never agent.finish or a connector tool. Nothing can be switched on that the template agent doesn't list. labels names an optional tool in your product's words, 1 to 80 characters (a key not in optional is 400 parameter_invalid on customizable.tools.labels.<tool>). The version stores only yours; the agent and template agent objects carry a label for every optional tool, yours or the platform's plain-word default.
    • agents: {creatable: [key, …], max} and schedules: {min_interval_seconds, max, hours?: {from, to}, days?: [0–6]}: applied by POST /agents, the schedule routes and the agent's own schedules (agent.schedule). Every creatable key is an agent of this version. agents.max (the agents an end customer may create in a workspace), schedules.max (unfinished schedules per agent, whoever made them) and min_interval_seconds each have a platform bound, and a value past it is 400 parameter_invalid. hours is a window within one day (from before to, in the workspace's time zone), and days are 0 = Sunday … 6 = Saturday.

A version stored before this shape (any map, or the old spelling customisable) customizes nothing; everything else in it still applies. One stored as min_interval_minutes reads as min_interval_seconds, × 60, and one stored with max_count as max.

triggers

  • triggers: which inbound events (POST /inbound_events) start which agent, at most 20, [{type, agent?, filter?: {where: [...]}}]. They are tried in order: the first trigger that matches starts a run of its agent, once. type is an exact type, a family (order.*) or *. agent is a template agent's key (default: the first agent); a key the template doesn't have is refused. where holds up to 10 conditions on the event's data. An event no trigger matches is recorded on the agent's inbound thread, and the agent reads it on its next run.

default_subject_role

  • default_subject_role: member (the default) or admin. The role a person your server names in OpenLegion-Subject gets the first time they act in a workspace. After that the header keeps whatever role they have; a session (POST /sessions with role) sets it. Never owner: a version that says owner is refused (400 parameter_invalid on default_subject_role), and only a session can make an owner.