#Goal
Make a directory of CSV and JSON exports available to an agent without exposing arbitrary filesystem paths.
Suppose the directory contains:
/absolute/path/exports/
├── orders.csv
├── customers.json
└── archive/
└── prior-orders.csv#Attach the Directory
from daita import Agent, LocalDirectorySource
async with await Agent.open("exports") as agent:
source = await agent.attach(
LocalDirectorySource(
"/absolute/path/exports",
name="Daily exports",
max_depth=3,
max_files=100,
max_file_bytes=2 * 1024 * 1024,
max_rows=100_000,
)
)
resources = await agent.list_catalog_resources(source_id=source.id)
for resource in resources:
print(resource.id, resource.name, resource.revision)
result = await agent.run(
"Summarize orders.csv by status and identify missing customer IDs.",
source_id=source.id,
)
print(result.final_text)Only .csv and .json resources within the admitted root are discovered. Symlinks, path escapes, non-regular files, and files outside the configured bounds are rejected.
#Preview the Catalog
The catalog loop in the example shows the stable resource identity used by the model-facing read tool. The model never supplies an arbitrary filesystem path.
#Analyze a File
The final run() lets the agent use data_read_file, which returns a bounded row projection with truncation and revision facts. The agent should describe limits when it has not seen the complete resource.
#Refresh the Snapshot
After adding or replacing files:
Call await agent.refresh_source(source.id) while the agent is open.
Daita checks containment and file identity again at read time. A replaced or changed file is rejected until refresh commits its new catalog revision.
See CSV and JSON for discovery and containment details.