Home/Docs/Autopilot — run your program on agents
Docs

Autopilot — run your program on agents

Trcker Autopilot is an open-source reference agent that uses Trcker's MCP tools to approve conversions, pause non-incremental partners, and flag attribution mismatches on a schedule. Install, dry-run, go live in ~10 minutes.

What Autopilot is

A reference implementation of an AI agent that runs your affiliate program end-to-end by calling Trcker's 12 MCP tools on a schedule. Not a black box — a ~1,200 line TypeScript repo you can fork, audit, and customize. Uses the Claude Agent SDK under the hood.

Open source, MIT-licensed. Point it at your brand's API key, walk away, wake up to a log of what it did overnight.

The four loops

| Loop | Frequency | Does | |---|---|---| | Conversion triage | every 15 min | Auto-approves pending conversions with fraud score below your configured threshold; leaves uncertain ones for you | | Partner quality sweep | nightly | Pauses partners whose incrementality lift is statistically significant and non-incremental | | Attribution rebalance | weekly | Flags partners over- or under-credited by last-click vs multi-touch; emits recommendations (v0) | | Cap enforcement | every 5 min | Flags offers approaching their daily/weekly/monthly caps |

All four exercise real MCP tools. Every action is logged to a local JSONL file you can tail, grep, or ship to Splunk.

Setup — ~10 minutes

1. Clone and install

`bash git clone https://github.com/AffDeveloper/trcker-autopilot.git cd trcker-autopilot npm install `

2. Configure

`bash cp .env.example .env cp autopilot.config.example.yaml autopilot.config.yaml `

Edit .env:

` TRCKER_API_KEY=trk_... # Settings → API Keys in your dashboard ANTHROPIC_API_KEY=sk-ant-... # console.anthropic.com AUTOPILOT_MODE=dry-run # safe default — doesn't mutate state `

Tune autopilot.config.yaml if you want — the defaults are conservative (approve only fraud score < 40, pause only partners with lift below -5% at p < 0.05).

3. Dry-run it

`bash npm run run-once -- conversion_triage `

You'll see the agent think through your pending conversions and log what it would have approved. Nothing is actually approved — AUTOPILOT_MODE=dry-run intercepts every write tool before it fires.

Read autopilot.log — every decision, every tool call, every dry-run skip is there as one JSON line.

4. Go live

When you're confident the agent's behavior matches your operator judgment, flip the mode:

`bash # In .env: AUTOPILOT_MODE=execute

Run it as a daemon: npm run dev `

The four loops start on their configured intervals. You monitor via:

`bash tail -f autopilot.log | jq 'select(.kind == "decision")' `

Safety rails

Five guardrails are built into the agent and can't be bypassed without editing the code:

  1. Dry-run is the default. Any fresh clone of the repo cannot mutate state until you explicitly set AUTOPILOT_MODE=execute.
  2. Per-loop action caps. The conversion-triage loop stops after 50 approvals per run. The partner-sweep loop stops after 3 pauses per run. If policy would exceed the cap, the loop halts cleanly with a log entry listing the remaining candidates for human review.
  3. Protected partner list. Put partner UUIDs into partner_sweep.protected_partner_ids in the config. The agent never touches those partners regardless of what the incrementality math says. Useful for strategic or contractual relationships.
  4. Brand-scoped API key. One Trcker API key scopes one agent to one brand. Even if the key is compromised, cross-brand access is impossible.
  5. Full audit trail. autopilot.log is append-only JSONL. Every tool call, every result, every dry-run skip, every policy block. Grep-friendly, log-shipper-friendly, compliance-friendly.

When things go wrong

Agent paused a partner you didn't want paused. Open Trcker → Partners → set status back to active. Then add that partner's UUID to protected_partner_ids in autopilot.config.yaml. The agent won't touch them again.

Agent approved a fraudulent conversion. Reject it manually in Trcker. Then tighten auto_approve_max_fraud_score in the config (e.g., from 40 to 30). The audit log shows why the agent thought it was OK — helps you tune the policy.

Agent is doing nothing. Check tail -f autopilot.log — if no activity, verify your API keys are valid and you haven't hit the MCP rate limit (120 req/min per key). Most likely cause of silence: expired Anthropic key.

Agent costs too much. Edit the interval_minutes in autopilot.config.yaml — raise conversion_triage.interval_minutes from 15 to 60 and you cut that loop's cost by 4x. Or drop to Haiku for specific loops by passing { model: "claude-haiku-4-5" } in the loop code.

What it costs

Rough estimate for a brand with ~20 partners and dozens of pending conversions per day:

| Loop | Frequency | Monthly cost | |---|---|---| | Conversion triage | every 15 min | ~$25 | | Partner sweep | nightly | ~$2 | | Attribution rebalance | weekly | <$1 | | Cap enforcement | every 5 min | ~$15 |

Total: ~$40–50/month per brand. You pay Anthropic, not Trcker. Scales roughly linearly with traffic.

Deploy options

  • Local dev machinenpm run dev
  • Existing VPS / dropletnpm install --production && npm run build && pm2 start dist/index.js
  • Cron one-shots — if you'd rather let the OS scheduler own the cadence, use npm run run-once -- in crontab
  • Docker — the repo ships a Dockerfile for containerised deploys

Extending

Write your own loop in src/loops/my-loop.ts mirroring the existing ones. Add a schedule entry in autopilot.config.yaml. Wire it into src/index.ts. That's the whole extension surface — ~50 lines for a new loop.

Examples of loops you might add: - Weekly digest to Slack — pull top-5 partners under each model, post a summary - Auto-pricing — adjust payouts on partners crossing specific EPC thresholds - Anomaly alerts — fire email / PagerDuty when fraud summary flags a spike - Creator-specific logic — different policies for TikTok vs affiliate partners

Why this exists

Trcker is the first affiliate-tracking platform with a first-class agent surface — 12 MCP tools, writeable, remote, auth'd with a single API key. The autopilot repo is the canonical reference implementation of what that surface is for. If you ever wondered whether "AI-native affiliate tracking" was a real claim or marketing copy, this is the answer — clone the repo, read the code, point it at your brand.

Competitors don't have this because they'd have to rebuild their entire operator surface as an MCP server. That's a quarter of engineering. The marketing takes an afternoon; the plumbing doesn't.

Related