Skip to main content

Use Built-in Tools

This guide shows how to give a Custodian Agent access to the web and to documents it was not trained on, using the built-in tools web_search, scrape_url, and parse_document.

For the full reference, see Built-in Tools for Python or TypeScript.

When to use a tool

SituationApproach
The agent should answer from your own stable documentsData source / RAG
The agent needs current information from the webweb_search
The agent should read one specific page you namescrape_url
The agent should extract text from a document by URL, one timeparse_document
from custodian_labs import Custodian

app = Custodian(
model="gpt-4o",
system_prompt="Answer using current web results when they help. Cite your sources.",
tools=["web_search", "scrape_url"],
).deploy()

reply = app.chat("What changed in the latest OpenAI API release?")
print(reply.response)

Combine tools with a workflow team

A common pattern: one agent researches with web_search, the next writes from its notes. In workflow mode the agents run in a fixed order and each output feeds the next.

from custodian_labs import Custodian, CustodianSquad

squad = CustodianSquad(
custodians=[
Custodian(
name="research",
model="gpt-4o",
system_prompt="Research the topic. Produce notes with sources.",
tools=["web_search"],
output_key="research_notes",
),
Custodian(
name="writer",
model="gpt-4o",
system_prompt="Write a one-paragraph brief from the research notes.",
),
],
routing_mode="workflow",
workflow_order=["research", "writer"],
)
app = squad.deploy()
reply = app.chat("Give me a brief on RAG evaluation methods.")
print(reply.response)

Cost and latency

Each tool call is an extra round trip. Tell the agent in its system prompt when to use a tool ("search only when the answer depends on recent events") rather than letting it reach for one on every message.

External connections

Gmail (read / send / reply from an agent) is coming soon.

Next steps