0001 Run answers through ai_agents; retrieval is the agent's own tool call¶
Status¶
Accepted
Context¶
ai_assistant_api is deprecated and removed see here: https://www.drupal.org/project/ai_answers/issues/3610874. The module
previously drove a direct provider chat() call and a manually constructed
Search API query, owning both generation and retrieval itself.
Decision¶
Both generation and retrieval now go through AiAgentEntityWrapper. On a
follow-up turn, retrieval is a real ai_search:rag_search tool call that the
agent's own LLM chooses to make, not a query the module issues on the agent's
behalf. A brand-new question (no prior turns) is the one exception:
AnswerService calls the tool directly itself, before the agent ever runs,
since there are no held sources to fall back on and grounding can't be left
to the model's discretion on that first turn. See
ADR 0006 for why the two turns are
treated differently.
Consequences¶
- Introduces cross-module dependencies that must land upstream: ai_search structured tool output (3584031) and ai_agents streamed chat (3538174).
- The module no longer owns the retrieval query directly — it can only shape the agent's environment (system prompt, tool constraints) and react to what the agent's tool call returns. This constraint drives ADR 0005, ADR 0006, ADR 0007, and the rerank known gap.