The Technical Solution
Three orchestrated agents on shared Vercel KV state. Agent 1 (invoicing): a Friday cron pulls active engagements, drafts invoices in your voice via Claude Haiku, sends through Resend, and runs the dunning ladder with warm / firm / final tones — webhook-backed Stripe with the same dedup pattern shipped on Mama Hala. Agent 2 (client pulse): a Monday-morning Sonnet narrative over open tickets, last invoice status, last deploy, last admin login — flags anyone trending the wrong way before they churn. Agent 3 (proposal drafting): a tool-using Sonnet loop that takes a discovery-call transcript plus our scope library and produces a first-draft proposal at 80% finished. Prompt caching on the system message and the scope library cuts model spend ~70%. Every agent degrades gracefully — model failure never blocks the underlying flow.
typescript
// Proposal-drafting agent — Sonnet tool loop, prompt-cached scope library
const SCOPE_LIBRARY = await loadScopeLibrary(); // cached in KV
const draft = await anthropic.messages.create({
model: "claude-sonnet-4-6",
max_tokens: 4000,
system: [
{ type: "text", text: SYSTEM_PROMPT, cache_control: { type: "ephemeral" } },
{ type: "text", text: SCOPE_LIBRARY, cache_control: { type: "ephemeral" } },
],
tools: [matchScope, draftMilestones, priceFromRules],
messages: [{ role: "user", content: transcript }],
});
// Tool loop: max 6 turns, escalate to admin if unresolved
for (let turn = 0; turn < 6 && draft.stop_reason === "tool_use"; turn++) {
const result = await runTool(draft.content);
// ... continue
}
// Output: pre-filled proposal, founder edits the last 20% and signs.
return formatProposal(draft);Claude SonnetClaude HaikuAnthropic SDKTool UsePrompt CachingNext.js 16Vercel KVVercel CronStripeResend