---
name: split-bill
description: Calculate how much each person owes when splitting a bill, including optional tax, tip, fixed-tip precedence, and round-up support.
tool_mapping:
  splitBill: scripts/main.js
---

# Split Bill

## L2 Instructions

When the user asks to split a bill:

1. Identify the subtotal and number of people from the request.
2. Collect any optional tax rate, tip rate, fixed tip amount, and round-up preference the user provides.
3. If a required value is missing, invalid, or ambiguous, ask a short follow-up question before using the tool.
4. Call `splitBill` with the resolved values.
5. Summarize the subtotal, tax, tip, total, and per-person amount in plain language.
6. If both `tip_rate` and `tip_amount` are provided, treat `tip_amount` as the value that takes precedence.
7. If `round_up` is enabled, mention that each share is rounded up to ensure the full bill is covered.

## Tool Definitions

### `splitBill(subtotal, num_people, tax_rate, tip_rate, tip_amount, round_up)`

Calculates the total bill and each person's share.

**Parameters**

- `subtotal` (`number`): Pre-tax, pre-tip bill amount.
- `num_people` (`integer`): Number of people splitting the bill.
- `tax_rate` (`number`, optional): Tax percentage to apply to the subtotal.
- `tip_rate` (`number`, optional): Tip percentage to apply to the subtotal.
- `tip_amount` (`number`, optional): Fixed tip amount. Takes precedence over `tip_rate`.
- `round_up` (`boolean`, optional): When `true`, round each person's share up to the nearest cent.

**Returns**

```json
{
  "subtotal": 85.5,
  "tax_amount": 7.27,
  "tip_amount": 17.1,
  "total": 109.87,
  "per_person": 36.63,
  "num_people": 3
}
```

## Validation Rules

- `subtotal` must be greater than `0`.
- `num_people` must be an integer greater than or equal to `1`.
- `tax_rate`, `tip_rate`, and `tip_amount` must be greater than or equal to `0` when provided.

## Tool Mapping

- `splitBill` → `scripts/main.js`
