# A parcel that never came — a case owned until it is right, closed, and opened again

> A tea shop's customer reports that her order has not arrived. The shop opens an assignment: a piece of work it owns until she has her tea or her money back, with two things that must be true for it to be done. An agent finds out what happened and keeps the evidence; the customer is asked what she wants; the agent refunds her; support records the decision and closes the case. A week later the refund has not reached her bank, and she opens it again. Nothing is lost, and nothing is refunded twice.

<!-- id: agent-story-delivery · area: agent · stability: preview · html: https://osysharp.com/reference/agent/story-delivery/ -->

> **You are here:** [Agents in an Osy# app](https://osysharp.com/reference/agent/overview/) › Stories › A parcel that never came

## Summary        {#summary}
The other two stories are processes: the steps are known before anything starts. This one is not. A parcel is
missing, and nobody knows yet whether it is late, lost, or sitting with a neighbour. What the shop does know is the
outcome it owes: **the customer has the order, or her money back.**

Work like that is an [[agent-guide-glossary#assignment|assignment]]. It says who asked, what outcome is wanted,
and what must be true for it to be done. Everything else is attached to it as it happens.

## Description    {#description}

### Who is involved?   {#people}

| Person | Their part | What they may do |
|---|---|---|
| Nora Lind | the customer | report a problem with her own order; read her own case; reopen it |
| Sana Iqbal | support | owns this case; gives the agent work on it |
| Tim Varga | support | not on this case, so he can give the agent no work on it |
| Lars Wik | support lead | reads every case; answers for the agent; sees what it cost |

| Agent | Its jobs | What it may do alone |
|---|---|---|
| Resolver | find out where an order is; settle a lost order | in this shop, everything its jobs include: look the order up, track the parcel, record what it finds, refund the order, write to the customer |

The last cell is a choice this shop made: a refund up to the order's total is within what its support may do, and
it lets the [[agent-guide-glossary#agent|agent]] do the same. A shop that wants a person to approve every refund changes one line, and the refund
becomes a [[agent-guide-glossary#proposal|proposal]] in somebody's [[agent-guide-glossary#inbox|inbox]], as in [the bakery's story](https://osysharp.com/reference/agent/story-onboarding/).

### Tuesday morning: the report   {#report}
Nora writes that order T-1042 has not arrived, and that she needs it before Friday. The order was 42.00 euros of
tea, sent with a carrier.

The shop opens an [[agent-guide-glossary#assignment|assignment]], with Sana as its owner:

- **Outcome wanted:** the customer has the order, or their money back. "I need it before Friday."
- **Limits:** this order only. A replacement or a refund up to the order's total.
- **Done means both of these are true:**
  1. The parcel is delivered or the order is refunded.
  2. The customer has been told the outcome.
- **Wanted by:** Friday. **May spend on agents:** five cents.

### Tuesday: finding out   {#investigation}
Sana asks the **Resolver** to find out where the order is. It looks the order up, tracks the parcel, and writes
down what the carrier's scans show before it concludes anything. That is what its instructions tell it to do:

> Carrier scans for PL7731. Last scan 6 March, Malmö depot: damaged, held. Nothing since.

That note is not a line in a log. It is an **item** in the case's repository: a piece of evidence, with who added
it (the Resolver's own account), where it came from (the carrier's tracking), and which piece of work it was
written in. The Resolver's conclusion is kept as a second item, a finding: the parcel is lost; suggest a refund. A
finding from an agent is marked *unverified* until a person accepts it.

The agent's work is finished. **The case is not.** Its page says exactly why: two of two things are not yet true.
Finished work completes nothing; only the outcome does.

### Tuesday to Wednesday: asking the customer   {#asking}
Sana asks Nora: "The parcel was damaged on the way. A replacement next week, or a refund?" The case now says it is
waiting, and on whom: Nora Lind.

Twenty hours later Nora answers: "A refund, please. Next week is too late." Her answer is kept as an item too.

### Wednesday: settling it   {#settling}
Sana asks the Resolver to settle the order. It refunds 42.00 euros, with the reason "lost in transit", and writes
the confirmation to the customer.

Then a person puts her name to what was decided. Sana records the decision — "Refund in full: lost in transit; the
customer chose a refund over a replacement" — and accepts it as within what support may refund. That decision is
what the first condition is met **with**: anybody who later asks why this case counted as resolved is one click
from the decision, and from the evidence under it.

Sana tells Nora. The second condition is met. Both are true now, so the case can be closed, and it is, with a
summary and one thing still to watch: "Watch that the refund reaches the customer's bank."

### What did it leave behind?   {#left}
Lars, the support lead, reads the closed case:

- **Eight items:** the carrier's scans, two findings, the decision, and four letters — what the customer was asked,
  what she answered, the refund confirmation, and what she was told.
- **Four pieces of work,** in order: find out where the order is; ask the customer; settle the order; refund the
  order.
- **What it cost:** two pieces of agent work and a closing summary, against the five cents the case may spend. The
  agent's work is charged to the case as it is spent, and a case whose money is spent starts no more agent work.

The amounts in the test are fractions of a cent, because its [[agent-guide-glossary#model|AI model]] is a scripted stand-in with made-up prices.
What the test checks is that the three add up.

### A week later: it comes back   {#reopened}
The refund has not reached Nora's bank. She reopens the case, and says which condition is no longer true: the
first.

- The case is open again, and says it was reopened once.
- "The order is refunded" is back to not met. "The customer has been told" is still met.
- All eight items and all four pieces of work are still there.
- When the refund is asked for again, it is **not made twice**. The answer is: "Already refunded: 42.00 EUR
  refunded: Lost in transit."
- And the case cannot be closed again by saying "done": it refuses while a condition is unmet.

That is where the test ends, and where a person takes over: somebody has to find out what happened to the money.
The case will not let itself be closed until they have.

### What else is tested on this case?   {#edges}
The awkward things that happen to long-running work, each a test of its own:

- **The agent's work dies half-way.** The case still says what it was waiting for. Asked again, the work is run
  again; the dead attempt is called off and closed.
- **It dies after the refund.** Asked again, the agent is told the refund was already made. One refund.
- **The work had already finished.** Asked again, it is answered from its [[agent-guide-glossary#receipt|receipt]]. No AI model is called.
- **The money runs out.** The work is stopped, what it found is kept, and the case can be ended as failed with a
  note of what was and was not done.
- **Somebody who is not on the case** cannot give the agent work on it.
- **The case is called off** — the customer found the parcel at a neighbour's — and the agent's running work is
  called off with it.

### What does an assignment look like on screen?   {#screens}
The tea shop's test app has no screens of its own: its tests are about the case, not about pages. The two kits it
uses draw these, shown here from their own test apps, a workshop that repairs machines and a company hiring a
consultant.

![An assignment's page: a press that faults; open, blocked, overdue and stalled; one of three conditions met; where it stands; the work attached; what it has cost](https://osysharp.com/media/ref/364e22-assignment-stuck-wide.png)

*An assignment that is stuck says so, and says why, without anybody typing a status.*

![An item with its versions: the version that stands, one waiting to be reconciled, and the first](https://osysharp.com/media/ref/8d0171-item-versions.png)

*An item is never overwritten. Each version says who wrote it.*

### Where is this written down?   {#source}
In the test app of the kit that joins assignments and agents:
`a_delivery_case_is_carried_from_the_customers_report_to_a_verified_outcome_and_opened_again`. No AI model is called
in it.

## What to read next   {#read-next}
- [What stays under people's control — ten promises, and where each is shown](https://osysharp.com/reference/agent/overview-control/) — the ten promises behind all three stories
- [What release 1 does not include](https://osysharp.com/reference/agent/overview-not-included/) — the plain list of what is left for later
- [Building with agents — the developer's guide](https://osysharp.com/reference/agent/guide/) — for developers: how all of this is built

## Go deeper   {#see-also}
- [Assignments — a piece of work owned until its outcome is reached (Assignments kit)](https://osysharp.com/reference/agent/assignments/) — criteria, reopening, progress, cost
- [Work repositories — what an assignment knows, kept as items (WorkRepositories kit)](https://osysharp.com/reference/agent/work-repositories/) — items, versions, who wrote what
- [[agent-guide-choosing#assignment-or-process]] — for developers: an assignment or a process?
- [Osysharp.Assignments.Agents — an agent's work, attached to the assignment it is for](https://osysharp.com/reference/agent/kit-assignments-agents/) — the kit this story's app tests
