AI in Drupal
Wiring an AI assistant into Drupal: the AiAssistantApiRunner workflow for direct answers vs. agent delegation, tool integration, and system prompt design.
What this covers
Wiring an AI assistant into Drupal: the AiAssistantApiRunner request flow, when to answer directly versus delegate to an agent, and how the system prompt is structured to keep that decision consistent. For Drupal module development and security review skills, see Drupal Development & Operations. For broader AI development concepts, see AI Development.
When to use it
- Wiring an AI assistant into Drupal (system prompts, direct-answer vs. agent-delegation flow)
- Deciding whether a user query should be answered directly or routed to an agent with tool access
- Writing or debugging a system prompt that governs an assistant’s response format
AiAssistantApiRunner Workflow
- Direct Answer: Respond in Markdown.
- Agent Delegation: Route complex queries to AI agents.
- Tool Integration: Use external services for data processing.
- Result Formatting: Present outputs in readable, context-preserving formats.
System Prompt Example:
$pre_prompt = $this->assistant->get('system_prompt');
"[instructions] ... You will answer directly or delegate to an agent. Format outputs in Markdown for readability."