Caveman Cloud· Hosted & VPCTemplates & Quick Setups
Template: Deterministic Code Tools (Billing Math)
Deploy an agent that pairs LLM reasoning with a deterministic JavaScript tool for exact invoice math and threshold checks.
The ts-tools template demonstrates how to bundle custom deterministic tools beside AGENT.md under tools/*.mjs. Instead of letting a language model estimate proration arithmetic in prose, the agent calls prorate_refund, which returns exact integer cents and a boolean approval flag.
Deploy in 30 seconds#
cvm agent init ts-tools ./ts-tools
cvm agent build ./ts-tools
cvm deploy ./ts-tools --budget 1
cvm run ts-tools "Calculate the exact prorated refund for a $300 monthly invoice used for 10 of 30 days."Folder layout#
ts-tools/
├── AGENT.md # Instructions requiring deterministic tool use
└── tools/
└── prorate_refund.mjs # Annotated deterministic code toolAGENT.md#
---
name: ts-tools
description: Agent combining deterministic QuickJS code tools with durable approvals.
computer: code
model: claude-sonnet-5-5
---
# Billing Math Agent
Use the deterministic `prorate_refund` code tool for all invoice math. Never estimate proration in prose.tools/prorate_refund.mjs#
// @caveman-tool {"description":"Compute exact prorated refund amount in cents for unused days in a billing cycle.","effect":"read","input_schema":{"type":"object","required":["total_cents","days_used","cycle_days"],"properties":{"total_cents":{"type":"integer","minimum":0},"days_used":{"type":"integer","minimum":0},"cycle_days":{"type":"integer","minimum":1}}}}
export default function execute({ total_cents, days_used, cycle_days }) {
const remaining = Math.max(0, cycle_days - days_used);
const refund_cents = Math.round((total_cents * remaining) / cycle_days);
return { refund_cents, remaining_days: remaining, requires_approval: refund_cents > 50000 };
}How tool annotations work#
The leading // @caveman-tool {...} header declares:
description: shown in the agent's tool schema.effect: declares side-effect class (read,write,idempotent, orexternal) so durable step fencing handles retries safely without repeating external actions.input_schema: standard JSON Schema validated beforeexecute(...)runs.
Test locally with hot reload#
cvm agent dev ./ts-toolsEdit tools/prorate_refund.mjs or AGENT.md and cvm agent dev recompiles agent.json automatically so you can test edge cases (days_used > cycle_days, refunds over $500) in seconds.
Verify and undo#
cvm agent build ./ts-tools --out ./dist-build
cvm deployments archive ts-tools --yesLimits#
computer: codeavailability depends on the target Cloud installation's enabled sandbox tiers. When a tier is disabled on a target install,cvm deploystill stores the build and prints what a session would be refused for. Usecomputer: nonewith custom tools orcomputer: linuxwhen a full Linux sandbox is needed.