# What Was Our Food Cost Last Week? A Restaurant Back-Office App Reads Each Kitchen's Inventory Sheets in Google Drive

A restaurant back-office app makes one agent per restaurant, signed into its Google Drive, that works out last week's food cost from its inventory count sheets.

[Run this on Rush](https://cloud.getrush.ai/run/calculate-weekly-food-cost-from-inventory-sheets/google-drive/). Opens the console with this prompt ready to send. Connect Google Drive there first.

## What the agent does

This is for a company that sells back-office software to independent restaurants: sales from the point-of-sale system, labor from the schedule, and a weekly report the owner reads on Monday. The number owners ask for most is food cost, and the data for it lives where the kitchen already keeps it: a Google Sheet per week in a Drive folder called Inventory counts, filled in by the sous chef on Sunday night, and a Purchases sheet where invoices are logged. The software saves one agent as a template that names Google Drive, and makes one agent per restaurant, signed into that restaurant's own Google account.

The software company connects its own Google Drive and saves the template with `POST /o/{org}/agents` and `"connections": ["google-drive"]`. When a restaurant turns the report on, the backend calls `POST /o/{org}/agents {"template": "<template id>", "name": "foodcost-<restaurant id>"}`, then `POST /o/{org}/agents/{agent}/connections {"type": "app", "name": "google-drive"}`, and opens the `authorize_url` for the owner, who signs in on Google's page. Rush's Google Drive sign-in asks for reading Drive, files the app creates, and Google Sheets, and the run reaches the Drive and Sheets REST APIs with a token Rush signs outside the agent's computer.

On a run the software passes last week's food sales from the point-of-sale system and the dates. The agent finds the folder with the Drive API's `files.list`, then lists the spreadsheets in it with a `q` on the folder as parent and the spreadsheet MIME type, and picks the count sheets for this Sunday and last Sunday by name. It reads each one's rows with the Sheets API `spreadsheets.values.get`: item, unit, count and unit cost. It reads the Purchases sheet rows dated within the week. Then it computes food cost the usual way: opening inventory value plus purchases minus closing inventory value, divided by food sales.

Alongside the number it checks what makes the number wrong: an item counted last week and missing this week, a unit cost blank or changed by more than a quarter, a count that jumped tenfold (a case typed as units), and purchase rows with no supplier. Each is listed with its sheet, row and value, so the chef can fix the sheet rather than the report. The agent edits nothing: the template's instructions forbid any write to Drive or Sheets, even though the Sheets permission would allow one.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "<agent id>",
  "input": "Compute food cost for the week 2026-11-16 to 2026-11-22. Food sales from the POS for that week: 18432.50. In Google Drive, find the folder named Inventory counts with files.list, then list the spreadsheets in it (mimeType application/vnd.google-apps.spreadsheet, that folder as parent). Opening count: the sheet named Count 2026-11-15. Closing count: the sheet named Count 2026-11-22. Read each with spreadsheets.values.get on range A:E (item, unit, count, unit_cost, location). Read the spreadsheet named Purchases, range A:F (date, supplier, invoice_no, item, category, amount), and keep rows dated 2026-11-16 to 2026-11-22 with category food. Food cost = (opening value + food purchases - closing value) / food sales, where value = count x unit_cost. Return only JSON: {opening_value, purchases, closing_value, food_sales, food_cost_percent, problems: [{sheet, row, item, kind (missing_item, blank_cost, cost_change_over_25_percent, count_jump_over_10x, purchase_without_supplier), value}]}. If a sheet is not found, return {error: 'sheet_not_found', name}. Do not edit, create, move or share any file or cell."
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

The agent works out last week's food cost percentage from the kitchen's inventory sheets and lists the problems it found in the count sheet. The answer is JSON in the session's `result` and the `run.completed` webhook. The back-office software puts the food cost percentage into Monday's report beside last week's, and lists the problems underneath as things to fix. Once the chef fixes a row, the owner presses Recalculate and the same request runs again on the corrected sheet.

What the owner checks: the sales figure, which comes from the point-of-sale system and decides the percentage as much as the counts do; any item the agent flags as a tenfold jump, which is usually a typing slip; and whether a big catering order landed in the week, which raises purchases before it raises sales. The agent reports the arithmetic and the problems it found, not whether the kitchen is doing well.

## Run it on every Monday morning, per restaurant

The software's scheduler sends one `POST /o/{org}/sessions` per restaurant on Monday at 6 a.m. local time, with that restaurant's agent id as `agent`, the week's dates and sales in `input`, and a `request_id` that is a UUID v5 of the restaurant id and the week, so a retry does not start a second run. A group with four sites has four agents and gets four runs, one per Google account.

When a restaurant's count is late, the run returns `sheet_not_found` with the missing name, and the software sends the chef a reminder instead of a report built on half the data.

## Why run it on Rush?

Each restaurant signs in on Google's own page, and that sign-in belongs to its own agent: one restaurant's run cannot read another's Drive, and the software company stores no Google token and registers no Google app. Rush asks Google only for Drive and Sheets on that account, and the session's `accounts` names which Google account each run used.

One template serves every restaurant, so when the software adds a check, such as waste logged on a separate tab, it is one `PATCH` to the template and every restaurant's next run has it. Each run has its own computer and a record of every Drive and Sheets call and what its model calls cost, which the company totals per restaurant with `GET /o/{org}/sessions?agent=<agent id>`.

## Frequently asked questions

### Our count sheets have different columns. Does that matter?

The column ranges are in the prompt, so the software can store each restaurant's layout and send it with the run. The agent reports a sheet whose headers do not match instead of guessing which column holds the cost.

### Can the agent fix the mistakes it finds?

The Google Sheets permission would let it, but the template forbids any write. A wrong count is the chef's to correct, since only the kitchen knows whether there are 4 cases or 4 units of cream on the shelf.

### Does it see everything in the owner's Google Drive?

The sign-in can read the owner's Drive, so the prompt names one folder and two kinds of sheet, and the transcript shows every file the agent listed and opened. An owner who wants a narrower reach can keep the kitchen sheets under a separate Google account used only for the restaurant.

### Is the food cost figure what our accountant uses?

It is the common weekly calculation from counts and purchases, useful for running the kitchen. Accountants work from the books at month end with their own adjustments, and the two can differ; the report says which inputs it used.

## More Google Drive jobs

- [Check Each Brokerage's Deal Folders in Google Drive for Missing Documents](https://getrush.ai/run/check-deal-files-for-missing-documents/google-drive/)
- [How Can a Property Manager Compare Each Building's Monthly Spending to Its Budget? An Agent That Reads Every Property's Sheet in Google Drive](https://getrush.ai/run/compare-each-propertys-budget-to-actuals/google-drive/)
- [RFP Response Drafts From Past Proposals in Drive](https://getrush.ai/run/draft-rfp-responses-from-past-proposals/google-drive/)

## More jobs like this: Run an agent per customer task

- [Call Every New Inbound Lead Within Minutes and Post the Outcome to Slack](https://getrush.ai/run/call-new-leads/lumisreach/)
- [Turn Buyer Inquiries in Each Real Estate Agent's Gmail Into CRM Leads](https://getrush.ai/run/capture-buyer-inquiries/gmail/)
- [How Can Bill-Pay Software Pick Up Vendor Invoices From Each Customer's Outlook? One Agent per Business, With Read-Only Mail Access](https://getrush.ai/run/capture-vendor-invoices-from-the-inbox/outlook/)

## Keep reading

- [Connect Google Drive to Rush once, then name it on any run](https://getrush.ai/integrations/google-drive/)
- [Start your first run from the developer API quickstart](https://getrush.ai/docs/quickstart/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
