Skip to content

Function Calls

The AI Context module provides one AI function call plugin that agents can use as a tool.

GetRelevantAiContextItems

Plugin ID: ai_context:get_relevant_ai_context_items

Function name: ai_context_get_relevant_ai_context_items

Group: context_tools

Class: Drupal\ai_context\Plugin\AiFunctionCall\GetRelevantAiContextItems

This plugin allows agents to explicitly request relevant context items during execution, in addition to the context that is automatically appended to the system prompt.

Parameters

Parameter Type Required Description
task string Yes The current task or user prompt to select context for
agent_id string No Agent ID whose assigned context to use; if empty, all items are considered
max_context_items integer No Override for maximum number of items to return
always_include list No List of ai_context_item IDs to always include first
entity_type string No Entity type for target matching (e.g., node)
entity_id any No Entity ID for target matching (used with entity_type)

Behavior

The plugin delegates to AiContextSelector::select() with the provided parameters. If matching items are found, the output includes:

  • The selected context item IDs
  • The rendered context text

If no items match, the output is "No relevant AI context items found."

Example output

Selected AI Context Item IDs: 5, 12, 3

## Brand Guidelines
Use our primary brand color (#1a73e8) for all headings...

## Product Categories
Our catalog is organized into three main categories...