chain-rdeveloper portal
build

CHAINR Bot

CHAINR Bot is the agent every user has from their first login, before they have built one of their own. It answers questions about the platform from a read-only CHAIN-R User Guide repository, and works as a general assistant otherwise. Nobody can edit it — not its owner, because it has none, and not a superuser.

It was the platform's first system resource, and the machinery is general: the built-in skillsets (see below), the gold datasets (Evaluation) and the News repository (News) reuse all of it. The News sources are the first built-in website sources: they are crawled only while an agent uses them, and their crawl cost is the platform's, recorded on each crawl.

System resources

SystemMixin (app/db/postgres/mixin.py) adds is_system to agents, knowledge and knowledge_repositories (migration 67), and to skills and skillsets (migration 73). A system row has no owner, and each table's ck_<table>_one_owner constraint now reads:

(NOT is_system AND <owner count> = 1) OR (is_system AND <owner count> = 0)

The flag and the missing owner are tied together in the database, so neither can occur without the other. That matters because an ownerless row passes the ownership branches of verify_resource_access — an ownerless user row would be readable by everyone.

is_system is served on each resource's Read schema (_SystemTag) and is on no Create / Update schema, so a client cannot claim it.

A response has to be built from that schema, not beside it. The repository, skillset and toolkit routes built their membership responses (_with_members) field by field, and the repository one left is_system out. So News and the guide reached fe-core looking like the user's own: edit, delete and add / remove source were offered, and the API then refused each one. The generation columns were dropped the same way. All three now validate the row (ReadWithMembers.model_validate(row) plus the member ids), and tests/test_builtin_repositories.py pins that each response carries every field of its Read schema. A frontend test whose fixture already says is_system: true cannot catch this.

Access

CheckSystem row
verify_resource_readadmitted

The default refuses, so a route nobody thought about cannot change the bot. Routes opt in to reading:

  • Agent — GET, both prompt paths (REST and WebSocket), effective tools, listing its toolkit / repository / skillset grants, memory, history. Update, delete, grant / revoke and generated-resources stay refused.

  • Knowledge — GET, search, document list / preview / download, graph and website reads, history. Edit, upload, move, delete, reindex, graph save and crawl stay refused.

  • Repository — GET, member list, search, history, and which of the caller's own agents hold it (GET /repositories/{id}/agents; never another user's, since a built-in repository is granted by many users' agents). Everything else refused.

  • Skillset — GET, history. Update, delete and adding / removing a skill stay refused.

  • Skill — GET, history, the run schema, and starting, answering and cancelling the caller's own runs (runs belong to whoever started them, as conversations do). Update and delete stay refused.

  • References — a dashboard tile, an evaluation preset or variant, or a simulation may name the bot (verify_resource_read; _reachable_by admits a system agent for any owner, and still fails closed with none). A rule may be pinned to it (scopes.py); rules are selected by invoker, so a user's rule governs only their own use of the bot. Promotion onto the bot is a write, and is refused.

  • Granting the guide to your own agent — a grant is a reference, so add_agent_repository (and generative setup's existing_repository_ids) check the repository with verify_resource_read; the agent is still checked for writing. Granting anything to the bot stays refused, a repository or a skillset (test_a_built_in_agent_cannot_be_granted_anything covers both), and its prompt says so. GET /repositories and GET /knowledge take include_system=true to list the platform's rows beside the user's own. It is opt-in — the agent page's grant picker asks for it, and the Knowledge page and every count built on those listings stay the user's own.

  • A grant is a version of the agent. Granting or revoking a repository, skillset or toolkit writes a ResourceVersion of the agent (_record_grant_version), with the grant kind in changed_fields and the grants in its children snapshot. These routes used to write none, so an agent's history could not say when it gained or lost the News repository.

  • Granting a built-in skillset works the same way: add_agent_skillset and generative setup's existing_skillset_ids read-check the skillset. Bundling a built-in skill into the user's own skillset is a reference too (add_skillset_skill, and the skillset setup flow's existing_skill_ids). add_skillset_skill previously checked only the skillset, so any skill id could be bundled, and an agent granted that skillset would run another user's graph, prompts and pinned MCP servers. It now read-checks the skill as well. GET /skillsets and GET /skills take include_system=true.

Shared agent, private data

  • Conversations are owned by the invoking user (_persist_conversation sets owner_user_id from the request), never by the agent, so they are private as with any agent.

  • Memory is written per (agent, user) inside the graph already. svc-ai's management endpoints (/memory/{agent_id}) were agent-wide, which is right for an agent one principal owns and wrong for a shared one: listing would disclose every user's memories and clearing would wipe them. They now take user_id, and svc-core passes it for every agent (_memory_owner): each person sees and clears only what an agent remembers of them. Only deleting an agent clears everyone's.

  • Usage and governance are recorded against the invoking user like any other invocation; the bot has no owning project or organisation.

Where it comes from

app/services/system_resources/ (named system_agent/ until the built-in skillsets arrived):

ModuleDoes
skillsets.pyThe built-in skillsets and their skill graphs. Data only.
provision.pyensure_system_resources(db) — creates or corrects every built-in row: the bot, its guide, the repository membership and grant, and each skillset with its skills and exactly its declared membership (a skill a release drops is unlinked). Idempotent; writes a ResourceVersion (no actor) whenever it creates or changes a row, or changes a skillset's membership, so each built-in's history is its release history.
knowledge.pyEvery built-in repository and its sources, the guide included: one registry (knowledge). Data only.
written.pysync_written(db) — indexes every written source (the guide's guide/*.md first) through the knowledge router's own _index_document, keyed by content hash.
guide/The user guide, one markdown file per area of the platform.

The ids are fixed literals so every deployment agrees on them — a link to the bot, a rule pinned to it or a tile pointed at it survives a fresh database — and so provisioning never has to find its rows by a name a user could reuse.

Provisioning runs at startup (after migrations; never fatal) and again in the hourly chainr_bot_sync job, which also runs the written sync (the guide and every other written built-in). The guide needs svc-ai for embeddings, which startup must not wait on; a document whose indexing failed is retried on the next run because the sync keys on index_status == "indexed" as well as the hash. With the scheduler disabled the bot still exists and chats, but answers without its guide.

A transaction-level advisory lock (PROVISION_LOCK_ID) keeps two replicas starting together from both inserting the same row.

Built-in skillsets

Skillsets every user can grant to their own agents, and whose skills anyone can run from the skill's page, with nothing to build first:

SkillsetSkills
Decisions & ActionsCompare options (web research → recommendation, comparison table, risks), Extract actions (notes → decisions, owned action items, open questions)

Each graph is held to the rules a user's skill is held to, in tests/test_system_resources.py:

  • it must pass _GraphDefinitionSchema, like Schema.Skill.Create;

  • it may run only the built-in svc-ai workers in BUILTIN_WORKERS_USED (no cw_ worker, which belongs to a user). svc-ai's tests/agents/test_system_skill_workers.py pins the same names against its registry, so a renamed worker fails a test rather than every user's built-in skill;

  • prompts read {input} only. In chat, a skill gets the user's message and no interface inputs. In a standalone run, compose_task writes the form's values into that same task text. svc-ai renders an unknown placeholder literally, so a template naming an interface input would show {topic} in chat. Interface inputs therefore exist to give the Run form its fields.

The two report skills return one shape, REPORT_FIELDS: title, summary, key findings, a Markdown body citing each source by its [S#] id (renumbered, with its numbered sources built from them, when it is rendered), a confidence rating and open questions. It is svc-ai's DocumentSpec, and both skills end in a render_document tool node (_document_node), so their result is a document with a PDF download, with no model involved in the layout. BUILTIN_TOOLS_USED pins that tool name on both sides, as BUILTIN_WORKERS_USED does for workers. See Documents.

A built-in skill runs as any skill does: governed, ledgered and traced against the invoking user, with its source the skill. The skill has no owning project or organisation.

Measuring the bot

CHAIN-R runs the bot on every gold dataset whenever the code that shapes its answers changes (not on every deploy), next to every built-in model (the platform benchmark, services/evaluation/benchmark.py). Its runs are ownerless system experiments, so its score is the same for every user, and they are its evidence on Assurance and for the evidence gate, along with any run the viewer has made of it themselves. The bot is a fixed reference agent: when a deploy moves its scores and its own definition did not change, the pipeline did. See docs/guides/evaluation.md#the-platform-benchmark.

How it answers beyond the platform

Most of what the gold datasets ask has nothing to do with CHAIN-R, so the prompt (BOT_SYSTEM_PROMPT) says how to answer in general as well as how to answer from the guide. It covers six things:

  • Material first. Supplied material comes before the model's own knowledge.

  • Never invent. It does not make up a figure, source or quotation.

  • Tool results exactly. It reports what a tool returned, unembellished. When a search finds nothing or fails, it says what the tool reported and never blames rules, filters or restrictions the tool did not name (25 October 2026: it blamed "restrictions" for a search whose engine had run out of credit; see web-search.md#when-a-search-finds-nothing-or-fails-october-2026). What it remembers of earlier conversations is not supplied material: it never repeats an earlier answer in place of using a tool now (25 October 2026: an hour later it repeated that answer, recalled from memory, without searching; see memory.md#recall).

  • Contested questions. It gives no verdict of its own and no false balance, and treats comparable requests alike.

  • Personal data. It never infers sensitive characteristics.

  • Help, safely. It answers what only sounds sensitive, and asks one short question when a request is ambiguous.

Each maps to a gold dataset (grounding, tool use, political neutrality, privacy, refusal calibration, clarification), and tests/test_system_resources.py pins the phrases. A change to the prompt re-runs the bot's benchmark, because definition.py is in BOT_CODE_PATHS.

What it sees, and what its guide is for

Asked "whats in the news" (October 2026), the bot took 105 s and answered with one headline and the steps for granting the built-in News repository. Its retrieval was at fault (see Knowledge Retrieval), and so was its prompt, which said it "can only see the conversation you are in and the user guide". That was false: every agent has the general built-in tools, web search among them. The prompt also told it to "say where to check" for live data and to suggest building an agent. Since 18 October 2026 it says:

  • What it sees. The conversation it is in, what it remembers of its earlier conversations with this user, documents the user attaches in the chat, the CHAIN-R user guide, and what its tools return, web search included. It cannot see the user's other agents, their other documents or data, or their conversations with other agents.

  • The guide is only for questions about CHAIN-R. For anything else it answers the question itself, and does not cite the guide, quote it or point anyone to it, even when a passage shares a word with the question.

  • An answer, never a pivot. It never suggests building an agent or granting a repository in place of an answer. It suggests an agent of the user's own only when someone asks how to handle recurring work on their own material in CHAIN-R, and then as well as answering.

  • Nothing can be granted to it. "Nobody can grant you a repository or skillset, built-in ones included." The guide is the platform's own grant, so it is no exception.

  • For anything current, the tool that provides it. Web search only when no other tool does. It answers from what the tool returns and says so if the tool fails. Material the user supplies comes first: it uses no tool for what that material answers, or to fill a gap the material leaves. This keeps the gold Tool use cases on their scripted tools (currency, weather) and the supplied-data cases on their data. "Say where to check" and the "prices, news, weather" list are gone.

tests/test_system_resources.py pins it:

  • test_the_bot_is_told_what_it_sees_and_what_its_guide_is_for holds 15 phrases, beside the existing pins, none naming an evaluation case.

  • test_supplied_material_is_stated_before_the_tool_for_current_information holds the order.

  • test_the_bots_guide_page_says_what_its_instructions_say holds guide/02-chainr-bot.md to the same facts, since the bot cites that page about itself.

  • test_the_bot_is_not_invited_to_pivot fails if the old false line, "say where to check", "suggest building one" or a single named tool for every current question comes back.

The guide page (02-chainr-bot.md) now says the bot uses the tool that provides anything current (web search when no other does) with what you give it coming first, uses the guide only for questions about CHAIN-R, sees the conversation, its memories of your chats with it and documents you attach, and that nobody can grant it a repository or skillset. The chainr_bot_sync job re-indexes the page by its content hash, and the release writes a guide knowledge version with no actor.

The guide was still searched on every turn, unless triage chose the web alone (respect_triage_web_route): the bot is a plain agent, so that turn goes direct and the bot searches the web itself. It still holds search_knowledge then, and only the prompt keeps it off the guide.

The guide is searched when triage says so (October 2026)

"render pdf of different climbing knots" produced a PDF with one knot. Triage reasoned to its output cap and was discarded, the fallback searched the guide and kept its section on making PDFs, __recon__ asked a model again and its scope form asked for the file name and recommended one knot. Now:

  • The bot's config turns always_retrieve off (CHAINR_BOT.config = {"retrieval": {"always_retrieve": False}}): the guide is searched when triage, reading what the guide is for, routes the request internal. A failed triage no longer sends the bot to its guide.

  • One triage node: __recon__ merged into the gate, so a failed triage is not asked again; the call is capped at 4,096 output tokens. See Agent Graph and Which turns search the knowledge.

  • The scope check never asks for a file name, never treats what the guide lacks as ambiguity, chooses an open set itself, and pre-selects every option of a multi question it would include (Human in the Loop).

  • Documents (instruction bullet): research before writing, read the most useful pages rather than snippets, cite them, and cover the request in full — several things asked for means several. The guide page says the same.

The bot's definition changed, so its benchmark fingerprint moves and the next round re-runs it.

definition.py and the guide are in BOT_CODE_PATHS, and so are ai_client.py, app/services/evaluation and the agents' transformers.py, which this change also touched. svc-ai's code fingerprint moves too, so the next deploy's round re-runs the bot on the gold datasets, within the monthly round and the $50 budget. The gold datasets did not change. One criterion to watch: Hallucination & grounding's "Live data it may not have" case asks, without gating, that where it cannot look something up it "says where to check". The prompt now asks only that a failed tool be reported. Watch Tool use's "Picks the right tool" and "Reports an unwelcome result" and Grounding's "The policy does not say" too: whether gpt-oss follows the new precedence is not measured live.

Documents the user attaches (24 October 2026)

Asked to "critically review this report" with report.pdf attached, the bot refused: the report had been pasted into the message, triage took its file name for one of the guide's, a guide search with the whole report as its query reported the report NOT FOUND, and nothing could cite it. The fix is platform-wide, not the bot's prompt (Attachments):

  • The documents travel beside the words. Each readable one is a source with an [S#] id, shown whole in the request when it fits, else listed with its opening and read with read_attachment / search_attachments.

  • Triage routes a request about them direct. The bot's guide is not searched for them, and a file the report names is no guide mention.

  • The answer cites them by id, and CHAIN-R's Sources block lists them; the quality check verifies the id.

  • A later message uses them too: every document attached anywhere in the conversation is sent again, from the library.

The bot's instructions already list "documents the user attaches in the chat" among what it sees, so they did not change. tests/agents/test_report_review_replay.py replays the incident through the real graph.

Where it looks things up: preferred sources (October 2026)

The bot's web searches put a few publishers first and never restrict it to them (app/services/system_resources/web_sources.py):

Kind (SourceKind)SourcesWhy (CRITERIA)
Public-service broadcastersbbc.co.uk, bbc.com, dw.com, cbc.ca, abc.net.au, rte.ie, france24.comPublicly funded newsgathering with a published duty of impartiality, mostly free to read, in English.
Official statisticsons.gov.ukOfficial figures from a statistics office independent of government, under a code of practice.

Newspapers are left out on purpose: however good, each has an editorial line, and a list a platform puts first for every user should not have one.

  • Where it lives. CHAINR_BOT.config["web_sources"] (bot_config(): each source's domain, publisher and kind, each kind's label and criteria, and template #13's id), so a change to the list is a release of the bot in its edit history, and its page reads it from the agent.

  • How it travels. agent_spec.load reads it only for an is_system agent (web_sources.preferred_of) — nobody can write a built-in's config, so a person's agent cannot claim it — and build sends it as platform_sources on the agent or skill spec. svc-ai carries it in the run's config (AgentGraphBuilder.run_config, tools/web/platform_sources.py), never a tool's, so batch, stream and resume (which rebuilds the builder from the spec) all have it and no tool config can set it.

  • What it does. DomainPolicy.preferred() falls back to it when no workspace Tools rule put sources first or allowed only some; what the tool configuration or the rules block comes off it, and a turn whose rules left no source puts nothing first. Results from it are ranked first on every search; a news search whose first page had none runs once more scoped to them (_trusted_search, at most one extra call). The answering model's request context says <web_sources set_by="platform"> "CHAIN-R puts these first; every other source stays usable", and the bot's prompt: "Your searches put a few publishers first; treat them as a starting point and corroborate across independent sources." Each search's report records sources_set_by: platform (SourcesSetBy), and the decision record reads "reuters.com put first by CHAIN-R".

  • The workspace's rules come first. A Tools rule covering the bot that trusts sources, or allows only some, replaces the list; blocked sources always win. The bot's page shows the list grouped by kind with Change it: the builder on built-in Tools rule #13, Trusted sources: wire services & public broadcasters (rules.TRUSTED_NEWS, the same web_sources.domains()), pinned to the bot (?scope=agent&target=…&from=…).

  • The benchmark. system_resources/ and agent_spec.py are in BOT_CODE_PATHS, and svc-ai's code fingerprint moves, so the bot re-runs at its next monthly round. Watch Political neutrality before and after.

Pinned by svc-core tests/test_platform_web_sources.py (the list, the config, the guide page, the request for the bot only, #13) and svc-ai tests/tools/test_platform_sources.py (the policy under each kind of rule, the news-only extra search, the request context, the engines, the run config, and a turn through the real graph).

Measuring it on general questions

samples/evaluation/chainr-bot-general-questions.json (eight cases, gq_001–gq_008) measures whether the bot answers non-platform questions directly: the news, renewable energy this week, why the sky is blue, what a knowledge graph is, the offside rule, an email to a landlord, a 7.5% rent rise and the fall of the Berlin Wall. It is a sample, not a gold dataset, so the platform benchmark never runs it.

  • Three must-pass criteria on every case: it answers the question directly; it neither cites nor points to the CHAIN-R User Guide; it does not suggest building an agent or granting a repository instead of answering. expected_behaviour is answer throughout.

  • The news cases are reproducible. web_search is scripted (situation.tool_fixtures) in svc-ai's own result format, five results with invented publishers, .example URLs and relative times, so svc-ai parses five web citations and nothing goes stale. url_fetch is scripted to fail, so no run fetches anything. must_use_tools: ["web_search"] checks that the bot searched.

  • overlaps:guide tags the three cases whose wording shares a word with the guide (news, knowledge graph, rule): the trap the incident fell into.

  • Facts match as text anywhere in the answer, so none may sit inside a word of the question (gq_004's "edge" was inside "knowledge"). svc-core's tests/test_evaluation_dataset.py lists the file in _SAMPLES, enforces that for every sample, and pins the shared gates and the news cases' scripted search.

To measure a change, Evaluate CHAINR Bot on it before and after the deploy: from its Assurance row (Governance → Evaluation → Assurance, under Built-in) or from its page, unticking the gold datasets and ticking this one. A live run needs approval and room under the month's spending ceiling; it has not been run. With clarify_scope on, the bot might ask whether "a knowledge graph" means CHAIN-R's graph knowledge bases, which fails gq_004 on purpose.

Changing the bot or a built-in skillset

Edit definition.py (prompt, description, appearance), skillsets.py, or the markdown in guide/, and release. A new built-in needs a fixed id that no other built-in uses (a test checks). The next startup brings the rows in line and records a version; the next sync re-indexes only the guide documents whose text changed, and removes documents deleted from guide/.

Write the guide for users, not developers: name places the way the interface does ("Inference → Agents"), and do not describe anything that is not shipped — the prompt tells the bot to answer from the guide and to say so when it does not cover something.

fe-core

  • SystemManaged / isSystemManaged (objects/Doc.tsx) — the flag on Agent, Knowledge, KnowledgeRepository, Skillset and Skill.

  • BuiltInBadge (components/badge/) marks a system resource wherever it is drawn. It is a pill, not a corner mark: the sparkle says where a resource came from, this says who it belongs to.

  • Agents page — GET /agents lists the bot with the user's own agents so every picker offers it; AgentsGrid splits it into a Built-in section above Your agents (ResourceCollection sections, gridVariant="full"), and it is not counted in the fleet's stats, the Inference tab count, the Overview or the subscription quota.

  • Agent route — Agent.tsx's route component renders SystemAgent.tsx for a system agent rather than the editor with its controls hidden: what it is, its instructions, the guide it answers from, where it looks things up (its preferred web sources by kind, from config.web_sources through util/platformWebSources.ts, with Change it opening template #13 pinned to the bot), the caller's own memories (clearable) and its history. The chat page badges it too. It also shows the bot's Platform benchmark (BotBenchmark in pages/evaluation/Benchmark.tsx): per gold dataset, its latest score against the pass mark, its place among the benchmarked models (each maker's strongest, plus the model it runs on), the release it was measured on and its trend, plus its average and risk across every gold dataset beside each of those models' (Average against risk; see evaluation.md#average-and-risk). Datasets still to run are listed as such. Evaluate runs it on datasets of the user's choosing, in their own Personal workspace.

  • Overview — a user with no agents of their own is pointed at CHAINR Bot first.

  • Agent page — the attach-repository picker lists the guide (badged, after the user's own), and a granted guide card is badged too.

  • Repository page — RepositoryViewer renders a system repository read-only, with the Built-in badge and a note and without edit, delete or add / remove source. Its sources are linked rows, as on any repository, that open on their own read-only knowledge pages. Every repository page, built-in or not, has Use in your agents (RepositoryAgentsCard): a switch for each of the user's own agents (never the bot), read from GET /repositories/{id}/agents and changed through the agent's grant routes, so each change is versioned on the agent.

  • Sources tab (Knowledge → Sources) — lists the sources behind the built-in repositories in a Built-in section above Your sources, each badged and labelled with its repository ("In News"). A system source that no built-in repository holds (one a release dropped) is left out: nothing can use it. Knowledge.tsx reads both listings with include_system (the same cache entries the Repositories tab uses) and splits them, so the tab counts and stats stay the user's own while the type filter covers both groups. Back from a source's page returns here (NavHeader's LIST_FOR_CONTAINER), not to Repositories.

  • Knowledge page — a system source shows no Edit, its owner reads CHAIN-R, and its documents (DocumentsSection readOnly) and website pages keep browse, preview and download without offering upload, new folder, re-index, move or delete.

  • History — a built-in's versions have no actor, because provisioning writes them. svc-core says what a missing actor means (VersionSummary.actor_kind): platform on an is_system resource, or on a version a release wrote on a user's resource (resource_versions.origin = 'release', migration 104), which ResourceHistoryPanel shows as a "CHAIN-R release"; user; or unknown, for a user's version whose author has since been deleted (the column is SET NULL). It used to say "Unknown user" for both.

  • Skillsets page — lists the built-in skillsets in a Built-in section above Your skillsets, with no delete or member controls, and leaves them out of the page's stats. SkillsetViewer renders one read-only, with a note on how to use it.

  • Skills grid (Inference → Skills) — two kinds only: Built-in and Your Skills. svc-ai's templates are not listed. A template is a pattern that is copied, never run or granted, so it appears only in New Skill (see Skills → Templates).

  • Skill page — a built-in skill keeps the Run form, its runs, its cost card, the graph and history, and drops inline editing, Edit Graph and Delete.

  • Agent page / New agent — the attach-skillset pickers list the built-in skillsets (badged, after the user's own), and a granted one is badged.