Debugging
The AI Context module includes optional debug logging to help troubleshoot context selection, rendering, and scope matching issues.
Enabling debug logging
- Navigate to
/admin/config/ai/context/settings/general - Expand the Debugging section
- Check the Enable debug logging checkbox
- Save the configuration
Viewing debug logs
Debug information is written to the standard Drupal log:
- Go to Reports > Recent log messages (
/admin/reports/dblog) - Filter by type: ai_context
Or using Drush:
ddev exec drush watchdog:show --type=ai_context
What gets logged
Context selection (AiContextSelector)
- Task and consumer ID at the start of selection
- Scope index prefilter counts (candidate IDs vs. published IDs)
- Number of published items loaded across chunks and always-include count
- Item count after merge and slice
- Render summary at info level (tokens used, item count, consumer)
- Warning when items are truncated due to token limits
- Warning when an
ITEMS_SELECTEDsubscriber exceeds configuredmax_items - Warning when
TEXT_RENDEREDtext exceeds configuredmax_tokens
See Selector pipeline events for when those overrides are allowed.
Scope scoring and hard context filtering run inside the selector via
AiContextScopeResolver but do not emit separate debug messages.
Context rendering (AiContextRenderer)
- Items skipped when the token budget is exhausted before or during rendering
Subcontext resolution (AiContextSubcontextResolver)
No dedicated debug channel. Subcontext inclusion is reflected in the final
item count logged by AiContextSelector.
Performance considerations
Debug logging generates significant log entries and may impact performance. Only enable it when actively troubleshooting issues. Remember to disable it when you are done debugging.