I built a TypeScript harness to stop tools leaking raw PII to LLMs
retained text
Hey r/AI_Agents,
Two things kept breaking our production TypeScript agents:
1. **Tool data leakage:** Passing raw DB/CRM objects into LLM context windows burns tokens and leaks sensitive PII.
2. **Fragile workflows:** Adding Temporal/Inngest just for step memoization and human approval felt like overkill.
I built `avantgate/agent` to handle both in-process with $0 infra.
# 1. Dual-Channel Tool Isolation (DTO Pattern)
Stream the rich raw payload directly to your UI, but only feed a minimal, PII-sanitized summary to the LLM:
import { z } from "zod";
import { createIsolatedTool } from "avantgate/agent";
export const getClientsTool = createIsolatedTool({
name: "get_clients",
description: "Fetch client list",
parameters: z.object({ industry: z.string() }),
async execute(args) {
return await db.clients.findMany({ where: { industry: args.industry } });
},
# 2. Durable Steps & Human-in-the-Loop ($0 Infra)
Memoized steps and pauses without hosting orchestration clusters. Works with SQLite, Prisma, Drizzle, or Redis:
import { createStepRunner, StepSuspendedError } from "avantgate/agent";
const runner = createStepRunner({ workflowId: `wf-${userId}` });
try {
// Memoized: won't re-run if already executed
const report = await runner.run("gen-report", () => generateReport());
// Suspends cleanly until an API/admin calls runner.approveStep("payout")
const approval = await runner.waitForApproval("payout", { amount: 5000 });
await runner.run("send-payout", () => executePayout(approval));
} catch (err) {
if (err instanceof StepSuspendedError) console.log("Awaiting human approval...");
}
Install: `npm install avantgate zod`
Would love to get feedback on the API design and learn how you are currently handling tool PII leakage.document fetched 2026-09-20 00:19 · canonical https://reddit.com/r/AI_Agents/comments/1wkk09w/i_built_a_typescript_harness_to_stop_tools