1ab0000chore(lab):sandbox tools · everything runs in your browser
The Lab.
Small tools for the work behind the lessons. Break things here; nothing leaves your browser and nothing runs on a server.
Stuck? Trace it. Every tool is a deterministic simulation. No model is called and no code you type is executed.
1ab0001tool:validate a tool call
Tool-call validator
The same contract as the tool calling lesson, with every check switched on.
- amount_cents must be an integer number of cents, got "6400". Example: 6400 for 64.00.
1ab0002tool:compare starter and solution
Shift to compare
Taught here only: hold Shift on a desktop keyboard to peek at the starter beside the solution. The button does the same on any device.
export async function handleToolCall(raw: string, attempt = 1) { const parsed = safeParse(raw); if (!parsed.ok) return retryOrHandOver("Your tool call was not valid JSON.", attempt); const errors = validate(refundSchema, parsed.value.arguments); if (errors.length) return retryOrHandOver(errors.join(" "), attempt); const args = parsed.value.arguments as RefundArgs; if (args.amount_cents > APPROVAL_LIMIT_CENTS) return queueForApproval(args); return issueRefund(args);} function retryOrHandOver(message: string, attempt: number) { return attempt < 2 ? { role: "tool", content: `Error: ${message} Fix the arguments and call again.` } : handOverToPerson(message);}Showing the solution. Open compare view to see the starter beside it.
1ab0003tool:estimate tokens and cost
Token and cost estimator
- characters
- 95
- words
- 15
- tokens (≈ chars / 4)
- 24
- fast input / day
- 0.0120 (illustrative price)
- careful input / day
- 0.1200 (illustrative price)
Real tokenizers differ by model and language. Use this to compare options, not to budget.
1ab0004docs:bigger sandboxes