What two new expert tasks are added to the invoice agent?
Categorizing expenditures into predefined categories and checking invoices against purchasing rules.
Why use expert tools instead of hardcoding rules?
It keeps the architecture clean, adaptable, and avoids embedding complex rule logic in code.
What does the categorize_expenditure tool take as input?
A one-sentence description of the expenditure.
What does categorize_expenditure return?
A single category name chosen from a fixed list of 20 categories.
Why is a fixed category list useful?
It constrains outputs so the agent returns consistent, valid classifications.
What persona is used for expenditure categorization?
A senior financial analyst specializing in corporate spending categorization.
What is the purpose of the purchasing rules expert?
To validate whether invoice data complies with company purchasing policies.
Why load purchasing rules from disk instead of hardcoding?
Policies can be updated without changing code, and the human-readable rules become the logic.
Where are purchasing rules stored in the example?
config/purchasing_rules.txt
What happens if the purchasing rules file is missing?
The tool defaults to “assume all invoices are compliant” (or another fallback rule).
What does check_purchasing_rules return in the basic version?
A compliance result (true/false) and a brief explanation of issues.
Why is free-text compliance output sometimes insufficient?
Other systems need predictable structure for logging, workflows, and reporting.
What does prompt_llm_for_json add to the compliance tool?
Enforces a structured JSON output that conforms to a schema.
What fields are required in the compliance JSON schema?
compliant (boolean) and issues (string).
Why is schema-enforced output important for downstream systems?
It makes results machine-readable and easy to store, trigger workflows, or aggregate.
What example rule triggers noncompliance in the case study?
Purchases over $5,000 require pre-approval.
In the example invoice, why is the purchase noncompliant?
Total exceeds $5,000 and lacks required pre-approval.
What additional policy example is given for consulting services?
Consulting fees over $10,000 require an SOW (Statement of Work).
What does the invoice agent’s updated workflow include after extraction?
Summarize expenditure, categorize it, validate against policies, store results, and report summary.
What is the one-sentence summary used for in the workflow?
As the input to the categorization expert tool.
What is the role of function calling in this updated agent?
It lets the agent invoke tools reliably using structured tool calls rather than parsed text.
Why does this example demonstrate “personas as tools”?
Categorization and compliance expertise are encapsulated in separate tools instead of the core agent prompt.
What is the advantage of separating compliance into a tool?
You can update rules, prompts, and schema without rewriting the agent’s core goals.
What is the risk mentioned even with structured extraction?
The LLM may still hallucinate, so production systems may need additional safeguards.