ai_context
Beta1 released at DrupalCon Chicago! ๐
Beta testers welcome!
Please file bugs, feature requests, UX improvements, and ideas in the issue queue. ๐
For developers and those comfortable with ddev, see the installation and testing notes.
Context Control Center (CCC) helps your Drupal siteโs AI use your content, rules, and terminology so it delivers more accurate, relevant results. Whether itโs a content editor drafting product pages with the right compliance language, a marketer generating on-brand copy, or a site builder integrating AI with domain knowledge, CCC ensures every agent interaction is grounded in your siteโs context.
Create and manage context items just like any other Drupal content, with drafts, approvals, scheduling, and version history. You can organize them by topic, language, or section of your site, link them to specific pages, and group related items so theyโre used together.
Choose which AI features use which context, set limits to keep costs under control, and pin or exclude items as needed. A built-in dashboard, usage reports, and logs help you see whatโs working and make improvements over time.
Context Examples
You can add whatever context makes sense for your website such as:
- Brand voice and tone
- Style guides
- Editorial standards
- Design systems and templates
- Regulatory requirements (HIPAA, FERPA, GDPR)
- Accessibility standards
Features
Context Content Management
Context items are managed as full content entities with moderation, scheduling, revisions, multilingual support, and a markdown editor, all within a UI consistent with Drupal CMS 2.0.
- Content moderation
- Scheduling
- Duplication
- Markdown editor
- Multilingual support
- Revisions and revision comparisons
- UI that matches Drupal CMS 2.0 content editing
Context Scope
Context scope plugins categorize context items by criteria such as use case, language, tags, site section, or target entities, and agents subscribe to the scopes most relevant to their tasks. The plugin system is extensible, so custom scopes can be added to fit any site's needs.
- Global: allow context to globally apply to any agent
- Use Cases: common, predefined use cases (e.g. writing words)
- Languages: target specific languages
- Tags: flexible tagging based on vocabulary for custom categorization
- Site Sections: define specific sections or paths of site
- Target Entities: bind context with specific Canvas pages, node content, etc
- Scope Subscriptions: configure agents to opt-in to the most relevant scope
- Extensible: add your own custom scope plugins
Subcontext
Subcontexts organize context items into a one-level parent-child hierarchy, where each child is either always included with its parent or conditionally selected by an LLM based on relevance.
- Required Subcontext: used for hierarchical organization
- Conditional Subcontext: parent rules explain when to include children
- Parent / Child UI: shows nested context with type icon
- Subcontext Selection: LLM decides when child is relevant for inclusion
Agent Context Selection
Agent context selection lets administrators control which context items an LLM agent receives through scope subscriptions, entity targeting, and always/never inclusion rules, all governed by configurable item and token limits.
- Context Limits: max context items and token limits to control costs
- Scope Subscriptions: configure agents to opt-in to the most relevant scope
- Global: global context is always included within max limit settings
- Target Entities: include context associated with certain content entities
- Always Include: ignore other configuration and always include context
- Never Include: ignore other configuration and always exclude context
Additional Features
The module includes an admin dashboard, usage tracking, debug logging, granular permissions, configurable settings, and comprehensive test coverage and documentation.
- Overview Page: lightweight dashboard with key actions and resources
- Usage Tracking: tracks context usage by context, agent, route, and tools
- Debug Logging: optional verbose debug logging for troubleshooting
- Agent Debugging: integrated with agents explorer and debugger modules
- Access Control: context management and module settings permissions
- Admin Settings: disable scope plugins, finetune moderation settings, etc
- Full Test Suite: extensive automated test coverage across all features
- Documentation: detailed feature and configuration documentation
Getting Support
- Check the issue queue first
- Join the #ai-context channel in Drupal Slack
- Add a support issue to the issue queue
Installation and Testing Steps
You can install using Drupal CMS 2.0 or Drupal 11. Choose one.
Note: These instructions assume you have ddev installed.
Install dev branch on Drupal CMS 2.0
mkdir my-drupal-site && cd my-drupal-site
ddev config --project-type=drupal11 --docroot=web
ddev start
ddev composer create-project drupal/cms
ddev composer drupal:recipe-unpack
ddev exec sed -i 's/"minimum-stability": "stable"/"minimum-stability": "dev"/' composer.json
ddev composer require drupal/ai_context:dev-1.0.x -W
ddev composer require drupal/ai_agents_debugger
ddev launch
go through installer in browser and choose the Byte site template
ddev drush en ai_context ai_agents_debugger -y
Install dev branch on Drupal 11
mkdir my-drupal-site && cd my-drupal-site
ddev config --project-type=drupal11 --docroot=web
ddev start
ddev composer create-project "drupal/recommended-project:^11"
ddev composer require drush/drush
ddev exec sed -i 's/"minimum-stability": "stable"/"minimum-stability": "dev"/' composer.json
ddev composer require drupal/ai_context:dev-1.0.x -W
ddev composer require drupal/ai_agents_debugger
ddev drush site:install --account-name=admin --account-pass=admin -y
ddev drush en ai_context ai_agents_debugger -y
ddev launch
# or automatically log in with:
ddev launch $(ddev drush uli)
Configure a provider
If you are using Drupal CMS 2.0, you should have the amazee.io provider available with some free credits. You can also install and configure another AI provider if you prefer.
For Drupal 11, install and configure an AI provider.
The provider settings page is at: /admin/config/ai/providers
Simple testing steps
- Go to: /admin/ai/context/overview
- Add context: /admin/ai/context/items/add
- Go to agent context settings: /admin/ai/context/settings/agents
- Update an agent to always include a context item (e.g. Content Type Agent)
- Test the agent using the debug option of the debugger: /admin/config/ai/agents
For example, if your context says "always add the word hello when you respond", and your prompt for the "Content Type Agent" is "list all the content types", then the response should have "hello" in it somewhere.
Working on issues
This is an official AI Initiative project. We welcome contributions from AI Partners as well as from the wider community.
Some issue etiquette:
- Please do not work on an issue that is already assigned before first commenting on the issue and/or contacting the person assigned.
- Only assign yourself an issue if you will be able to work on it within the next couple of days. Exceptions can be made for project maintainers or those who have arranged something with the project maintainers.
- Since assigning an issue blocks others from working on the issue, it's important to unassign an issue as soon as you know you can't work on it. If an issue has been assigned for more than 3 days with no updates, we will assume it's not being worked on and we may unassign it so others can take it on.
Issues that are tagged as AI Initiative Sprint are worked on during sprints run by the AI Initiative. Sprints run for two weeks. If you are not officially part of the AI Initiative, you can still work on these issues if you follow the guidelines above. When in doubt, DM Kristen Pol in Drupal Slack or add a messaging in the #ai-context Slack channel.