Problem

The answer depends on who is asking, and the employee should not have to know that.

"How much maternity leave do I get?" is one question with several answers. The global policy says 16 weeks. In India the law says 26, and the higher number wins. In the US the 16 weeks run alongside 12 weeks of job protection, not on top of them. Whether you qualify depends on how long you have been here, measured differently in each country. And how to apply is a third document.

An employee should not have to know which of those documents apply to them. They should type the question and get their answer. A single search returns one passage from one document, and that passage is wrong for half the company. This use case is what I built when one search was not enough.

Solution

Retrieval as the reasoning.

The assistant resolves who is asking, reads the global policy, notices that it defers to a country supplement, fetches that supplement, reconciles the two, checks eligibility against the employee's start date, pulls the procedure, and only then answers, with a citation on every fact. Then it turns the answer into a leave of absence: a start date, a computed return date, the document HR needs, and a request routed to the manager for coverage and to HR for eligibility. No PTO is deducted because none applies. The trace, the list of steps under the answer, shows all of it.

The demo as Ananya: one answer, every line cited, and the seven steps that produced it, including the second search the first one asked for.
The demo as Ananya: one answer, every line cited, and the seven steps that produced it, including the second search the first one asked for.
How much maternity leave do I get?

Ananya, here is what applies to you as an employee based in India:

Entitlement: 26 weeks of paid maternity leave, up to 8 weeks of it before the expected delivery date India Leave Supplement / Maternity leave entitlement. The global policy's 16 weeks is the floor and the India entitlement is higher, so it applies Parental Leave Policy / Country supplements.

Pay: 100% of base for the full 26 weeks India Leave Supplement / Pay during leave.

Eligibility: you need 80 days worked in the 12 months before the expected delivery date. You joined on Mon, Jun 10, 2024, so you qualify India Leave Supplement / Eligibility.

To apply: at least 30 days before the leave starts, with a maternity certificate from a registered medical practitioner stating the expected delivery date. The request goes to Rohan Mehta to acknowledge coverage and to HR to confirm eligibility Leave of Absence Procedure / How to apply.

Want me to start the request? Tell me your expected delivery date, or the date you'd like the leave to begin.

  1. orchestratorIntent: parental leave (rule: matched "maternity"). Routed to the parental leave agent, 5 tools.
  2. resolve_askerAnanya Iyer · based in India · full-time · with the company since Mon, Jun 10, 2024 (820 days)
  3. search_policiesFound the Parental Leave Policy: 16 weeks birthing, 12 weeks non-birthing. It defers to a country supplement where local law gives more, so one document is not enough.
  4. search_policiesFound the India Leave Supplement: 26 weeks under the Maternity Benefit Act, up to 8 weeks before the expected date.
  5. reconcileGlobal 16 weeks vs India statutory 26 weeks: the higher entitlement applies, so 26 weeks paid.
  6. check_eligibilityEligible: 820 days of service against a 80-day minimum.
  7. search_policiesPulled the Leave of Absence Procedure: 30 days' notice, routes to Rohan Mehta for coverage and to HR for eligibility, HR replies within 5 business days.

Then Sarah, an engineer in California, asks the identical question. She has access to the US supplement, not the India one, so the loop finds a different second document and reconciles differently: 16 weeks paid, 12 weeks of FMLA job protection running concurrently, state paid family leave coordinated by HR. The India supplement is never named, because she has no reason to know it exists.

How much maternity leave do I get?

Sarah, here is what applies to you as an employee based in the United States:

Entitlement: 16 weeks of fully paid leave for a birthing parent, 12 weeks for a non-birthing parent US Leave Supplement / Company paid leave.

Job protection: up to 12 weeks under FMLA, running concurrently with the paid leave US Leave Supplement / Job protection under FMLA. State paid family leave, where it exists, is coordinated by HR so pay stays at 100% US Leave Supplement / State programs.

Eligibility: you need 90 days of service. You joined on Mon, Nov 8, 2021, so you qualify Parental Leave Policy / Eligibility.

To apply: at least 30 days before the leave starts, with a medical certification form from your healthcare provider giving the expected due date. The request goes to Jordan Park to acknowledge coverage and to HR to confirm eligibility Leave of Absence Procedure / How to apply.

Want me to start the request? Tell me your expected due date, or the date you'd like the leave to begin.

  1. orchestratorIntent: parental leave (rule: matched "maternity"). Routed to the parental leave agent, 5 tools.
  2. resolve_askerSarah Kim · based in the United States · full-time · with the company since Mon, Nov 8, 2021 (1765 days)
  3. search_policiesFound the Parental Leave Policy: 16 weeks birthing, 12 weeks non-birthing. It defers to a country supplement where local law gives more, so one document is not enough.
  4. search_policiesFound the US Leave Supplement: 16 weeks company paid; FMLA job protection 12 weeks, running concurrently.
  5. reconcileCompany paid leave 16 weeks; FMLA job protection 12 weeks runs concurrently, not on top. 16 weeks paid applies.
  6. check_eligibilityEligible: 1765 days of service against a 90-day minimum; FMLA job protection applies (12+ months of service).
  7. search_policiesPulled the Leave of Absence Procedure: 30 days' notice, routes to Jordan Park for coverage and to HR for eligibility, HR replies within 5 business days.

Captured from the running demo. The day counts in the trace move with the date.

Same words to the assistant, different documents behind it, different answer, different form. That is the persona story at its sharpest, and it is why this use case sits second in the demo, right after search.

Ask asGlobal policySupplement in scopeReconciled entitlementEligibility check
Ananya, India16 weeksIndia: 26 weeks, 8 pre-natal26 weeks paid80 days worked in the prior 12 months
Sarah, US16 weeksUS: FMLA 12 weeks concurrent16 weeks paid, 12 protected90 days of service; FMLA at 12 months
Marcus, contractor16 weeksnonenot eligibleContractors are excluded by the global policy
Architecture and flow

Same front door. A search that knows when to search again.

The time-off agent uses search as one small tool and the hard part is planning. Here the hard part is the search itself: knowing that the first document points to a second, choosing the second by who is asking, and reconciling the two before anything else can happen.

Employee
One conversationThe same assistant as use case 01. "How much maternity leave do I get?" in plain words.
Front door
Same sign-in and orchestrator as use case 01Who you are and your groups from the sign-in; an orchestrator that hears maternity, parental, adoption, or leave of absence and hands the turn here. How that works.
Parental leave agent
Claude, with five toolsRuns the assessment, reads what came back, asks for a date if it needs one, drafts, and submits on your yes.
Five tools. Four read or draft, one writes.
  • search_policiesthe global policy, your country supplement and the procedure, each cited
  • assess_parental_leaveresolves your country, reconciles global with supplement, checks eligibility from tenure, returns weeks, pay, documents and routing
  • get_time_off_requestsyour existing requests
  • propose_leave_of_absencedrafts the leave from the entitlement and your start date. Submits nothing
  • submit_time_off_requestwritethe only tool that changes the HR system. A start date drafts, only a yes submits
Inside the assessment
1. Read the global policySixteen weeks. It says a country supplement may give more, so one document is not enough.
2. Get your supplementThe one for your country, found by a second search. A contractor gets none, which is the answer.
3. Reconcile and checkHigher entitlement wins, or the weeks run together. Then eligibility against your start date, and the procedure. Every number with its section.
Systems
Policy libraryThe global policy, each country supplement, and the procedure, indexed with their permissions.
HR recordCountry, hire date, employment type. Read, never asked.
Manager and HRThe request goes to your manager for coverage and to HR for eligibility.
Always on
The yes gateA start date drafts. Only an explicit yes submits.
The traceEvery search, the reconcile, the eligibility check, in order.
The evalsSeven cases: both countries, the contractor, and the cross-leak.

The difference from use case 01 is inside the assessment: it searches more than once, and each search is chosen by what the last one said. That is what makes it agentic RAG.

The guardrails, and the test that proves each one

Each rule below says where it lives in the code, what you see when it stops something, and the test that would fail if it broke.

The ruleWhere it livesWhat you seeProof
Two countries, two answers, and nothing bleeds acrossthe supplement is chosen from the country on the HR record, not from the questionAnanya gets India’s 26 weeks. Sarah gets the US 16. Neither sees the other’s rules.leave-03
Eligibility is read from the recordcountry, hire date and employment type are read inside assess_parental_leaveA contractor is told they are not eligible, and nothing is drafted.leave-04
A date drafts, a yes submitsthe same confirm gate as use case 03The draft shows weeks, pay and documents, then waits.leave-05
Changing your mind moves the drafta second date updates the pending request instead of making anotherYou end up with one request and a new start date.leave-07
Parental leave does not touch your PTOa leave of absence is its own request typeApproval leaves the PTO balance where it was.leave-06
Every number carries its sectionthe assessment returns citations from the global policy and the country supplementWeeks, pay and documents each cite the document and section they came from.leave-01leave-02

The flow, in six steps.

  1. You ask, and the orchestrator sends it to the leave agent.

    Maternity, parental, adoption, or leave of absence, and the turn goes here rather than to plain search.

  2. The agent looks up who you are.

    Country from your location, tenure from your hire date, whether you are a contractor. From the record, never from the question.

  3. It reads the global policy and notices it defers.

    Sixteen weeks, and a line saying local law may give more. So it searches again, this time for your country's supplement. Sarah's search never sees the India document; she does not have access to it.

  4. It reconciles and checks eligibility, in code.

    India: 26 weeks, the higher number. US: 16 weeks paid, 12 protected, running together. Then your days of service against the rule, and a third search for how to apply.

  5. You get one answer with a citation on every line.

    Entitlement, eligibility, and the procedure, each with the section it came from. Then: want me to start the request?

  6. A date drafts it. A yes sends it.

    The draft shows the start date and the computed return date, with no PTO deducted. Your yes sends it to your manager for coverage and to HR for eligibility, and both are told.

Evaluation framework

Both countries, the contractor, and the cross-leak.

Seven cases in the suite cover this loop, and they check the trace as well as the text. Ananya gets 26 weeks, and the trace shows resolve, more than one search, reconcile, and an eligibility check, in that order. Sarah gets 16 weeks and 12 under FMLA, and her answer never contains 26 weeks or the word India. When Ananya asks outright what is in the US Leave Supplement, the answer abstains and names no source, and the same holds for Sarah asking about India. A contractor is told they are not eligible and nothing is drafted. A due date opens the 8-week window, a start date drafts, and a yes submits to the manager and to HR. Approval never touches the PTO balance. A second date given before confirming moves the start instead of opening a new request. The latest run passes all seven, and all 67 in the suite. The method is in the evals chapter.

CaseWhat it checksCategory
leave-01Ananya (India): 26 weeks, reconciled from global policy and India supplementLeave
leave-02Sarah (US): 16 weeks paid, FMLA concurrent, no India rulesLeave
leave-03Same question, two countries, two answers, no cross-leakLeave
leave-04Contractor is told they are not eligible, nothing draftedLeave
leave-05India: due date opens the 8-week window, start date drafts, confirm submits to manager and HRLeave
leave-06US: start date drafts 16 weeks; approval does not touch PTOLeave
leave-07A second date before confirming moves the start, not a new PTO requestLeave

Two of these need the Python search layer up, because they check what the retrieval loop actually returned. The rest run against the local index, so the loop's logic is tested even with the search service down.

Outcome

The return here is an answer that is never wrong.

Deflection arithmetic is the wrong way to value this one. What it owns is first-answer accuracy on a question whose answer lives in two documents and changes by country, asked by someone making decisions about their family and their job at the same time.

Price the failure instead. Ananya is told 16 weeks because the assistant read the global policy and stopped. She plans her year around it, HR corrects it four months later, and the company has a statutory problem in India and a trust problem with her. Or a contractor is told they are eligible for something they do not have. Either one costs more than a year of deflected tickets saves.

This is the use case where deflection is the wrong target. Reward it here and you buy confident wrong answers, because the fastest way to end a conversation is to answer from the first document you find. The bar is the seven cases in the suite: the right number for the right person, the cross-leak refused in both directions, the contractor told no, and tenure checked before anything is drafted.

Owns · the number this answers for
First-answer accuracyThe entitlement is right for that person and that country, with both sources cited7 of 7 in the suite
Moves · what follows if it works
Specialist escalationsCountry-specific leave questions that reach an HR specialist↓ over time
Question to filed requestDays from asking to a leave request sitting in the manager's queue↓ over time
Guardrail · never traded for the number
Cross-population leakAn India answer reaching a US employee, or either reaching a contractor0
Unsupported eligibility claimA benefit asserted that the documents do not grant0

How this one is valued next to the other three is on the business case.

What I learned

Retrieval is a decision, not a lookup.

  1. Write the deferral into the document.

    The global policy says, in plain text, "see your country supplement." That sentence is what makes the second search a reasoned step instead of a hardcoded one. Corpus design is agent design.

  2. Ground before you rank.

    With nine documents the offline embedder started returning the India supplement for an executive-only question. A lexical grounding check, the top passage must share key terms with the question, fixed it, and the eval caught it before a demo did.

  3. Say what the numbers are.

    The demo policies are consistent with the statutes as I understand them and they are demo policies, not legal reference. The assistant says HR confirms eligibility, and it means it.

How you can build this

How to build this yourself.

Start from a working, permission-aware search. Then teach it to search twice. Six steps.

  1. Write the one-page spec first.

    Who the users are, which tools only read and which write, what each write needs before it runs, and what the assistant must never do. Write the acceptance transcript too: the conversation that has to work, word for word. I built this one first, deciding the rules as I went, and wrote the spec afterward. The spec is where those rules turned into decisions I could see and defend. Write it before the second use case at the latest.

    Prompt

    Here is what I want the assistant to do and for whom. Draft a one-page spec: users and roles, tools split into read, propose, and write, the guard each write needs, what must never happen, and one acceptance transcript. Mark every product decision you had to guess as DECIDE.

  2. Write the deferral into the corpus.

    The global policy has to say, in plain text, that a country supplement can give more. That sentence is what turns the second search into a reasoned step. If your real policies already say it, you are ahead. If not, that is a policy fix before it is an engineering one.

    Prompt

    Here is our parental leave policy and two country supplements. Point out every place the global document defers to local rules, and rewrite any deferral that is implied but not stated.

  3. Resolve the asker before the first search.

    Country, tenure, and employment type decide which documents are in scope and which eligibility rule applies. Get them from the identity token and the HR record, not from the question.

    Prompt

    Write a resolve_asker step that returns country, tenure in days, and employment type from the employee record, never from the question, with a one-line trace entry.

  4. Make the second search depend on the first.

    Search for the global policy, read it for the deferral, then search for the supplement that matches the asker's country. For a contractor, no supplement is the answer. Every search still passes the access check.

    Prompt

    Design an assess_parental_leave tool that searches for the global policy, detects the deferral, searches again for the asker's country supplement through the same permission-filtered retrieval, and records both searches in a trace.

  5. Reconcile and check eligibility in code.

    Higher entitlement wins where local law says so; job protection runs concurrently where it does. Tenure against the country rule. These have one right answer, so they are code, not prose from the model.

    Prompt

    Write a reconcile function for India (statutory entitlement wins if higher) and the US (company paid weeks with FMLA concurrent), plus an eligibility check against days of service, returning a section citation with each number.

  6. Turn the answer into a request, behind a gate.

    Offer to start the leave. A start date drafts it with the return date computed from the entitlement and no PTO deducted. Only an explicit yes submits, to the manager for coverage and to HR for eligibility.

    Prompt

    Add propose_leave_of_absence, reuse the existing submit tool with its yes gate, and write eval cases for both countries, a contractor, and a cross-country leak.

Key terms

Definitions, in plain language.

Agentic RAG
Search inside the reasoning. The agent reads a result, decides whether it needs another document and which one, and stops when it has enough. Plain RAG searches once, before the model answers.
Deferral
A line in one document that points to another: "where local law gives more, the local supplement applies." It is what makes the second search a reasoned step.
Country supplement
The document with a country's rules on top of the global policy. Which one you get depends on who is asking, and the access check keeps the others out of sight.
Reconcile
Turning two documents into one answer by a rule: the higher entitlement wins in India; in the US paid leave and job protection run at the same time rather than adding up.
Entitlement vs. job protection
Entitlement is paid weeks off. Job protection is the promise your role is there when you return. FMLA gives the second, not the first.
Eligibility
Whether you qualify at all, measured differently by country: days worked in the prior year in India, days of service in the US. Checked in code against your record, and cited.
Yes gate
A start date drafts the leave; only an explicit yes submits it. Nothing reaches your manager or HR without it.
Resources

Worth your time.

Use case 02 of four. Next: time off →