# Overview What SAGE is, and where it runs. SAGE runs AI agents as durable processes. An agent is a model in a loop that calls typed operations as its tools, enables skills when a task needs them, and can have an identity of its own. It hibernates while it waits, hands work to sub-agents, and wakes on messages, triggers or rules over what it knows, without polling a model. People and agents plan the work in shared specs, which record who decided what and can be checked against the code. Four words carry the section: - An **operation** is a typed action that an app defines once, for its UI and for agents alike. - A **skill** is a set of instructions with the operations that one kind of work needs. - A **trigger** is an object that starts an operation on a schedule or an event. - A **spec** is a text that says what a piece of software should do, for people and agents both. ## Where SAGE runs Composer is the workspace app that DXOS builds on this stack. Its assistant is the chat panel where a person works with a model. | Where | What runs | Page | | ------------------------ | --------------------------------------------------------------------------- | ------------------------------------------ | | Composer's assistant | Chats in a space, with the skills and objects a person adds to them | [Agents](/docs/sage/concepts/agents/) | | Agents on EDGE | An agent's chats and triggers, while every device is offline | [Agents](/docs/sage/concepts/agents/) | | The MCP server | A space's operations and skills, for any MCP client such as a coding agent | [MCP](/docs/sage/concepts/mcp/) | Each action an agent takes is an [operation](/docs/edge/concepts/operations/), run as a [process](/docs/edge/concepts/processes/). An agent's chats and memory are objects in the user's spaces, so they sync, and the user can read and edit them like anything else they own. A chat names the model it uses, hosted or local. An agent that runs on EDGE uses a hosted one. ## Where to go next Read [Why SAGE?](/docs/sage/why-sage/) for what sets its agents apart, then [Agents](/docs/sage/concepts/agents/) for how one runs. --- # Why SAGE? What sets SAGE's agents apart from other agent frameworks. Most agent frameworks give a model tools, a memory store and a loop that runs while a request is open. If you have called an LLM API with tools, you have written that loop yourself. SAGE runs an agent as a durable process. The agent hibernates while it waits and wakes on events without asking a model. It hands work to sub-agents and picks up when they report back. It can have an identity of its own, apart from the person who asked. ## The pattern Suppose you ask an agent to prepare next week's board meeting. It writes a plan, hands the research tasks to three sub-agents and ends its turn. The sub-agents run as child processes. When each one finishes, the agent wakes, reads the result, ticks off the task and posts what it found. Nobody kept a request open, and the agent did not poll a model to check on them. ## An agent framework against SAGE | | Typical agent framework | SAGE | | ------------------------- | ------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | | How long a task can run | While the request or the session is open | As long as it takes: the process hibernates and resumes, on a device or a server | | What wakes the agent | A message, or a scheduler that calls the model to check | A message, a trigger, a sub-agent finishing, or a rule over facts that matches | | Who made a change | The user's account, or an API key | The agent's own identity when it has one, apart from the person who asked and from other agents | | Where tools come from | Functions written for the agent | The app's typed operations, the same ones its UI runs, with hints on what they change | | How tools reach the model | Usually every tool's schema in the prompt | The tools of the skills the task needs, or one `eval` tool in code mode | | What the work is held to | A prompt or a ticket | A spec that records who decided what, and reviews that check the code against it | ## Practical problems ### Work that outlives a session A loop that runs inside a request ends when the request or the session closes. In SAGE, an agent's work runs as a process. While it waits on a timer, a person or a sub-agent, the process is written to storage and dropped from memory. It then resumes where it left off. On a server that is always online, the agent keeps going after every device is closed. See [Agents](/docs/sage/concepts/agents/). ### Knowing which agent changed what When several agents and people work on the same data, a change made by "the user" says little. A SAGE agent can have an identity of its own, which EDGE creates. A space can then admit the agent as a member under its own DID, apart from the person who asked and from other agents. See [Agents](/docs/sage/concepts/agents/). ### Waking without polling a model An agent that checks for new work by calling a model every few minutes is slow and expensive. SAGE's agents can hold goals written as rules over facts. The rules are evaluated as facts arrive, and the agent wakes only when one matches. See [Memory](/docs/sage/concepts/memory/). ### One set of actions for people and agents When an agent needs its own API, you build every feature twice. In SAGE, an agent's tools are the app's operations. The button, the command palette and the agent call the same key. The schema that labels a form also tells the model what to pass. See [Operations as tools](/docs/sage/concepts/tools/). ### Memory the user owns A memory that only the agent can read is hard to check and hard to correct. An agent's chats, the memories it writes and the facts it extracts are objects in the user's own spaces, beside the data they are about. They sync to the user's devices and the people they share with, and the user can read, edit and delete them. See [Memory](/docs/sage/concepts/memory/). ### A plan that people and agents both hold A prompt says what to do once. A spec says what the software should do, in text a person reads and an agent acts on. The spec's changelog attributes every decision to the person or the agent that made it. A review records how far the code meets each item. The spec's tests are steps that a person can follow and an agent can run. See [Specs](/docs/sage/concepts/specs/). ### A long task in a few model calls Calling one tool per step sends every result back through the model. In code mode, the model writes one short program that queries, loops and calls operations. Only what the program prints comes back, or the value it returns when it prints nothing. See [Operations as tools](/docs/sage/concepts/tools/#model). ### Choosing the model Different work suits different models, and some prompts should stay on the user's device. A chat names the model it uses, and a resolver finds a provider that serves it. The provider can be hosted, or it can be a model running on the user's own device. See [Models](/docs/sage/concepts/models/). ## What SAGE does not do SAGE does not train or host models. It calls them. It also does not run the work itself, which EDGE's [Compute](/docs/edge/concepts/compute/) does. Each tool call is an operation, run as a [process](/docs/edge/concepts/processes/). ## Next [Agents](/docs/sage/concepts/agents/) shows how an agent runs. --- # Models The model an agent uses, and how DXOS picks and calls it. SAGE calls models through one service, `AiService`. An agent, Composer's assistant and an operation that needs a model all ask for one the same way. The caller names a model, and the service finds a provider that serves it. ## Model A model SDK ties a model to the vendor that serves it, in one package with one API key. SAGE separates the two. **Models and providers.** A **model** has an id, which is a DXN in its developer's namespace. A **provider** is who serves the model: EDGE for hosted models, or a local server. Several providers can serve the same id. Each pairing has its own back-end name and characteristics, such as the context window and whether the model accepts images. | Provider | Serves | | --------- | --------------------------------------------------------------- | | EDGE | Hosted models, such as Claude, through EDGE's AI service | | Built-in | Local models on a server Composer manages, on the user's device | | Ollama | Local models on an Ollama server the user runs | | LM Studio | Local models on an LM Studio server the user runs | **`AiService`.** If your operation needs a model, it declares `AiService` and asks it for a model by id. The service returns a layer for that model, which is the Effect value that supplies it. The operation provides the layer to its model calls. EDGE's AI service is a different thing. It is the EDGE service that calls hosted models, and it stands behind the EDGE provider. **Resolution.** A **resolver** maps a model id to a provider that can serve it. Resolvers are chained. A resolver serves the models it knows, and passes the rest, or any it fails to reach, to the one below it. By default the provider is EDGE, so a local resolver can sit in front and fall back to EDGE. **Kinds of model.** The service resolves language models, which hold a conversation. It also resolves decision models, which pick from a fixed set of answers, and extraction models, which pull structured facts from text. ## Behavior - A chat records the model it uses. If you change it, the change applies from the next turn. - Calls through EDGE are made with the space's access to EDGE, so a person needs no API key of their own for hosted models. - A local model keeps prompts on the device, but works only while the device and its model server are running. Agents on EDGE use hosted models. ## Limits - A call sends the model the chat, the agent's instructions and skills, and the content of every object the agent reads in that turn. A hosted model's provider receives all of it. - When telemetry is on, each model call is recorded with its model, timings and token counts. - A model that no resolver in the chain serves fails to resolve. The caller gets `AiModelNotAvailableError`, not a different model. --- # Agents A model in a loop, acting in a space, with an identity of its own when it is given one. An agent is a model in a loop. Each turn it reads the chat, calls operations, reads their results and answers. A SAGE agent runs as a durable process, so it keeps going while no one is watching, and it can have an identity of its own. ## Model SAGE runs the loop as a process, and keeps the agent and its chats as objects in the space: - An **agent** object holds a name, instructions, the skills it starts with, and a switch that turns its automation on or off. It can also hold the DID of an identity. Its chats are children of it in the space. - A **chat** is the conversation an agent works in. It holds a feed of messages, the model and settings for the session, the skills enabled in it, the objects added to it, and the tasks of the agent's plan. A chat with no agent is a plain chat, such as one with Composer's assistant. The assistant is the chat panel in Composer, where a person works with a model directly. ### Turns A chat runs as an agent [process](/docs/edge/concepts/processes/), and a message is input to that process. A **turn** is what the process runs for that message. In a turn, it calls the model, invokes the [operations](/docs/sage/concepts/tools/) the model asks for, feeds the results back, and repeats until the model answers. Between turns the process is idle. It hibernates while it waits on a timer or a sub-agent. The diagram follows one turn from top to bottom. Each column is a party to the turn, and each arrow is a message or a call: ### Identity An agent can have a HALO identity of its own, named by a DID. EDGE creates the identity, and the agent object records the DID. Composer asks for one when it creates an agent only while its "Create identities for agents" setting is on, and the setting is off by default. With an identity, the agent owns a space of its own, and an admin can admit it to a shared space as a member, as they would a person. The DID lets content name the agent as its author, apart from the person who asked and from other agents. See HALO's [Identities and devices](/docs/halo/concepts/identities-devices/). An agent's identity is not an agent device. An agent device is a device of a person's identity, of kind `agent-managed`, whose key EDGE holds. See EDGE's [Identity services](/docs/edge/concepts/identity-services/). ### Delegation **Delegation** is an agent handing tasks in its plan to sub-agents. Each sub-agent runs as a child process, and the parent's turn ends when its own reply is done. When a child finishes, the parent wakes, reads the child's result, updates the task and posts what it found. ### Outside loops An agent loop from elsewhere, such as the Claude Agent SDK, can run in a **host**, which is a local Node process on a device. It brings its own tools and loop, and DXOS keeps its output as messages in the chat's feed, like any other agent's. ## Behavior - By default, an agent's chats run on EDGE, so it answers messages and fires its triggers while every device is offline. A plain chat runs in the app. - An agent sees the objects added to its chat and anything it can query in the space. It changes them only through operations. - If you turn an agent off, its triggers turn off too. ## Limits - An agent can do only what its operations do. If no operation it can reach changes a kind of object, the agent cannot change it. - An agent without an identity has no DID. No space can admit it as a member, and nothing can name it as an author. - An outside agent loop runs only on the device that hosts it, and only while that device is online. - An agent on EDGE uses a hosted model. Local models are reachable only from the device that runs them. See [Models](/docs/sage/concepts/models/). --- # Operations as tools How an agent sees and calls the operations a person would. An agent's tools are operations. The schema and description that tell a person what an operation does tell the model too. When your plugin defines an operation, you write no separate tool for agents. An agent gets the operation once a skill lists it. ## Model Your app has a "mark as read" action behind a button. What does it take for an agent to call it? A tool needs a name, a description and a schema for its parameters. An **operation**, the typed action behind the button, has all three. **From operation to tool.** Each part of the operation becomes a part of the tool: - Its key becomes the tool's name. - Its description becomes the tool's description. - Its input schema, with each field's description, becomes the tool's parameters. When the model calls the tool, the invoker checks the input against the schema and runs the handler, the same way it does for a button. See EDGE's [Operations](/docs/edge/concepts/operations/). **Which tools a turn has.** A turn is one round of the agent's loop, and it does not get every operation in the space. It gets the operations named by the [skills](/docs/sage/concepts/skills/) enabled in the chat, plus the tools of the chat's MCP servers. An agent finds more by searching the operation registry for a skill that covers the task and enabling it. **Code mode.** In **code mode**, the model gets one tool, `eval`. It does its work by writing a short program against the **workspace**, which is the space and the operations the program can reach. The program holds queries, operation calls, loops and conditions. By default, Composer's agents run in code mode. The program runs in a sandboxed browser worker with its own ECHO client. Only what the program prints comes back to the model. If the program prints nothing and returns a value, that value comes back instead. A task that would take twenty tool calls, each sending its result back through the model, is one program. | | Tool calling | Code mode | | ------------------------ | ------------------------------- | ---------------------------------------------------------------------- | | Tools the model sees | One per operation in its skills | One, `eval` | | What comes back | Every call's full result | What the program prints, or its return value if it prints nothing | | A loop over many objects | One tool call per object | One program | | An error | A failed tool call | The output so far and a short error, so the model can rewrite the code | ## Behavior - An operation's mutation hint goes with the tool. The hint says whether the operation changes nothing, writes, or destroys data, so the app that runs the agent can ask before a destructive call. - Results that are ECHO objects come back as references with their type and label, so the model can pass them to the next operation. - Use `dx eval` to run a code-mode program from the command line. `dx eval --instructions` prints the API the program is written against. ## Limits - A model sees only an operation's schema and description. An operation without a clear description is hard for an agent to use well. - In code mode the output is cut at 8,000 characters, so a program should print a summary, not every object. - In Composer, code mode needs its sandbox module and an ECHO client for the browser worker to connect to. If the module fails to load, or the app has no client, the agent falls back to tool calling. It never runs the code in the page. --- # Skills Instructions an agent loads when a task needs them. A skill teaches an agent one kind of work. It holds instructions for how to do the work and the [operations](/docs/sage/concepts/tools/) the work needs. A chat enables only the skills its task calls for, so the model's context holds those and nothing else. ## Model One system prompt and one list of tools for a whole app grow with every feature, and the model reads all of both on every call. Skills split the prompt and the list by kind of work. A **skill** is an ECHO object with a name, a description, instructions and a list of tools. - The instructions are a template, so they can include the current date or details of the objects in the chat. - The tools are the operations, by key, that the agent gets while the skill is enabled. The format follows the open [Agent Skills](https://agentskills.io/specification) specification, so a skill means the same in DXOS as in other agent tools. **Where skills come from.** A PLEX plugin contributes skills alongside its operations, so installing a plugin gives agents both the actions and the instructions for using them. See PLEX's [Operations](/docs/plex/concepts/operations/). A person can also write a skill in the space, as an object like any other. **Enabling a skill.** To **enable** a skill is to switch it on for one chat. The chat's model calls then load the skill's instructions and tools into the model's context. A person enables skills in a chat, and an agent starts with the skills its instructions name. A type can also name the skills a chat about one of its objects should have. For example, a chat opened beside a project starts with the project skills. ## Behavior - An agent can look up skills during a turn and enable one it needs, if the skill allows agents to enable it. - A skill enabled in the middle of a turn applies from the next model call, with its operations and instructions. - A skill marked for MCP is served by the [MCP server](/docs/sage/concepts/mcp/) as a prompt, and its operations become reachable there. ## Limits - A skill holds no secrets, such as API keys, and no MCP server connections. Those belong to the space, and each chat can turn them off. - A turn lists only the operations of the skills enabled in its chat. If no skill lists an operation, the agent has to search for it, and over MCP it cannot be reached at all. --- # Specs The contract people and agents both work from, with what to build, who decided it, and how far the code meets it. A spec says what a piece of software should do, in text that a person can read and an agent can act on. It records who decided each part, people and agents alike. It can also be checked. A review says how far the code meets each item, and the spec's tests are steps that a person can follow and an agent can run. ## Model A prompt tells a model what to do once. A spec stays, and the next person or agent to work on the software reads the same text. **The language.** A spec is a `.mdl` file in DEUS, a specification language for people and agents working together. The body is Markdown prose. Fenced `mdl` blocks carry the parts that need structure: types, operations, features with numbered requirements, and tests. Simple requirements stay as prose. The block types are themselves declared in DEUS, so a project can add its own. The language and its tools are in `@dxos/deus`. **The changelog.** Every change to a spec is a **decision** in its changelog. A decision says what is now true, the day it was made, why, and who made it. The author is written as `user:` for a person, or `agent:` for an agent, with the person it acted for. A choice nobody has made yet is a question, which a later decision answers. When you read the changelog, you can tell which parts of a spec a person decided and which an agent proposed. **Reviews.** A **review** reads the code at one commit and gives each spec item a verdict, with the code it read as evidence: | Verdict | Means | | ---------- | ----------------------------------------- | | `done` | Built as specified | | `untested` | Built, but no test covers it | | `partial` | Built in part | | `diverged` | Built differently from what the spec says | | `missing` | Not built | A spec's history is its reviews, and an item's current status is its newest verdict. **QA tests.** A test is a list of steps, each with what to do and what to expect. A person can follow it by hand. An agent runs the same test by invoking one operation per step and judging the result against the same expectation. ## Behavior - In Composer, a spec is an object in a project, with its reviews kept beside it. It syncs both ways with a `.mdl` file on disk or in a GitHub repository, so you can edit it in Composer or in your editor. - The Spec Review skill lets an agent review a spec against the code and record the result as a review. - The `deus` command line lints a spec and checks that every feature in a feature map cites a real spec item. - The editor highlights, completes and lints `.mdl` text as you type it. ## Limits - A review is an agent's or a person's judgement of the code, not a proof. Its verdicts are as good as the evidence it cites. - A spec is the source of truth only while people keep it current. A decision made in a chat and never recorded in the changelog is lost to the next reader. --- # Memory What an agent keeps between turns, as ECHO objects the user can read. An agent remembers by writing objects: its chats, the memories it keeps and the facts it extracts. The objects are stored in the space beside the user's own data. They sync to members, show up in queries, and can be read, edited and deleted like anything else the user owns. ## Model A model keeps nothing between calls. Whoever calls it has to store the conversation and send it again each time. SAGE stores it in the space, as a chat. **Chats.** A **chat** is the conversation an agent works in, and its messages are a [feed](/docs/echo/concepts/feeds/) in the space. Each turn appends the person's message, the model's reply and every operation call with its result. A process that stopped and resumed rebuilds its context by reading the chat. **Memories.** A **memory** is a small object with a title and content. It holds something the agent learned and wants to keep, such as a preference or a decision. An agent writes memories through an operation and finds them again with a query. **Facts.** A **fact** is a statement read from text that passes through the space, such as messages, email or transcripts. It says who said what about whom, and when. Each fact keeps the source it came from, so an agent can show why it believes something. **Goals.** A **goal** is something an agent watches for or works toward, such as "when someone in this chat asks for a review, start one". An agent holds its goals as rules over those facts, and the rules decide when the agent wakes. A goal fires when a new fact matches it, when it is achieved, or when one of its sub-goals changes state. ## Behavior - Memory is shared with the space. Every member can see the agent's chats and memories, and so can every agent in the space. - The rules that wake an agent run on EDGE, beside its process, so a new fact can wake an agent while every device is offline. - If you delete a memory or a message, it is gone from what the agent reads next. ## Limits - An agent's chats and memories are as private as the space they are in. Keep work that should not be shared in a space of its own. - In a turn, an agent sends a model a selection of its memory, not all of it. A long chat can be summarized or cut to fit the model's context. --- # MCP Reaching a space's operations and skills from any MCP client. The [Model Context Protocol](https://modelcontextprotocol.io/) lets an agent outside DXOS, such as a coding agent, use a space. The DXOS MCP server serves the space's [operations](/docs/edge/concepts/operations/) and skills to any MCP client. In the other direction, an agent inside DXOS can connect to outside MCP servers and use their tools. ## Model An MCP server usually lists one tool for each thing it can do, and the client loads every schema. The DXOS MCP server serves three tools, however many operations the space has: | Tool | Does | | ----------------- | ------------------------------------------------------------------------ | | `queryOperations` | Searches the operations by text, skill or key, and returns their schemas | | `invokeOperation` | Runs one operation by key, checking its input and resolving the space | | `loadSkill` | Returns a skill's instructions, or lists the skills when given no name | The client searches for the operations a task needs. It is not handed a schema for every one, so its context stays small as plugins add operations. A **skill** is a set of instructions with the operations one kind of work needs. Each skill marked for MCP is also served as an MCP prompt. **Where it runs.** Use `dx mcp serve` to run the server on a device, against the profile's spaces. EDGE runs it too, so a client can reach a space with no DXOS device online. Both serve the same tools and prompts, built from the same operation registry. **Outside MCP servers.** A space can hold connections to outside MCP servers. A chat connects to them at the start of each turn, and their tools join the agent's operations. Each chat can turn a connection off. ## Behavior - An operation is reachable over MCP only when a skill marked for MCP lists it. - `queryOperations` returns one row for each operation it finds. The row says whether the operation changes nothing, writes, or destroys data, so the client can ask before a destructive call. - Writes over MCP replicate to members like any other change. ## Limits - When the MCP server runs on EDGE, it needs the space to give EDGE more than `pull` access, the lowest access level. See HALO's [Spaces and membership](/docs/halo/concepts/spaces-membership/). - An outside server's tools run on that server. DXOS checks their input against the schema the server gives, and nothing more. --- # Glossary Every SAGE term, defined once. Compute terms, such as operation, process and trigger, are in EDGE's [glossary](/docs/edge/resources/glossary/). ### Agent An agent is a model in a loop that acts in a space. Its work runs as a process, and it can have an identity of its own. It is not HALO's agent device, which is a device of an identity whose key EDGE holds. See [Agents](/docs/sage/concepts/agents/). ### Assistant The assistant is the chat panel in Composer, where a person works with a model directly. Its chats have no agent. ### Chat A chat is the conversation an agent or the assistant works in. It holds a feed of messages, and the model, skills and objects for the session. ### Code mode Code mode is a way of running a turn in which the model has one tool, `eval`. The model writes a program against the [workspace](#workspace) instead of calling one tool per action. See [Operations as tools](/docs/sage/concepts/tools/). ### Decision A decision is an entry in a spec's changelog that says what is now true, and who decided it: a person or an agent. See [Specs](/docs/sage/concepts/specs/). ### Delegation Delegation is an agent handing a task to a sub-agent, which runs as a child process and reports back when it finishes. ### [Fact](/docs/sage/concepts/memory/) A fact is a statement extracted from text in the space, such as who said what and when. It is kept with the source it came from. ### Goal A goal is something an agent watches for or works toward. The agent holds it as rules over [facts](#fact), and the rules decide when the agent wakes. ### Host A host is a local Node process that runs an agent loop from outside DXOS, such as the Claude Agent SDK, and writes its output into a chat. ### Instructions Instructions are the text that tells a model how to behave. A turn carries the agent's own and those of each enabled skill. ### [MCP](/docs/sage/concepts/mcp/) MCP is the Model Context Protocol. DXOS serves a space's operations and skills over it, and agents use outside servers' tools through it. ### Memory Memory is what an agent keeps between turns, as ECHO objects: its chats, the memories it writes, and facts. ### [Model](/docs/sage/concepts/models/) A model is the AI system a turn calls, such as a language model. It is named by an id that several providers may serve. ### Provider A provider is whoever serves a model: EDGE for hosted models, or a local server such as Ollama. ### Resolver A resolver maps a model id to a provider that can serve it. Resolvers are chained, so one that cannot serve a model passes it to the next. ### Review A review is a judgement of how far the code at one commit meets each item of a spec, with the code as evidence. See [Specs](/docs/sage/concepts/specs/). ### [Skill](/docs/sage/concepts/skills/) A skill is a set of instructions with the operations a kind of work needs. A chat enables it when the task calls for it. ### [Spec](/docs/sage/concepts/specs/) A spec is a `.mdl` document that says what software should do, for people and agents both. It carries its decisions, reviews and tests. ### Tool A tool is what the model calls during a turn. In DXOS a tool is an operation, or a tool of a connected MCP server. ### Turn A turn is one round of an agent's loop: the model's calls and their results, until it answers. ### Workspace A workspace is what a code-mode program runs against: a space and the operations the program can reach. --- # llms.txt The SAGE site map and full text for agents, in the llms.txt format. Point an agent at these files before asking it to work with SAGE. They follow the [llms.txt](https://llmstxt.org/) format and cover every written page of this section. | File | Contents | | -------------------------------------------- | ---------------------------------------------------------- | | [`/sage/llms.txt`](/sage/llms.txt) | Each SAGE page with its summary and a link to its Markdown | | [`/sage/llms-full.txt`](/sage/llms-full.txt) | Every SAGE page in one file | Any page is also served as Markdown at its URL with `.md` in place of the trailing slash.