Sub topic 11
Using an Agentforce Data Library as a shortcut
This chapter assumes you can administer Salesforce (objects, permission sets) and know what Agentforce agents, topics, and actions are. It also assumes you know the manual path from earlier chapters: ingest Knowledge into Data Cloud, build a search index, create a retriever, and wire it into a prompt template or agent action.
What a Data Library is
An Agentforce Data Library is a setup object that bundles the manual steps into one guided configuration. You pick a source of content, and Salesforce creates the Data Cloud pieces for you. These pieces include the data stream, the data model objects, the search index with chunking and embeddings, and a retriever. The library then exposes that retriever to agents through a standard answer-questions-with-knowledge action.
You trade control for speed. A Data Library makes most of the decisions that you would otherwise make by hand.
The exact screens, option names, and defaults change between Salesforce releases. Check the release notes and Setup in your org before relying on a specific label.
What the library creates for you
The Data Library maps onto the manual path like this.
| Manual step | What the Data Library does |
|---|---|
| Create a data stream from Knowledge | Creates the ingestion for the source you select |
| Choose chunking and an embedding model | Applies default settings |
| Create a search index | Creates a hybrid search index |
| Create a retriever | Creates a retriever with default returned fields |
| Add the retriever to an agent action | Makes the library available to the agent's knowledge action |
Because these are real Data Cloud objects, you can open them afterward. You can use the same retriever testing tools you used in the earlier chapters. This is the main way to check what the library built.
Choosing a source
A Data Library can draw on several kinds of source. The common ones are Salesforce Knowledge, uploaded files, and a web search source. Which options appear depends on your org and release.
For this tutorial, choose Knowledge. Before you do, confirm that the content you want is published. You can use the SOQL query from the Knowledge preparation chapter:
SELECT Id, Title, UrlName, PublishStatus, Language, LastPublishedDate
FROM Knowledge__kav
WHERE PublishStatus = 'Online'
AND Language = 'en_US'
ORDER BY LastPublishedDate DESC
LIMIT 20Draft and archived articles are not published, so they are not retrieved. If an article is missing from this list, it will also be missing from the library.
Creating a library
The overall flow is short.
- Confirm that Data Cloud is provisioned and that Agentforce is enabled.
- In Setup, open the Agentforce Data Library page and start a new library.
- Name the library and give it a description. Agents and admins see this text later, so describe the content clearly.
- Select Knowledge as the source and narrow it if the options let you, for example by article field or data category.
- Save. Salesforce starts the ingestion and index build in the background.
- Wait until the status shows the library is ready. The first build can take a while, depending on how many articles you have.
Your user needs permissions for both Data Cloud setup and Agentforce setup. Missing permissions are a common reason the page or the option is not visible.
How an agent uses the library
The library connects to an agent through the knowledge action. You add the action to a topic and attach the library to the agent. When a customer asks a question, the agent runs the action, which queries the library's retriever. The returned excerpts go back to the agent as context for its reply.
The topic still matters. The library supplies content, but the topic instructions decide when the agent calls the action and what it does with the result. Use the sample topic instruction from the earlier chapter as a starting point:
When a customer asks a product or policy question, use the knowledge action to look up the answer.
Base your reply only on the returned articles.
If no relevant article is returned, do not guess. Tell the customer you do not have that information and offer escalation.What you give up
A Data Library is convenient, but the shortcut has limits. Know them before you choose it.
- Less control over chunking. You usually cannot tune chunk size or the fields that are embedded. If your articles are long and mixed, this can reduce relevance.
- Fewer filter options. A custom retriever lets you define filters on fields such as data category or language. A library may expose only a few of them.
- Fixed returned fields. You might not be able to return a custom field, such as a product line or an article URL, that your prompt wants to cite.
- One retriever per library. If you need different retrieval behavior for different agents, you may need different libraries or a custom retriever.
- Prompt templates. Check whether your release lets you use the library's retriever in Prompt Builder. If it does not, build a custom retriever for prompt grounding.
Library or custom retriever
Use these criteria to decide.
| Situation | Better choice |
|---|---|
| Prototype, demo, or first agent | Data Library |
| Admin-only team that does not manage Data Cloud objects | Data Library |
| Need to tune chunking or embedded fields | Custom search index and retriever |
| Need filters by language, category, or audience | Custom retriever |
| Need to ground a prompt template with specific returned fields | Custom retriever |
| Several agents that need different retrieval behavior | Custom retriever |
The two approaches are not exclusive. You can start with a library, test it, and move to a custom retriever when quality or control becomes a problem.
Checking the result
After the library is ready, verify each layer separately.
- Open the library's search index in Data Cloud and confirm that the record count roughly matches your published article count.
- Open the retriever and run a test query you know the answer to. Check the returned excerpts, their source titles, and their order.
- Ask the same question in the agent preview. Compare the answer with the excerpts.
- Ask a question that your articles do not cover. The agent should use the fallback, not general model knowledge.
- Publish a small edit to one article, wait for the next refresh, and confirm the change appears in retrieval.
Step 5 matters because freshness is not instant. Ingestion and indexing run on a schedule or with a delay, so a just-published article may not appear right away.
Common problems
- The library stays in a building or error state. Check that Data Cloud is provisioned and that the Knowledge data stream has the permissions it needs.
- Articles are missing. Check the publish status, the language, and any narrowing options you set on the source.
- Answers ignore the articles. Confirm that the knowledge action is on the topic and that the topic instructions tell the agent to use it.
- Answers contain facts not in any article. Tighten the topic instructions and check the fallback behavior. Retrieval grounds the answer, but the model can still add outside knowledge if the instructions allow it.
- Users see content they should not. Review how the source respects sharing and visibility. Treat this as a governance check, covered in a later chapter.
Exercise
Your team built a Data Library over Knowledge, and the agent answers well in most cases. A prompt template for case summaries needs to cite the article URL from each excerpt, but the library does not return that field. What are your options, and which is usually best?
Show answer
First check whether your release lets you change the library's returned fields or use its retriever in Prompt Builder. If not, create a custom search index and retriever over the same Knowledge data, include the URL field in the returned fields, and use that retriever in the prompt template. The custom retriever is usually best, because it gives control over returned fields. You can keep the library for agents that do not need the extra field.
Exercise
A customer asks about a policy that was updated an hour ago. The agent gives the old text. List the checks you would make, in order.
Show answer
Confirm the new version is published (PublishStatus = 'Online') with the SOQL query. Check whether the Knowledge data stream has refreshed since the publish. Check whether the search index has updated. Run the question in the retriever test tool and see which version comes back. Only after retrieval returns the new text should you look at the agent instructions.