An agent connected to knowledge

An agent can consult RAG as a knowledge tool.

What you will learn

  • Explain: a bounded agent loop
  • Apply the idea in an example: An agent connected to knowledge
  • Recognize limitations and verify the exercise outcome

An agent can consult RAG as a knowledge tool. That differs from claiming it memorized all documents.

These steps refer to features identified in the application code. This material has not been validated on a live instance; check the documentation and the options in your version.

How it works, step by step

A bounded agent loop

An agent combines a model with tools, a goal and state. It observes the request, chooses a step, receives a result and decides whether to continue. A chatbot may only generate text; an agent may request an external action. Commercial definitions vary, so inspect actual control. Define success and stopping: a verified result, a maximum step count, repeated errors or an exhausted budget. Use narrow capabilities and minimal permissions. Useful autonomy means freedom within boundaries enforced by software.

RAG accesses evidence, it does not retrain

RAG means retrieval-augmented generation: retrieval supplies relevant passages before the model answers. Ingestion prepares documents, while query execution searches the index and builds context. An embedding model represents text numerically; the response model writes the answer. Rerankers, vision, graph and router models have different roles when needed. RAG helps with private or changing information but does not guarantee truth. Use an authorized API for balances, exact inventory or permissions; an old document is not a reliable source for current state.

Fluency and truth are checked separately

A hallucination is unsupported or incorrect content presented as an answer. It can arise from missing information, ambiguity or incorrectly combined patterns. Ask for evidence and check the original document, date, units and conditions. A real citation may still fail to support the claim. Use current sources for current facts, a calculator for arithmetic, and “cannot determine” when evidence is missing. Do not treat confidence expressed in prose as a calibrated probability.

The visual map

An agent connected to knowledge Follow the solid arrows for the main flow. Dashed blue arrows supply data or context; dashed pink arrows show feedback or returning results. Colors and shapes distinguish models, stores, decisions and outputs. Connections: User request → Agent / LLM; Agent / LLM → Semantic search; Semantic search → Candidate passages; Candidate passages → Build evidence context; Build evidence context → Final answer; Instructions and context → Agent / LLM; Access permissions → Semantic search; RAG knowledge → Semantic search; Original sources → Candidate passages; Build evidence context → Agent / LLM (Retrieved context). A03 · Relationship map An agent connected to knowledge Input User request Data Instructions and context Decision / control Access permissions AI model / agent Agent / LLM Store / index RAG knowledge Processing Semantic search Data Candidate passages Processing Build evidence context Output Final answer Store / index Original sources Retrieved context Main flow Data and context Feedback and return

Follow the solid arrows for the main flow. Dashed blue arrows supply data or context; dashed pink arrows show feedback or returning results. Colors and shapes distinguish models, stores, decisions and outputs. On smaller screens, scroll horizontally to follow the entire diagram.

A complete example

Attach an indexed-policy RAG to the agent. For “Can I return after 20 days?”, it retrieves the 14-day policy and explains limits without inventing exceptions.

Try it yourself

  1. Attach the RAG and compare the same question with and without available evidence.
  2. Record the input, source and expected outcome before running the experiment. Use only the fictional data in the example.
  3. Follow the diagram stages. At every step record what information is received and produced; do not confuse intermediate output with the final outcome.
  4. Repeat after removing necessary information or making the input ambiguous. Check whether the system clarifies, stops or invents an answer.
  5. Compare with the explained solution. Keep the configuration, date, result and an explanation for differences. Change one thing and retest.

An explained solution

The agent uses the policy and notes no documented exception; it changes neither policy nor order. A successful exercise lets you show the connection between input, stages and outcome. When information is missing, a cautious answer is more useful than invented details. Compare more than style: check conditions, sources and operations too.

When it helps and what can go wrong

Attaching an unindexed RAG does not create evidence. Choose this approach when it improves a measured need. Keep a simple baseline and compare outcomes using identical inputs. One successful example does not establish reliability in every situation.

Check your understanding

Does more autonomy always give a better result?

No. It also increases room for errors, costs and unnecessary actions.

Does RAG change LLM parameters?

No. It supplies request-time context; parameter changes belong to training.

What outcome should this exercise produce?

The agent uses the policy and notes no documented exception; it changes neither policy nor order.

Words to remember

  • Agent: A system that can choose steps and use tools toward a goal.
  • Retrieval: Finding relevant information in accessible sources.
  • Grounding: Grounding an answer in verifiable evidence.

Sources and your next step

To prepare: A02 — Your first agent in the application