A pharmacy parcel never reached the patient. Records point to other records, such as a driver log or a swap note.
The first try has the same tool and the same step limit. It looks things up without saying why. It gets no nudge when it repeats itself. We wanted to see if reasons help.
This is ReAct, an agent loop. The model gives a reason, uses a lookup tool and reads the result.
- The model says why it wants a record, then asks for it.
- Code returns the record. This is the observation.
- The model reads it and picks the next lookup.
- A repeat lookup gets a nudge, so the loop moves on.
For example, the driver log names a swap note. Only then can the model ask for it.
sequenceDiagram
participant App as Your code
participant Model
loop until it can answer
Model->>App: reason and lookup
alt the record is new
App-->>Model: the record
else it was read before
App-->>Model: look somewhere new
end
end
Model-->>App: where the parcel is
- An agent loop repeats think and act.
- An observation is what comes back from a move.
- The lookup is a tool.
uv run lab react naive
uv run lab reactAdd --case 2 or --case 3 to try the other cases.
There are three lost parcels. Code checks that the answer names the true place.
| Version | Parcels traced |
|---|---|
| Act only | 3 |
| Reason, then act | 3 |
The pattern did not win. Both versions traced every parcel.
Now break it. Open the pattern file and find observe. Make it return the record every time. Then
run the test:
uv run pytest tests/promises/test_react.pyThe test fails, because the same record can be read again with no nudge.
- A "no key found" message means the key file is missing. Copy the example file and paste your key.
- If you see "no answer within the step limit", the trail was longer than the limit.
These trails are clear, with each record naming the next. A messy trail may treat the two versions differently. That was not measured.
Every turn sends the history again, so long trails cost more.
Go to Verify every step. It checks that each move really worked.