Function tools
tools into your agent workflow. Keep the JSON response intact unless you have a reason to trim it; the doc_id, search_id, and provenance fields are the useful part of the result.
Search, then read
The strongest pattern is a two-step loop:caesar_search(query, max_results=5)to find candidates.- Pick the most relevant
doc_id. caesar_read(doc_id, query="what the agent needs")to fetch clean markdown.- Send feedback through the SDK if a result helped.
For agents
- Return JSON from the tool when possible. It preserves snake_case fields and prevents accidental loss of
doc_id. - Prefer
verbosity="compact"for the search tool. Read the selected document for longer evidence. - On truncated reads, continue with the returned
start_charvalue instead of asking for a largermax_chars. - If your LlamaIndex runtime can consume MCP tools directly, use the remote MCP server and skip custom wrappers.