Cairnmind
Core Workflows 37 min read Source: docs/API.md ↗

API, Models & Connections

Local knowledge service HTTP API, Ollama and OpenAI-compatible model profiles, Copilot SDK connections, sensitivity classes, and third-party MCP tools.

cairnmind opens the project's terminal workspace. A named connection defines the client, the model and the limits, and a project assistant uses one of those connections. You can assign several assistants to a project and explicitly start the one you want. Cairnmind's own agent handles direct APIs; Copilot has a separate adapter built on the official Python SDK. The interface is in English by default; More → Settings → Language → Polski switches it to Polish.

Available connections

Profile Protocol / sign-in Available models
Codex CLI Native client with its own ChatGPT sign-in or key configuration Models supported by the installed Codex
Claude Code Native client with its own sign-in / configuration Models supported by the installed Claude Code
OpenAI API Responses API, separate API key Provider's model list or an explicit model ID
Anthropic API Messages API, separate API key Provider's model list or an explicit model ID
OpenAI-compatible API Chat Completions API with a custom base URL Server's model list or an explicit model ID
Ollama Local /api/chat and /api/tags Models installed on the selected Ollama instance
GitHub Copilot Official SDK and a Copilot account / entitlement Models available to that account

A ChatGPT subscription, a Claude subscription, GitHub Copilot access and direct API access each have separate sign-ins and billing. Choosing a Claude model in Copilot uses the Copilot connection and the Copilot quota. An OpenAI API profile does not automatically inherit ChatGPT subscription entitlements. GitHub Models is a different service from the Copilot adapter.

Cairnmind's own coding agent requires a model that supports tool calling. An embedding model is not such an agent. A missing model or missing tool support is reported explicitly; Cairnmind never switches providers in the background.

Setting up a connection in the terminal

  1. Run cairnmind, open Connections and choose Add connection. The menu is also available via Ctrl+B, then Space.
  2. Pick the connection type, give it a name and enter the model. Enter a custom base URL for an OpenAI-compatible API. Limits, USD rates and key references live under Advanced limits and credentials. Save forms with Ctrl+S; a validation error does not discard the values you entered.
  3. In the named connection's menu, choose Connect account, Connect GitHub account or Set API key, as appropriate for the provider. Codex and Claude Code keep their own sign-in procedures. Check connection shows the locally available state; for Copilot it does not confirm a working account session.
  4. Choose model can fetch metadata from the provider and save the selected model. It does not start a conversation or edit the project.
  5. Test model and tools is a separate request that you confirm explicitly. It may consume paid tokens or account quota; the test does not edit the project.
  6. In the project list, Enter opens the project preview. On the project screen, choose an assigned assistant or Add assistant, then Start work. Only the selected assistant starts. Start work in the global menu first shows the project screen for confirmation.

Opening the terminal UI, selecting a profile and restoring a view do not generate any model response. A running API panel restores the local history; the model starts working only after you send a message. A profile change takes effect on the next start; an existing process keeps its configuration.

When the service is started from the terminal UI, memory tasks that need a local model wait for Start work or More → Queue → Process memory. This action enables the queue for the selected project only. It does not start the queues of other projects. Process memory also lets you resume memory processing on its own after a connection error, without restarting the assistant. Services and sessions that were already running continue working.

The default base URLs are https://api.openai.com/v1, https://api.anthropic.com/v1 and http://127.0.0.1:11434 for Ollama. A custom URL must not contain a password, a key or query parameters. Remote connections require HTTPS; plain HTTP is allowed only for loopback/localhost addresses. Do not disable TLS verification to work around a corporate certificate problem.

Keys and environment variables

Set API key opens an empty, masked field. A saved key is never displayed again. By default the key is kept in the memory of the current broker process and stops being available when that process exits. Simply detaching the terminal does not stop the broker.

The Remember on this computer option is off by default. It stores the key in the private file credentials/api-keys.json in Cairnmind's local data directory. The directory has 0700 permissions and the file 0600 (owner-only NTFS DACL on Windows); the file is not encrypted. It is never included in the knowledge base, the administrative export or a project snapshot. Removing a locally stored key is a separate action in the connection menu.

Instead of storing a key, you can enter a reference of the form env:VARIABLE_NAME in the connection's advanced settings, for example env:OPENAI_API_KEY. The variable must be visible to the broker process that runs the workspace. Changing the variable in a new shell does not update a broker that is already running. Keys are not passed to system commands executed by the agent.

Full conversations and command output may contain private data. Before conversation text is indexed or given to extraction, Cairnmind replaces known secrets in it with [REDACTED]: in imported Claude Code and Codex transcript lines, in archived events of the built-in agent, in remember notes (from /remember, an external session's report and cairnmind remember), and in session findings, checkpoints and tasks added with cairnmind task add. Replaced are, at least 8 characters long, the service token, the ArcadeDB password, the keys saved in the credential store, the values behind the env: references of the saved connection profiles and memory model profiles, and the credential variables of the service's environment (OPENAI_API_KEY, ANTHROPIC_API_KEY, GH_TOKEN, GITHUB_TOKEN and the others it keeps from commands, and any name ending in _API_KEY, _AUTH_TOKEN or _GITHUB_TOKEN); a piece of at least 12 characters of such a value cut off at the end of a text, or left at the start of the next event when a value was split between two; private key blocks (a BEGIN line without its END line up to the end of the key lines that follow it); and the well-known key and token shapes the secrets gate of published memory also looks for (Anthropic, OpenAI, AWS, GitHub, GitLab, Slack, Google, Stripe, npm and Hugging Face keys, JSON web tokens, Azure storage keys and bearer tokens). Because a value is matched as typed, a saved placeholder of 8 characters or more (for example lm-studio as an API key) is replaced wherever it occurs; a cut-off piece shorter than 12 characters, or a short password, is not. The replacement is made in the readable view (metadata.normalized_text, or metadata.indexed_text for a transcript record without a readable view, which is still not extracted), in the chunks that search and embeddings use, and so in the extraction prompt, in what the ask agent reads and cites, and in the chunks a memory snapshot import rebuilds; extracted quotes are checked against that view. A source whose view was changed has metadata.masked: true and the kinds replaced in metadata.masked_kinds, never the values. The raw archived text is not changed: the transcript line, the agent event or the note is kept exactly as received, with its SHA-256, and it is what the raw view of the inspector, the ingestion inbox, the administrative export and a memory snapshot carry. A remember record's own text is kept as written too; publishing it is refused by the secrets gate. Text archived before 0.11.0 is not rewritten. If the saved keys or profiles cannot be read, a transcript import, an agent archive, a remember note, a finding, a checkpoint or a task stops with that reason instead of indexing unchecked text, and the extraction of a masked source fails and is retried later; it fails too when the known secrets changed since the import so that its text no longer matches the masked view. This is not a promise that every secret typed into project content or a conversation is found: a password that has no known shape and is not registered here stays as typed. Such a value is not only kept in the raw text: extraction reads the readable view, so it can copy the value word for word into proposed records, and from there it is shown by memory show, the inspector and resume packets and carried by memory snapshots. The masking described here looks only for registered values and the listed shapes; it has no rule for random-looking strings. The random-string rule belongs to the secrets gate of published memory, which refuses a publication holding one, and it looks only at strings of 32 characters or more (MEMORY_CONTRACTS.md). Check the scope of a snapshot before sharing memory.

Ollama

Choose Ollama (local models) and enter the address of a running local service. The key field can stay empty. The model list comes from that Ollama instance. Cairnmind does not download a missing model automatically.

An Ollama profile has an explicit Ollama context tokens field in its advanced settings: 32768 tokens by default, range 4096–262144. The value is sent to Ollama; Cairnmind does not guess the model's actual context window. A larger value increases RAM/VRAM usage. A context that is too large is rejected before generation instead of truncating the memory package; adjust the profile or reduce the scope of the work. The check before generation estimates tokens as half the UTF-8 bytes of the request, which stays above the real count on ordinary text, and Ollama itself is asked to refuse rather than truncate.

The coding model in the profile is independent of the local knowledge agent and embedding model configured in Cairnmind. A shared GPU has limited memory; measure the actual latency and capabilities of the chosen model locally. Local model APIs have no per-token provider fee, but the interface does not turn missing pricing data into a fictitious cost estimate.

GitHub Copilot

In Connections, choose a named GitHub Copilot connection:

  • Connect GitHub account opens an operational sign-in terminal. If the runtime is missing, it first offers to prepare it, with a separate confirmation for the download. Device codes, sign-in URLs and the output of this terminal never become project memory sources.
  • Prepare Copilot runtime lets you separately download the pinned official runtime, verify its checksums and persist a local integrity confirmation. Opening Cairnmind on its own does not download the runtime.
  • Choose model shows the models granted to the account. Organization entitlements and administrator policies may restrict Copilot usage.

The adapter uses the official Python SDK github-copilot-sdk, pinned to a compatible version in the lockfile. Cairnmind controls the tool set and the approvals. Tools with unconfirmed permissions are never approved automatically. Usage information is shown only when the SDK reports it; it is not an independent reading of the account balance.

Signing in with an account does not require your own API key. The Cairnmind runtime has a separate credentials directory and may ask for consent to store them locally without encryption; the decision is yours. Version 0.7.2 fixed how this consent is passed to the runtime. Inherited COPILOT_PROVIDER_* and COPILOT_OFFLINE variables are removed so that they cannot switch this profile to a different API provider. File permissions and the runtime's SHA-256 checksums are checked again even after an earlier successful verification.

The knowledge agent's models

The connections above are for coding assistants. Cairnmind's own knowledge agent (answers to ask, extraction of decisions and tasks, embeddings) has two roles, each with its own server: chat and embedding. By default both run on the local Ollama with qwen3.5:9b and qwen3-embedding:0.6b. Choose another model or server per role with cairnmind models set:

# LM Studio on this computer, both roles
cairnmind models set --role chat --provider openai_compatible --base-url http://127.0.0.1:1234/v1 \
  --model qwen/qwen3-8b --context-window 32768
cairnmind models set --role embedding --provider openai_compatible --base-url http://127.0.0.1:1234/v1 \
  --model text-embedding-qwen3-embedding-0.6b
# a model server in the company network, chat only, key in an environment variable
cairnmind models set --role chat --provider openai_compatible --base-url https://models.example.com/v1 \
  --model qwen3-32b --credential-ref env:MODELS_API_KEY --allow-remote
# back to the local Ollama (the one at ollama_url in the settings)
cairnmind models set --role chat --provider ollama --model qwen3.5:9b
  • openai_compatible speaks Chat Completions and /embeddings at the base URL. It covers LM Studio, vLLM, llama.cpp, an Ollama on another computer (its /v1 address) and most model servers. A server that offers only one of the two can take that one role. The chat role is asked for structured JSON output for a JSON schema (response_format of type json_schema, format with Ollama) by extraction, answer repair, the support check and the names call. The names call is one more request of the chat role for every complete answer to a question asked without an answer schema: after the support check accepts the answer, the model lists the product and technology names the answer asserts and says whether the quotes state each; an unstated name, or a failed or unreadable reply, makes the answer partial, and it is counted in the answer's model_calls as phase names. It is not made in deterministic-only mode. A server that refuses it with HTTP 501 and an error saying structured output is unavailable (Ollama with an MLX build of the model on Apple silicon) is asked the same request again without it, with the schema in the prompt, and Cairnmind validates the JSON itself as it always does: an answer that fails validation stays partial. Every such request is sent with structured output first. The last refusal of a server and model is noted in models.capabilities.json of the data directory, and cairnmind doctor --json shows it as memory_models.chat.structured_output ("structured output: unavailable on this server", with the time it was seen). Any other error of such a request is reported as the model being unavailable.
  • ollama speaks Ollama's own API at the base URL.
  • --reasoning-effort none|low|medium|high (chat role, OpenAI-compatible only) is sent with every chat request. A thinking model such as qwen3.5:9b behind Ollama's /v1 address thinks unless it gets --reasoning-effort none, and then may use its whole answer budget on thinking; the native path turns thinking off on its own. When the test call below ends at the length limit, its message says so and names this option (cairnmind setup remote has no such option, so there the message says only that the reply was cut at the length limit).
  • An OpenAI-compatible server is not told a context size: Cairnmind sends num_ctx only on the native Ollama path, so there --context-window sets only how much text Cairnmind puts into a prompt, and the server's own context setting (for Ollama's /v1, its server-wide context length) must be at least that. How the two paths compare is in evaluation/RESULTS.md.
  • Before saving, the command makes one test call: a short chat request with a JSON schema, or one embedding, whose dimension it reports. Nothing is saved when the test fails. The test sends only a fixed probe text.
  • The same transport rules as for coding connections apply: HTTPS unless the server is this computer, no key or password in the address. A key is named by --credential-ref, env:NAME or profile:ID, never typed into the command. The knowledge service is a separate process: an env: variable must be visible to it, and a profile: key must be saved on this computer (Remember on this computer); a key kept only for the workspace session cannot reach it.
  • A server on another computer receives memory content: your questions, and the text of the sensitivity classes listed in memory_remote_classes in config.json. Cairnmind refuses such a server unless you pass --allow-remote. A server counts as on another computer when its address is not loopback (127.0.0.1, ::1, localhost); a server on your local network counts as remote.
  • A role without a profile uses the Ollama at ollama_url, and that must be this computer. An ollama_url that is not loopback, whether it comes from config.json or from CAIRNMIND_OLLAMA_URL, is refused like a profile without consent: no request of any kind goes to it, not even the read-only ones of doctor and init. cairnmind doctor --json shows the refusal under ollama and memory_models and names the setting; init stops instead of choosing deterministic-only mode; the service, ask, models list, models pull and the evaluations report it as a configuration fault. To use a server on another computer, run cairnmind models set --provider ollama --base-url URL --allow-remote for each role.
  • Which memory may leave. Every source and record has a class (see MEMORY_CONTRACTS.md): project (code, documents, check output, plans), conversation (transcripts, remember notes, checkpoints, findings) and third_party (anything an external client's session wrote or a third-party tool result degraded). The default memory_remote_classes is ["project"]: conversation and third-party text never goes to a remote server unless you add its class, for example "memory_remote_classes": ["project", "conversation"]. A value that is not a list of distinct classes sends nothing, and cairnmind doctor --json says why. For a remote role, held-back text stays on this computer: extraction leaves such a source pending (job diagnostics code remote_not_allowed), embedding leaves its chunks to full-text search, and ask leaves its chunks, records, plans and sources out of the answer's context; the answer's diagnostics count them under held_back, and an answer that is not complete says so in its unknowns. After you add a class, stop the service and start Cairnmind again: the held extractions and embeddings run then, without importing anything again. With the local Ollama nothing changes.
  • The same setting holds memory back from the built-in agent on a hosted model. What a coding agent reads from memory through read_source, ask, resume_context and memory_records goes to that agent's own provider. The built-in agent (API and Copilot connections) is gated on all four when its model is hosted: every Copilot connection, and every API profile whose address is not loopback (a model server on your local network counts as hosted). By default it receives code and documentation (project); conversations, notes and third-party text only after you add their class to memory_remote_classes. read_source refuses a held source and memory_records lists a held record without its content (id, kind, status, version and class only), each saying which class and which setting; ask leaves held passages out of its answer and says so in its unknowns (in its freshness warnings when the answer is complete), and diagnostics.held_back counts them (the request body of /ask and /sessions/prepare carries held_classes, which can only shrink what is read); the resume packet leaves held record previews out and counts them under held_back, while the active plan, the active task and the blockers stay and the ACK works as for any session. What remember and checkpoint hand back to such a run leaves out the record's content and metadata, so that updating a held record by id cannot return its text. A run may still read what its own session archived (a tool result over 16,000 characters is read back with read_source). A built-in agent on a model server with a loopback address gets everything, also when that address only forwards to a hosted model (an Ollama cloud model, a local proxy): the rule goes by the address. Codex CLI, Claude Code and external MCP clients are not gated: their ask answers and resume packets go to their own provider (see EXTERNAL_CLIENTS.md).
  • cairnmind doctor --json shows, under memory_models, the server, the model, whether it answers, where each role's content is sent, which classes it receives (sends) and which stay here (held_back), and the setting under remote_classes.
  • cairnmind setup remote --models-url URL --provider PROVIDER --chat-model NAME --embedding-model NAME --allow-remote ... puts both roles on one model server on another computer, together with a database this installation only connects to (see INSTALL.md). It tests both models before it saves anything and saves them through the same code as models set, so the consent, HTTPS and credential-reference rules above hold for it; cairnmind setup local and cairnmind setup remote-db bring a role that is on another computer back to the Ollama on this one, with the release's model. It never writes ollama_url.
  • models set changes only the two settings of that role in config.json; engine settings given by environment variables stay temporary. The service reads these settings when it starts: stop it and start Cairnmind again after a change. When the two roles are on different servers and one is down, the background work of the other role goes on.
  • Changing the embedding model changes the vectors. Vectors of different models are kept apart: each is stored under the model's identity and its dimension, and search uses only the current model's vectors. Run cairnmind rebuild-vectors PROJECT for each project after the change; until the new vectors exist, search falls back to full-text search. A running service also queues missing vectors for the current model on its own, as it does after models pull. A model on an OpenAI-compatible server reports no digest, so its identity is its name and server. To notice other weights served under the same name (for example another quantization loaded under the same id), the service sends one fixed, short request to such an embedding server when it starts, and rebuild-vectors sends it before it rebuilds. The request is the same sentence on every computer and holds no memory content; only the vector it returns is kept, per model and server, in models.fingerprints.json of the data directory. When the answer differs from the stored one (cosine similarity below 0.9999, or another dimension), no new vectors are made, search uses full-text search only, and cairnmind doctor --json shows memory_models.embedding.fingerprint.changed with the next step. rebuild-vectors accepts the new weights: the identity gets the next generation (NAME@SERVER~w1, ~w2, ...), a new vector namespace, so vectors of the earlier weights, in every project, are kept apart and never searched again; a running service queues the missing vectors of the other projects, as after changing the model. If the earlier weights are served again before that, the next check clears the mark. With Ollama (local, or an Ollama profile) the digest is the identity and no such request is sent. The check is sent at every service start, also when background model work is deferred (as in the cockpit), because it holds no memory content and search needs it before it uses vectors. Weights changed while the service runs are noticed at its next start, or by rebuild-vectors. Until then the service keeps making vectors with the new weights under the current namespace, and they stay there even if the earlier weights are served again later and the next check clears the mark. After any swap the service may have run through, run cairnmind rebuild-vectors PROJECT for each project, also when the earlier weights are back: it deletes the project's vectors and makes them again with the weights in use.
  • Changing only the chat model needs no rebuild.
  • A larger context window for the local model is one command: cairnmind models set --role chat --provider ollama --model qwen3.5:9b --context-window 32768. With it a question may read about twice as much source text before the context guard stops it, and the model takes about 0.6 GB more graphics memory. It is a setup of its own for the evaluation record below. What it and other local chat models gave on questions about this repository is in evaluation/RESULTS.md.
  • A pair of models is evaluated once cairnmind eval run and cairnmind eval memory have both passed with exactly those models and the same setup: each role's server, the chat context window and the reasoning effort (see EVALUATION.md). Until then, with any models other than the release's, answers carry "model_evaluation": "unevaluated" in their diagnostics, and cairnmind doctor --json shows "evaluated": false. The label informs; it does not block answers.

cairnmind models pull downloads only the models that run on the local Ollama.

Without models (deterministic-only mode, knowledge_agent: disabled in config.json, chosen by cairnmind init when no model server or model was found) nothing asks a model, and ask is a full-text search of the project's memory that makes no answer. Through the command line (in a terminal a short view whose status line says that there is no answer without models; with --json, or in a pipe, the JSON), the MCP tool, POST /ask and the Ask memory panel it returns status: unavailable with diagnostics.code: models_not_configured, an empty sources, and full_text_matches: up to 8 passages that match words of the question, each with id, source_id, uri, kind, line_start/line_end where it has lines, an excerpt of at most 400 characters and match: full_text. A record and the note it was made from, with the same words, are listed once, as the record. They are found by full-text search under the same project, worktree and sensitivity rules as an answer's evidence, and the answer says that they are search results, not an answer and not verified evidence for one; no citation is made, and they are never cached, written to the answer log or evaluated. With no matching passage the list is empty and the answer says so. unknowns says how to get models; the evaluations report not_run (exit 3) and rebuild-vectors refuses. cairnmind models pull after a successful download, and cairnmind models set after its check, set knowledge_agent: enabled; the service reads it when it starts. A configured model server that is down is still reported as a fault: the answer's code is model_unavailable and cairnmind status shows background.model_error once background processing runs (the workspace's service waits until a project allows it). Until the service is restarted after models pull or models set, cairnmind status on a service that started without models says so in get_models.

Agent work and permissions

The API/Copilot panel shows the history, the streamed response, tool calls and their results, and the memory state. Send or Ctrl+Enter starts a turn. Ctrl+C or Interrupt stops the current operation. The Ctrl+B workspace prefix and the panel shortcuts still work; press Ctrl+B twice to pass a native Ctrl+B through.

The agent can browse, create, edit and delete files in the selected worktree. File tools validate paths and links, and changing an existing file requires a match with the hash of the version that was read. Replacing or deleting a whole existing file additionally requires that every line of that version reached the model whole, unmasked, in the current conversation (or that the model wrote that version itself); a read cut to fit the context, or a single slice, is not enough, and the agent is told to read the rest or use a patch instead. Direct writes to .git/ and to the managed .memory/cairnmind/ directory are blocked, and a change to a file that configures execution needs a one-use approval (see below). If a second client changes a file, the agent must re-read it instead of overwriting the newer work.

Every system command, including running tests, requires one-time approval. The approval screen shows the exact command, the working directory, the session and the generation. The approval applies only to that specific operation; changing any parameter requires a new approval. The command runs with the user's permissions; this mechanism is not system-level sandboxing. A command of Cairnmind's own engine runs in its own process group. A timeout, an interrupt or a cancelled turn stops the whole group: SIGTERM, up to half a second for it to end, then SIGKILL to whatever is left, and the tool does not return (or let the cancellation through) until no process of the group runs any more, waiting at most one more second for that. If a process still runs after that second (for example one stuck in the kernel), the result and the journal say processes_remaining and the action stays uncertain for Resolve; a process that left the group (setsid, setpgid) is not followed. Native Codex and Claude Code processes keep their own tool policies.

The agent's own file changes and approvals

Most file changes need no approval, so text the model read (a README, a transcript, a tool result) can lead it to write a file that runs code later: a conftest.py that the next approved pytest loads, a Makefile for make, another coding client's hook. Two protections cover this; both apply to API and Copilot runs alike, since Copilot's own tools are switched off and every file change goes through the same executor.

The list of changed files (the general protection). The approval dialog of every command and every third-party tool call lists the files the agent created, changed or deleted since your last approval of a command or a third-party call: each path with created, changed or deleted, at most 20 paths (the rest are counted), a path longer than 240 characters shown with its middle cut, and the text made inert like all model text; line breaks, tabs and other control or separator characters in a name are shown as escapes such as , so a name stays on its own line. A file created and deleted again is left out; an empty list says so. The list is reset only when you approve; after a refusal the same files are listed again. It is rebuilt from the journal, so a restart of the agent pane does not forget an unapproved write (if the journal cannot be read, the dialog says the list may be incomplete). The journal's approval_requested and approval_decided events carry it as changed_files and changed_files_more. This is the part that covers every path: read the list before you approve a command that could load one of those files.

Files that configure execution need approval. A write, patch or delete of a file that makes another program run something without asking you needs the same one-use approval as a command (Write once). The dialog shows the path, whether the file is created, changed or deleted, and a diff of the change, bounded to 60 lines and 18,000 characters, with the count of lines not shown. A line is shown whole or not at all, never cut, so no part of the change hides behind the start of a long line. The change is checked against the version the model read before you are asked, and again when it is made, so the change you approve is the one written. A refusal returns approval_denied, leaves the file as it was and is not counted as a started action; the journal has approval_requested and approval_decided with kind: "file_write". Approving such a change does not reset the list of changed files. The paths, compared without regard to case and at any depth in the worktree:

  • Coding clients' configuration and hooks: anything under .claude/, .codex/, .cursor/, .gemini/, .windsurf/, .clinerules/, .continue/, .amazonq/.
  • MCP configuration: .mcp.json (other clients' MCP files are in their directories above, .vscode/mcp.json below).
  • Repository instruction files: AGENTS.md, AGENTS.override.md, CLAUDE.md, CLAUDE.local.md, GEMINI.md, .cursorrules, .windsurfrules, .clinerules, and .github/copilot-instructions.md, .github/instructions/, .github/prompts/.
  • CI: .github/workflows/, .github/actions/, .gitlab-ci.yml, .circleci/.
  • Editor tasks: .vscode/tasks.json, .vscode/launch.json, .vscode/settings.json, .vscode/mcp.json.
  • Dev containers: .devcontainer/, .devcontainer.json.
  • Shell environment and Git hook managers: .envrc, .pre-commit-config.yaml, .husky/, lefthook.yml, .lefthook.yml (.git/ itself stays blocked).

No such list can be complete. Almost any file can make code run when a later command uses it: conftest.py, Makefile, package.json scripts, pyproject.toml, setup.py, tox.ini, noxfile.py, a build script, any source file a test imports. Those are deliberately not gated, since the agent's normal work is to change them; the list of changed files in the dialog is what shows them to you. The path list covers the places where nothing would ask you later. Neither protection reaches coding clients outside Cairnmind, or changes made by a command you approved.

The default limits of Cairnmind's own engine are 20 model requests per turn, 4096 output tokens per request and 120 seconds per command. A Copilot profile defaults to 20 tool calls and 900 seconds per turn. The forms let you change the supported limits. The number of Copilot's internal requests is not claimed to be known when the SDK does not expose it.

Reaching a limit stops the turn; you continue by sending another message. Token counts come from the provider's report. Cost is an estimate based on the profile's optional rates; without rates or usage data it is shown as No data. It is not a guaranteed cap on the amount charged by the provider.

Third-party MCP tools

The built-in API agent (OpenAI, Anthropic, OpenAI-compatible endpoints, Ollama) can use the tools of up to four stdio MCP servers per project. Only you add or remove them, in the workspace under More → MCP servers for the selected project; the list lives in your local cockpit preferences, not in the repository, and applies from the next agent run of that project. Other projects, Copilot runs and the native Codex and Claude Code clients do not get them.

  • A server's tools appear as mcp_<server>_<tool> and only after the model has acknowledged its resume packet, like every tool with an effect. Every call shows the server, the tool and the exact arguments and needs your one-use approval, also for a tool its server calls read-only. There is no "always allow".
  • A server gets no secrets: the form takes a program path, arguments and literal environment values, and refuses names that look like credentials or belong to Cairnmind, and variables such as PATH, HOME, LD_PRELOAD, PYTHONPATH or NODE_OPTIONS that change which code a program loads. A server whose program, argument or value names a path inside the project folder is not started. A server that needs a token works only through its own sign-in under your home directory.
  • What a server returns is untrusted third-party text: bounded, marked as such for the model, kept in the agent's journal, archived with origin_evidence: degraded so it never makes a record verified, and never indexed for search. After a third-party tool was used, nothing the agent says or does in that session is searchable or evidence: its later replies, tool requests and results are archived the same way and what it then writes to memory is marked degraded.
  • A tool whose input schema is outside the subset every provider accepts is left out; if a provider still refuses the request with them and the same request succeeds without them, the third-party tools are withdrawn for the run and the agent works on without them.
  • Only tools are used (no resources, prompts, sampling, elicitation or roots), over the stdio transport only.

Two things are accepted, not prevented. A stdio server is a program you chose to run under your own account: it can read and change what your account can, and Cairnmind is not a sandbox for it. And text from a server can steer the model into editing files in the worktree without an approval, exactly as text read from repository files can. What limits this: the next command or tool-call dialog lists every file the agent created, changed or deleted since your last approval, and a change to a file that configures execution (a coding client's hooks or MCP file, AGENTS.md, CLAUDE.md, a CI workflow, editor tasks, a dev container, .envrc) needs its own one-use approval. The details follow; the agent's own file changes are under The agent's own file changes and approvals.

A project can give its built-in API agent the tools of up to four stdio MCP servers. You add or remove a server in the workspace under More → MCP servers (see TERMINAL.md); nothing else writes the list: no command, no memory tool, no agent tool and no file in the worktree. It is stored per project in the owner-local cockpit/preferences.json (key project_mcp_servers) and copied into the run's private configuration when the agent starts, so a change applies from the next run. This is separation by place and by the authenticated settings route, as for connection profiles: any process of your own user account can still write that file. Copilot runs, the native Codex and Claude Code clients and other projects do not get the servers; to use a server there, configure it in that client yourself, where its calls bypass Cairnmind's journal, ACK gate and approvals.

A server has an id (lowercase letters, digits and hyphens), an absolute program path, arguments and literal environment values. It gets no secrets in this version: names that look like credentials (TOKEN, PASSWORD, SECRET, API_KEY, AUTH, ...) or Cairnmind's own variables are refused, and the agent's key and the service token never reach its arguments, environment or calls. Variables that change which code a program loads or where it looks for it are refused outright: PATH, HOME, SHELL, LD_*, DYLD_*, PYTHONPATH, PYTHONSTARTUP, PYTHONHOME, PYTHONUSERBASE, PYTHONPLATLIBDIR, NODE_PATH, NODE_OPTIONS, PERL5LIB, PERL5OPT, PERLLIB, RUBYLIB, RUBYOPT, GEM_HOME, GEM_PATH, BASH_ENV, ENV, CLASSPATH, JAVA_TOOL_OPTIONS, _JAVA_OPTIONS, JDK_JAVA_OPTIONS, XDG_CONFIG_HOME and XDG_DATA_HOME. A server whose program, an argument or an environment value names a path inside the worktree is not started, since the agent could change that code without an approval. Two checks, either of which refuses: every piece of a value that can be a path (split on =, :, ,, ; and whitespace, and the part of a piece from its first /, as in -f/path) is resolved, following links, and compared with the worktree component by component; a relative piece is resolved against the server's working directory, a private directory directly under the system temporary directory. And the worktree, as given and as its real path, must not appear as a path prefix anywhere in a value once separators are normalised: that catches a path inside a shell command and a link inside the worktree that points out, such as a virtual environment's bin/python. A sibling folder such as app-mcp or app.venv next to app is not mistaken for it. The limit of this check: a value that only becomes a path inside the server (a name it looks up, a file it reads its configuration from, $HOME expanded by a shell) cannot be seen. When the agent starts, such a server is reported as definition_refused. The process gets a minimal environment built from scratch (HOME, LOGNAME, PATH, SHELL, TERM, USER from the worker and the values you set), a private working directory outside the worktree, no stderr (it goes to /dev/null) and its own process group. A stop signals the whole group, first with SIGTERM and then SIGKILL, keeps the process until it is reaped and completes even if the turn is interrupted meanwhile; closing the agent stops every server. Cairnmind talks to it with a small bounded client of its own; only tools are used, never resources, prompts, sampling, elicitation or roots, and a request from the server is answered with an error.

The servers start with the first turn and have 20 seconds together to answer initialize and list their tools (at most four pages). Interrupting that start stops every server it started; they are started again with the next turn. Their tools appear as mcp_<server>_<tool>: at most 16 per server and 32 in all; a description is escaped, cut to 1,024 characters and prefixed with a sentence that names the server and says the text is untrusted. A built-in tool can never be shadowed: the prefix is reserved. A tool is left out, with its reason in the journal (invalid_tool, invalid_name, name_taken, tool_limit, invalid_schema, schema_unsupported), when its name does not fit or its input schema is outside the subset every provider accepts. That subset is the same for the OpenAI, Anthropic, OpenAI-compatible and Ollama profiles: at the top type: object with properties, required, additionalProperties and description; inside also type, items (required for an array), enum of plain values, anyOf, minimum, maximum, exclusiveMinimum, exclusiveMaximum, minLength, maxLength, minItems and maxItems; property names of letters, digits, _, . and -; at most 6 levels. $ref, $defs, oneOf, allOf, not, const, uniqueItems, a top-level anyOf and every other keyword leave the tool out; pattern, patternProperties and format are removed rather than evaluated, as are annotations such as title, default and $schema. What makes checking arguments expensive is bounded at admission: at most 128 schema nodes, 16 anyOf branches in all and none inside another anyOf, and 256 enum values in all. A call whose argument nodes times the schema's nodes and enum values exceed 200,000 is refused (arguments_too_costly); the rest is checked on one dedicated thread with a 2-second limit, and a tool whose check runs out of time once is withdrawn for the run (mcp_tool_withdrawn in the journal and the status line). If a provider refuses a request that offers third-party tools, naming the tool definitions (tools_rejected: OpenAI's tools[...] parameter or "Invalid schema for function", Anthropic's tools.N...input_schema) or without a usable cause (provider_error, unsupported_request), and nothing of the answer was shown yet, the request is made once more without them: if that succeeds they are withdrawn for the rest of the run (mcp_tools_withdrawn), if it fails too they stay offered (mcp_tools_kept) and the original refusal is the turn's error. Any other refusal, a context overflow included, is not retried. The catalogue is journaled as mcp_server_started. A server that does not start is journaled as mcp_server_failed with a fixed code (program_unavailable when its program does not exist or cannot be run, start_failed, start_timeout, protocol_unsupported, catalogue_invalid, definition_refused), shown in the agent pane as its reason in words, and the agent works on without its tools. The worker also reports it to the broker (POST /_control/agent/mcp_failure, bearer only: the run id, generation, project id, server id and code, nothing else; an unknown code, an unknown run, another generation or project, or an id that is not one of the run's servers is refused), which keeps it with the run once per server; the sidebar then shows it once per server per run, on the notice line for the project shown and otherwise only in Notices under the run's project. Nothing the server printed is part of the report. There is no restart within a run.

The tools are offered only after the model's exact resume ACK and refused without a fresh one. Every call shows the server, the tool and the exact arguments and runs only after your one-use approval (Call once), also for a tool the server marks read-only; there is no "always allow" and nothing is remembered per server. The dialog always shows the whole request: a call whose request would print as more than 60,000 characters is refused before the dialog. If the project state changed while the dialog was open, the call is refused and a new ACK is needed. A call has the profile's command timeout; a timeout, an interrupt, a message over 4 MiB or the server exiting stops the server for the rest of the run, and an interrupted call stays an uncertain action for Resolve. The journal holds approval_requested, approval_decided, action_started before the call and action_completed with the result.

What reaches the model for a call:

  • Refused by the host before anything is sent, with host text only: invalid_tool_call (unknown or withdrawn tool), invalid_tool_arguments (not valid for the admitted schema; with the argument's path, the schema keyword and a fixed hint, never the value sent), tool_withdrawn (the check ran out of time; the tool is gone for the run), credential_in_tool_arguments, arguments_too_large (over 16 KiB as compact JSON), arguments_too_costly (too expensive to check against the schema), arguments_too_long_to_show (the dialog could not show it in full), resume_required, approval_required (no person to ask) and approval_denied.
  • Failed in transport, as a fixed code and never with the server's text: mcp_call_failed (a JSON-RPC error), mcp_call_timeout, mcp_server_exited, mcp_server_unavailable and result_too_large (over 1 MiB as a converted result, given only as its size and SHA-256; a single message over 4 MiB has no hash).
  • A result: its text blocks (other blocks replaced by their type and size) and structuredContent as structured, with third_party_untrusted: true, the server, the tool and a notice that it is untrusted data. A result the server itself flags with isError is ok: false with error_code: mcp_tool_error and still carries the server's text, marked the same way. A result over 16,000 characters reaches the model's context as a projection that keeps all of these markings, the server's text only under content, cut to about 10,000 characters, and structured left out; the full result is in the journal and the archive.

In memory, every archived event of a server or one of its tools is a source with origin_client: mcp:<server> and origin_evidence: degraded: a record that rests only on it is degraded, never anchored, and it is not chunked, embedded or extracted, so search and later resume packets do not surface it. It stays readable by its source id. After a third-party tool was used, nothing the agent says or does in that session is searchable or evidence: from the first result that carries a server's text (a completed call, or a tool error the server reported), every later event of the session is archived the same way (degraded, not chunked, not extracted): the agent's messages, its tool requests and their arguments, tool results and approvals. What the session writes to memory afterwards (records, checkpoints, plans) carries the mark origin_client: mcp:<server>, origin_evidence: degraded, and is described as written after a third-party tool result, not as an external client's. A call that never reached a server (refused, denied, too large, a made-up mcp_ name, a fixed failure code) does not count. The person's own messages and resolution notes are archived as before, and a session that never received a third-party result is archived exactly as before.

Accepted and not prevented: a stdio server is a program you chose to run under your own account; it can read and change what your account can, and Cairnmind is not a sandbox for it. Text from a server can steer the model into editing files in the worktree, which needs no approval for most files, exactly as text read from repository files can; the next approval dialog lists those files (see The agent's own file changes and approvals). A harmless server to try is the reference time server: install it with uv tool install mcp-server-time and add its program, for example /home/me/.local/bin/mcp-server-time, with no arguments.

Memory and recovery after interruption

Cairnmind's local data directory must be located outside project directories, for example in ~/.local/share/cairnmind. A new agent refuses to start when its store is inside the selected project; saving a persistent key also checks the other registered directories. This keeps configuration files and local credentials from becoming the agent's working files.

Every engine uses the shared project memory, with an actual resume_context read and an exact ACK from the model. Delivery of context by the UI or the SDK is not an ACK. A partial package, a mismatched readback or a change in relevant state blocks writes and any actions that require restored context.

The ack_resume schema requires a readback with plan and task fields: the exact id and version of the corresponding active item in the package, or null when there is no such item. Version 0.7.2 gives this shape directly to API and Copilot models; the acknowledgement is still verified by the actual memory server.

Messages, complete tool calls and their results are persisted in a private, integrity-checked journal. The start of an action is recorded before it executes, and its result before the model's next step. Conversations and evidence are archived as Cairnmind sources and are available through the memory inspector and in portable memory.

Ctrl+B d detaches the interface and keeps the process running. Shutting down WSL terminates the processes. A later Sessions → Resume saved session restores memory and requires a new ACK handshake. The journal does not grant earlier command approvals again.

An action that was started without a confirmed result is in an uncertain state. Resolve (Ctrl+R) lists such actions and requires a note after you check for yourself, for example whether a file was created or a test finished. Ctrl+S saves the note; a save error keeps the text you typed. Saving the note does not re-run the command. Only a separate message continues the work. Do not repeat a paid request or a command just because the connection dropped; the previous operation may have completed.

When compacting context, the engine keeps the sources and a checkpoint, and builds the new context from the current memory and the required sources. Memory does not remove context limits or model costs. A snapshot carries saved conversations, decisions and evidence; it does not carry keys, connection profiles, active processes or approvals. Imported test results remain historical.

Post-installation check

First restore a known project and check the existing Codex/Claude panels. Then configure the new profile you want, check its state, run an explicit model test and a short turn with a file read and a rejected command. Verify that a second client restores a saved decision together with its source. Detach and reopen cairnmind.

Automated tests use controlled HTTP/SDK responses, a real ArcadeDB and tmux. They do not consume paid quota. A real connection, models on a specific GPU and Copilot/OpenAI/Anthropic accounts require a separate, explicit check by the user. A missing account, model or available quota is a not_run result, not a passed test.