What you will have
A roster agent called Monitor Agent that runs every weekday morning, finds that day’s exports in a SharePoint folder, and turns them into one row per merchant in a tracker workbook plus a short summary in#fraud-monitoring. Every number in the output comes from three Python scripts bundled with its skill: they parse the files, compute each merchant’s fraud-to-sales ratios against fixed thresholds, and reconcile the totals before anything is written. The model decides only what a script can’t: which folder is today’s, whether an input is missing, and one sentence on why each new breach matters. Run it twice on the same files and you get the same rows.
This guide follows the six steps of Build an agent. It is the worked example for Code or prompt: the whole job is a fixed sequence of parsing, arithmetic and lookups, so it lives in scripts and the agent runs them.
The agent spec
Inputs and output
The processor drops three files intoFraud monitoring/in/<YYYY-MM-DD>/ every morning:
Daily table of Fraud monitoring tracker.xlsx, one row per merchant with reports: date, merchant_id, fraud_count, fraud_amount, sales_count, count_ratio, amount_ratio, tier, watchlist, new. A merchant is breach when it has at least 10 reports and $5,000 reported and either ratio reaches 0.90%, watch when either ratio reaches 0.65%, no-volume when it has reports but no sales this month, and ok otherwise. new marks a watch or breach that differs from the merchant’s last tier in the tracker. The thresholds here are illustrative; put your own program’s in assets/thresholds.json.
1. Define the job
Read Define the job first. Decide what is code and what is judgment before you write a word of instructions: here every count, sum, ratio and tier is code, and the agent only orchestrates.Create the roster agent
Monitor Agent. On Instructions, use this description:Scores the day’s fraud report against merchant sales volume with fixed scripts, appends the results to the fraud monitoring tracker and posts a summary. Never acts on a merchant.And these system instructions:
Point it at a template
2. Measure success
Read Measure success. A deterministic job has an unusually sharp criterion: the output either equals the scripts’ output or it doesn’t.Add two evaluation categories
3. Give it tools
Read Give it tools. One system, scoped to one folder.Create the Fraud Monitoring template
Fraud Monitoring, keep Basic and click Create Template. Nothing is cloned; the template carries the connection and the skill.Microsoft 365, agent-scoped, one folder
Fraud monitoring folder (Copy link in SharePoint). The agent can open that folder and everything in it, and nothing else on the site. Put the tracker workbook inside the folder too.4. Define how it works
Read Define how it works and Code or prompt. The runbook is a skill whose steps are commands, and the scripts are files in that skill.Write the fraud-monitoring skill
fraud-monitoring with this SKILL.md:uv run uses the same openpyxl on every run.scripts/parse_inputs.py reads the three inputs into one JSON file and puts every row it can’t read in exceptions, with its file and row number:scripts/score.py aggregates reports per merchant, computes both ratios with Decimal, assigns the tier, compares it with the tracker’s last tier for that merchant, and writes rows.json (sorted, most severe first) and summary.md:scripts/validate.py reconciles the run before anything is written: every input row is either parsed or an exception, the amounts and counts in the rows add up to the parsed reports, and each merchant appears once:assets/thresholds.json:microsoft-365 and Required tooling to uv: latest. Then attach the skill to the Fraud Monitoring template.Build the template once
ready. The build installs uv; the first run downloads openpyxl once.Create the schedule, disabled
Fraud monitoring. For the prompt, write:Run the fraud-monitoring skill for today’s inputs. If an input is missing or a check fails, say which and write nothing.Set run-as to Agent and pick Monitor Agent, so the agent-scoped Microsoft 365 connection applies and the run is graded. Set the schedule to weekdays at 13:00 UTC, after the processor’s drop. Under Post, pick
#fraud-monitoring. Create it, then flip the toggle off until step 5 proves it.5. Prove it works and iterate
Read Prove it works and iterate and Skill evals and session evals. Test it like software: many skill evals at the bottom (unit tests against fixed files), a few scheduled runs at the top (integration tests against SharePoint).Give the skill its unit tests
same_json.py is the comparison script from Fixtures and expected outcomes. A case in evals.json:runtm-api skills upload-file <skill_id> --file <path> --path <same path> --mode binary.Run three known days
sales_volume.xlsx removed: the run must stop, name the file and append nothing.Fix the script, not the prompt
Restore the prompt
6. Add guardrails and approvals
Read Add guardrails and approvals. The proven runs used a handful of commands; allow those and deny the rest of what the helper can do.Command rules
uv run */skills/fraud-monitoring/scripts/* and for the helper’s search, get, download and append, and deny rules for its write, patch, post, send, reply and chat-send. Set the default policy to ask.Network rules
graph.microsoft.com and login.microsoftonline.com (Microsoft 365), pypi.org and files.pythonhosted.org (the pinned openpyxl), and app.runtm.com and docs.runtm.com.Enable the schedule
What stays human
- Every action on a merchant. Outreach, holds, limit changes and closures are decided by an analyst reading the tracker. The agent’s connection can only reach one folder, and its rules deny sending.
- The thresholds.
assets/thresholds.jsonchanges through a skill edit, reviewed and tested against the eval suite, never during a run. - A failed check. When
validate.pyfails, a person looks at the inputs; the agent never retries with a workaround.
Gotchas
- The model doing arithmetic. If a summary ever shows a ratio that isn’t in
rows.json, the agent computed it. Tighten the instruction to copysummary.mdverbatim and gradedaily-runon the numbers. - Floats. Ratios and money are
Decimaland quantized; a float version of the same script gives different last digits on some inputs and breaks the exact comparison in step 5. - Rounding before comparing. Tiers compare the exact ratios and only the tracker gets the rounded ones. Rounding first turns 0.89686% into a 0.90% breach, and the totals still reconcile, so only a just-below-boundary fixture catches it.
- Unpinned dependencies. Without the PEP 723 header,
openpyxlfloats to whatever is newest. Pin it, and bump the pin through a skill edit. - A header renamed upstream.
parse_inputs.pyexits naming the missing column instead of guessing. The run stops with nothing written, which is the point. - Appending twice. The append is one call with the whole
rows.json. A retried run on the same day appends again; check the tracker for the date before appending if your schedule retries. - Network rules without PyPI. The first run after a build can’t fetch
openpyxland every script fails. Addpypi.organdfiles.pythonhosted.org, or install the dependency in the template.