Skip to content

Debugging

The AI Context module includes optional debug logging to help troubleshoot context selection, rendering, and scope matching issues.

Enabling debug logging

  1. Navigate to /admin/config/ai/context/settings/general
  2. Expand the Debugging section
  3. Check the Enable debug logging checkbox
  4. Save the configuration

Viewing debug logs

Debug information is written to the standard Drupal log:

  1. Go to Reports > Recent log messages (/admin/reports/dblog)
  2. 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_SELECTED subscriber exceeds configured max_items
  • Warning when TEXT_RENDERED text exceeds configured max_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.