Four people share a house. Some bills are split by days at home, and some by name. Leftover cents follow a rule.
The first try asks the model to work out the shares itself. It shows its working and sounds sure. Several figures still come out wrong.
The model writes a short program. Your code runs it in a sandbox and checks the result.
- The model writes the program.
- The sandbox runs it with strict limits.
- A guard checks the names and that the shares add up to the bills.
For example, a program that loses one cent is sent back to be fixed.
sequenceDiagram
participant Code as Your code
participant Model
participant Runner as Sandbox
Code->>Model: write a program for these bills
Model-->>Code: program
Code->>Runner: run it
Runner-->>Code: shares
alt the shares add up
Code->>Code: use them
else they do not
Code->>Model: say what failed
end
uv run lab code-execution naive
uv run lab code-executionAdd --case 2 or --case 3 to try the other cases.
There are three months of bills. Code works out every true share. It counts shares that are right to the cent, out of 12. More is better.
| Version | Right shares |
|---|---|
| Model works it out | 8 |
| Model writes code | 12 |
Now break it. Open the pattern file and find check_shares. Make it return an empty list. Then run the test:
uv run pytest tests/promises/test_code_execution.pyThe test fails, because shares that do not add up are now accepted.
- A refused import means the program used something outside the safe list.
- The check proves the total, not the split. A program can add up and still be unfair.
This sandbox stops mistakes, not attackers. Use a container or a virtual machine for code you do not trust. Never give the program your keys or files.
Go to Load skills on demand. It keeps long rules out of the prompt.