Method WithKnowledge
WithKnowledge(AgentKnowledge)
Grounds the agent's answers in knowledge sources: every user input searches them (or the agent searches on demand, per Mode), the passages found are presented with citation numbers, and the run's result carries its Grounding verdict.
public AgentBuilder WithKnowledge(AgentKnowledge knowledge)
Parameters
knowledgeAgentKnowledgeThe knowledge sources and their rules.
Returns
- AgentBuilder
This builder instance for method chaining.
Examples
var agent = Agent.CreateBuilder(model)
.WithInstruction("You answer customer questions about our policies.")
.WithKnowledge(new AgentKnowledge(documentRag))
.Build();
var result = await agent.RunAsync("What is the refund window?");
Console.WriteLine($"{result.Content} ({result.Grounding.Status})");