Starting…

No run yet. Write your code, then click Run.

Lesson

Grounding on real sources

Already wiring web, SharePoint and file search with citations? Skip to the next lesson.

Last lesson you searched one small set of documents. Real questions need several sources, and every claim needs to point back at one.

The idea

Grounding means every statement your agent makes can be traced to something it actually read. Not "the model is fairly sure", but "here is the page it came from".

Three sources cover most workplaces:

  • The web, for public information. Cite with a link.
  • SharePoint, which is where most companies keep internal documents. Cite with a link to the page.
  • Your own files, on disk or in cloud storage. Cite with the file path.

Keep them as three separate tools rather than one. They have different permissions and different trust levels, and when an answer is wrong you want the trace to tell you which one it came from.

A citation is a promise

A citation is only worth something if someone can follow it. That means a locator: a URL, a link, a path. A snippet with no locator is just a sentence you cannot check, and lesson 0.3 showed you exactly how convincing an unverifiable sentence can be.

The format here is [web] title (url): snippet, so the next turn can reuse it.

What to write

  1. cite(kind, title, locator, snippet) to build the citation string
  2. search_web, search_sharepoint and search_files, each returning a cite(...) string
  3. TOOLS and execute_tool for all three
  4. The agent loop, with tools=TOOLS and deployment=AZURE_DEPLOYMENT

The point

If you cannot point at a source, you do not know. You are guessing politely.

Break it on purpose

Return bare snippets with no locator. The check fails for missing sources, and the answer still reads perfectly well. That is the danger.

Check yourself

Answer out loud first. Reading the answer without trying is where the learning leaks out.

  1. 1. Why keep web, SharePoint, and files as separate tools?

  2. 2. What belongs in a citation besides the snippet?

  3. 3. Who runs the search, the model or your code?