Skip to content

Site context

The Site Agent AI Context submodule (site_agent_ai_context) gives the model the site's AI Context items: its voice, standards and rules, written and published by the site's editors in AI Context.

  • Each toolset is an AI Context consumer, of the type "Site Agent toolset", listed with AI Context's consumers. Its subscriptions, always and never include lists, limits and selection mode are set there, and so is whether it gets context at all. It does by default.
  • Before each model call, the items of each toolset the thread's owner may use are selected for the user's latest message and the page the chat was opened on, in the order of the toolset list, and added to the system prompt as one "Site context" section after the toolsets' sections. An item one toolset's selection has is left out of the next ones', so it is given once. The page is given to AI Context as its entity and its path, so Entity Types, Specific Entities, Taxonomy Terms and Site Sections items match it. The selection is cached until an item or AI Context's settings change, so a turn's tool rounds select once, record one usage row, and send the same system prompt. A remote client's instructions get the items selected without a message or a page.
  • The site_agent_ai_context:page_context tool selects the items for a page being drafted or rewritten: by its entity type and bundle for a new page, or its id, and its path. It leaves out the site-wide items, which the system prompt has. Where any of the toolsets offers it, the system prompt tells the model to call it before drafting a page and to follow its result as guidance. Installing the submodule adds it, pre-approved, to every toolset with a content write tool, such as Editor and Site builder; uninstalling takes it out of every toolset. A toolset made later gets it from the toolset form. It needs AI Context's access published ai context permission ("Use Published AI Context in AI Features").
  • The site_agent_ai_context:propose_learning tool keeps what the model learns about the site, such as "field_image takes a media id, not a URL", as a proposed AI Context item: a title, the text, a scope (Global, an entity type, a bundle or a site section, from the values AI Context offers) and why, which becomes the item's Purpose. The item is saved unpublished, in the AI Context workflow's draft state, owned by the requesting account, with the thread reference as its revision log message. It is a drafting content write, so it runs without a prompt. AI Context selects only published items, so no chat gets it until an editor publishes it in AI Context, from the URL the tool returns or the items listing. The tool refuses an item with the same title, ignoring case, or with the same scope and the same text, ignoring case, spacing and punctuation, published or not. It needs AI Context's create access (create ai context item or administer ai context), and the workflow's draft transition (use ai_context_editorial transition create_new_draft), as AI Context's own form does. Where any of the toolsets offers it to the user, the system prompt tells the model to propose a rule or gotcha particular to the site that it hit, not general Drupal knowledge. Installing the submodule adds it, pre-approved, in an entry of its own, to Editor and Site builder; only accounts with AI Context's create access are offered it. Uninstalling takes it out of every toolset.
  • An item reaches the system prompt when its Context scope is Global, when it matches the page the chat was opened on, or when it matches a scope one of the toolsets subscribes to. An item with no scope matches nothing.
  • AI Context selects only items the user may view, so the roles that use the chat need access published ai context. Items in the system prompt are instructions to the model: give the AI Context editing permissions, and the workflow's publish transition, only to roles trusted to instruct it.
  • AI Context's own push into AI requests doesn't apply: the consumer type routes no request tags.

Selection gives AI Context the page through its request info resolver, and records usage through its usage tracker. Both are internal to AI Context, so the submodule's info file requires AI Context 1.0.0-rc1 or later, the version they were written against.