TOOL WIKI · AGENT SDKS
LlamaIndex
Provides components for connecting data, retrieval, and agent workflows.
Jump to a section 10 sections
EXAMPLE USE CASE
Use a function tool in a LlamaIndex agent
A developer needs a small, observable agent or retrieval step before connecting real business services.
- Input
- An order_status function and an A104 status request.
- Expected output
- The status from the tool result in the final answer.
- Success check: The answer uses the fixture result for A104: packed. Ask about A999 to verify the missing-record path.
- Try a failure: Ask about A999 and inspect whether the missing-record result is preserved.
Example scope: Actual FunctionAgent workflow; document ingestion is not part of this example.
Official reference · LlamaIndex
Authenticate the request and define the goal before calling the framework.
Agents whose work depends heavily on a document or knowledge corpus. Validate ingestion and retrieval quality separately from orchestration.
invokeTo 03 · Model providertool callTo 04 · Tool servicemeasureTo 06 · EvaluationThe application supplies provider credentials, model selection, and budgets.
decisionBack to 02 · LlamaIndexValidate each operation and return authoritative observations.
resultBack to 02 · LlamaIndexChoose the checkpoint or session store and its retention policy deliberately.
Result or stopping pointCheck completion, cost, latency, and tool behavior against fixtures.
Result or stopping point
Agents whose work depends heavily on a document or knowledge corpus. Validate ingestion and retrieval quality separately from orchestration.
When to consider it
- Agents whose work depends heavily on a document or knowledge corpus.
A design decision to make
- Validate ingestion and retrieval quality separately from orchestration.
Prerequisites and setup
- Python 3.11+ in an empty directory. A compatible model and provider credentials are required.
- Running the model-backed example can incur API charges; this website displays it without calling a provider.
python3 -m venv .venv
source .venv/bin/activate
pip install llama-index-core llama-index-llms-openai
export OPENAI_API_KEY="YOUR_API_KEY"
export OPENAI_MODEL="YOUR_ENABLED_MODEL"Try a small integration
example.py
import asyncio
import os
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
def order_status(order_id: str) -> str:
"""Look up the authoritative demo order status."""
return {"A104":"packed"}.get(order_id,"not_found")
async def main():
agent = FunctionAgent(tools=[order_status],
llm=OpenAI(model=os.environ["OPENAI_MODEL"]),
system_prompt="Use the order_status tool and answer only from its result.")
print(await agent.run("Read the status of order A104."))
asyncio.run(main())Run and check the result
python example.py- The answer uses the fixture result for A104: packed. Ask about A999 to verify the missing-record path.
- Inspect the tool invocation or trace; a correct-looking sentence alone does not prove the tool ran.
Common failures
- 401 or model-not-found: verify the provider key, project and configured model identifier.
- A repeated tool call needs a bounded loop and a clear not-found result; do not raise limits blindly.
Production decisions
- Bind tool execution to the authenticated user and resource permissions. Keep keys in server environment variables.
- Add deadlines, a turn budget, redacted traces, regression fixtures and explicit handling for refused or incomplete runs.
Keep exploring
Explore the same layer
Compare candidates on your own workload. This entry describes a product’s role; it is not a claim that products in the category are interchangeable.