In agentic RAG, the model chooses whether to call retrieval tools instead of always injecting context.
Decision flow
“Use this tool for ARIS policies, docs, release details, and system behavior. If facts are uncertain, call this tool before answering.”
“Searches database.”
Empty-result fallback
- Inspect why retrieval failed.
- Rewrite query with broader wording.
- Retry retrieval once.
- If still empty, answer with uncertainty and next-best guidance.
LangGraph routing example
from typing import Annotated, Literal
from typing_extensions import TypedDict
from langgraph.graph import StateGraph
class AgentState(TypedDict):
messages: Annotated[list, add_messages]
def router(state: AgentState) -> Literal["retrieve", "end"]:
last_message = state["messages"][-1]
return "retrieve" if last_message.tool_calls else "end"
workflow = StateGraph(AgentState)
workflow.add_node("agent", agent_node)
workflow.add_node("retrieve", tool_node)
workflow.set_entry_point("agent")
workflow.add_conditional_edges("agent", router)
workflow.add_edge("retrieve", "agent")
app = workflow.compile()
Last modified on February 21, 2026