Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse filesFiles changed (41)
- DockerfileAdded+50
- README.md+273-12
- __init__.pyAdded+29
- baseline_scores.jsonAdded+27
- client.pyAdded+84
- convo_logging/task_1_conversation.mdAdded+666
- convo_logging/task_2_conversation.mdAdded
- convo_logging/task_3_conversation.mdAdded
- data/__init__.pyAdded+18
- data/ad_generator.pyAdded+561
- data/advertiser_profiles.pyAdded+160
- data/fraud_patterns.pyAdded+432
- data/landing_pages.pyAdded+187
- data/network_generator.pyAdded+194
- graders/__init__.pyAdded+14
- graders/base_grader.pyAdded+113
- graders/task1_grader.pyAdded+49
- graders/task2_grader.pyAdded+89
- graders/task3_grader.pyAdded+133
- inference.pyAdded+451
- models.pyAdded+100
- openenv.yamlAdded+7
- openenv_ad_fraud_env.egg-info/PKG-INFOAdded+18
- openenv_ad_fraud_env.egg-info/SOURCES.txtAdded+33
- openenv_ad_fraud_env.egg-info/dependency_links.txtAdded+1
- openenv_ad_fraud_env.egg-info/entry_points.txtAdded+2
- openenv_ad_fraud_env.egg-info/requires.txtAdded+14
- openenv_ad_fraud_env.egg-info/top_level.txtAdded+1
- outputs/task_1_conversation.mdAdded+840
- outputs/task_2_conversation.mdAdded+1251
- outputs/task_3_conversation.mdAdded+1057
- pyproject.tomlAdded+44
- server/__init__.pyAdded+1
- server/app.pyAdded+113
- server/environment.pyAdded+559
- server/requirements.txtAdded+9
- tests/__init__.pyAdded
- tests/test_data_generation.pyAdded+141
- tests/test_environment.pyAdded+178
- tests/test_graders.pyAdded+203
- uv.lockAdded
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950ARG BASE_IMAGE=ghcr.io/meta-pytorch/openenv-base:latest
FROM ${BASE_IMAGE} AS builder
WORKDIR /app
ARG BUILD_MODE=in-repo
COPY . /app/env
WORKDIR /app/env
RUN if ! command -v uv >/dev/null 2>&1; then \
curl -LsSf https://astral.sh/uv/install.sh | sh && \
mv /root/.local/bin/uv /usr/local/bin/uv && \
mv /root/.local/bin/uvx /usr/local/bin/uvx; \
fi
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
&& rm -rf /var/lib/apt/lists/*
RUN --mount=type=cache,target=/root/.cache/uv \
if [ -f uv.lock ]; then \
uv sync --frozen --no-install-project --no-editable; \
else \
uv sync --no-install-project --no-editable; \
fi
RUN --mount=type=cache,target=/root/.cache/uv \
if [ -f uv.lock ]; then \
uv sync --frozen --no-editable; \
else \
uv sync --no-editable; \
fi
FROM ${BASE_IMAGE}
WORKDIR /app
COPY --from=builder /app/env/.venv /app/.venv
COPY --from=builder /app/env /app/env
ENV PATH="/app/.venv/bin:$PATH"
ENV PYTHONPATH="/app/env:$PYTHONPATH"
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" || exit 1
ENV ENABLE_WEB_INTERFACE=true
CMD ["uvicorn", "server.app:app", "--host", "0.0.0.0", "--port", "8000"]123456789101112---title: AdArenaemoji: 🏃colorFrom: pinkcolorTo: bluesdk: dockerpinned: falselicense: bsd-3-clauseshort_description: Train agents to catch fraud---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273---title: Ad Fraud Investigation Environmentemoji: "\U0001F575\uFE0F"colorFrom: redcolorTo: yellowsdk: dockerpinned: falseapp_port: 8000base_path: /webtags:- openenv- ad-fraud- reinforcement-learning---# Ad Fraud Investigation EnvironmentAn OpenEnv environment that simulates ad fraud review - a real-world task where AI agents investigate queues of advertisements, uncover fraud signals, and render verdicts under budget constraints.Ad fraud costs the digital advertising industry over **$100 billion annually**. Platforms like Meta process billions of ads daily and ban advertisers only at high confidence thresholds. Unlike simple classification, real ad review is a **sequential decision-making** problem: a reviewer starts with limited surface-level signals, actively chooses what to investigate within a constrained budget, and must decide when enough evidence exists to commit to a verdict. This environment captures that workflow and provides a training ground for agents to learn it.## Quick Start### Install```bashpip install -e .```### Run the server```bashuvicorn server.app:app --host 0.0.0.0 --port 8000```### Use the client```pythonfrom ad_fraud_env import AdFraudEnv, AdReviewActionwith AdFraudEnv(base_url="http://localhost:8000").sync() as env:result = env.reset(seed=42, task_id="task_1")print(result.observation.queue_summary)# Investigate an adresult = env.step(AdReviewAction(action_type="investigate",ad_id="ad_001",investigation_target="landing_page",))print(result.observation.feedback)# Render a verdictresult = env.step(AdReviewAction(action_type="verdict",ad_id="ad_001",verdict="reject",confidence=0.9,))print(f"Reward: {result.reward}, Done: {result.done}")```### Run with Docker```bashdocker build -t ad-fraud-env .docker run -p 8000:8000 ad-fraud-env```## Environment Design### Episode flowEach episode is a review session. The agent receives a queue of ads and must process them within a limited action budget:```reset(task_id, seed)|v+----------------------------------+<----------------------+| Observe queue + first ad info | |+------------------+---------------+ || |v |+-------------+ +------------------+ || investigate |---->| Reveal one signal |----------++-------------+ | (costs 1 budget) || +------------------+v+-------------+ +------------------+| verdict |---->| approve / reject |----------++-------------+ | / escalate | || +------------------+ |v |+--------------+ +------------------+ || link_accounts|---->| Flag fraud ring |----------++--------------+ | (Task 3 only) || +------------------+vBudget exhausted or all ads reviewed -> episode ends```### TasksThree tasks with increasing difficulty test different capabilities:| Task | Name | Ads | Budget | Composition | Challenge ||---|---|---:|---:|---|---|| 1 | Basic Ad Triage | 5 | 25 | 2 legit, 3 obvious fraud | Learn the investigate -> verdict loop || 2 | Sophisticated Fraud | 12 | 30 | 5 legit, 5 sophisticated scams, 2 gray-area | Triage under budget pressure (~2.5 actions/ad) || 3 | Fraud Network Detection | 20 | 35 | 6 legit, 10 fraud (3 hidden rings), 4 gray-area | Cross-ad reasoning to detect coordinated networks (~1.75 actions/ad) |Task 3 introduces **fraud rings** - clusters of 3-5 ads controlled by the same actor, using varied topologies (cliques, chains, hub-and-spoke). Individual ring members look borderline; the fraud signal is only visible by cross-referencing investigation data across ads (shared payment IDs, matching template hashes, overlapping targeting fingerprints).### Action SpaceActions are JSON objects. Three types:**`investigate`** - spend one budget point to reveal a signal about an ad.```json{"action_type": "investigate","ad_id": "ad_001","investigation_target": "landing_page"}```Each ad has six investigation dimensions:| Target | What it reveals ||---|---|| `advertiser_history` | Account age, spend history, violation record, verification status || `landing_page` | Domain age, SSL, registrar, redirect chains, scam template similarity || `payment_method` | Payment type, chargeback history, cross-account velocity || `targeting_overlap` | Targeting fingerprint, audience overlap percentages || `creative_similarity` | Template hash, image dimensions, scam template similarity score || `campaign_structure` | Objective, bid strategy, budget/age ratio, placement distribution |**`verdict`** - render a final decision on an ad.```json{"action_type": "verdict","ad_id": "ad_001","verdict": "reject","confidence": 0.9}````verdict` options: `approve`, `reject`, `escalate`. `confidence`: 0.0-1.0.**`link_accounts`** - flag two ads as part of the same fraud network (Task 3).```json{"action_type": "link_accounts","ad_id": "ad_003","linked_ad_id": "ad_007","link_reason": "shared payment ID pmt_ring_48231 and matching template hash"}```### Observation SpaceObservations are text-heavy by design so LLM agents can reason naturally:| Field | Type | Description ||---|---|---|| `queue_summary` | `str` | Task name, total/reviewed/pending counts, budget remaining || `current_ad_info` | `str` | Ad copy, category, targeting, risk signals for the focused ad || `investigation_findings` | `str` | Accumulated findings from all investigations so far || `verdict_history_summary` | `str` | Verdicts rendered so far || `feedback` | `str` | Natural language feedback on the last action || `available_ads` | `list[str]` | Ad IDs still pending review || `queue_status` | `dict` | Structured status for programmatic access || `done` | `bool` | Whether the episode is complete || `reward` | `float` | Step reward |## Reward Design| Action | Reward | Rationale ||---|---:|---|| Investigation | -0.02 | Simulates time/latency cost || Correct rejection (fraud -> reject) | +0.30 to +0.40 | Scaled by fraud severity || Correct approval (legit -> approve) | +0.10 | Revenue preserved || Correct escalation | +0.15 | Appropriate caution || False positive (legit -> reject) | -0.35 | Lost advertiser revenue || False negative (fraud -> approve) | -0.50 | Worst outcome - fraud goes live || Escalate (when wrong) | -0.05 | Human reviewer cost || Correct network link | +0.40 | High-value coordinated fraud detection || Incorrect network link | -0.25 | False accusation cost |Unreviewed ads are auto-approved at episode end - missed fraud incurs the full -0.50 false-negative penalty.## Grading & ScoringEach task has a dedicated grader that produces a normalized **0.0-1.0 score**. Raw reward is normalized between theoretical worst-case (every decision wrong + full budget wasted) and best-case (every decision correct + efficient budget use).| Component | Task 1 | Task 2 | Task 3 ||---|:---:|:---:|:---:|| Verdict accuracy | Yes | Yes | Yes || Budget efficiency bonus | Yes | Yes | Yes || Calibration bonus | - | Yes | Yes || Network detection (edge coverage) | - | - | Yes || Investigation coverage bonus | - | - | Yes |**Calibration bonus** rewards agents whose stated confidence correlates with actual accuracy - high confidence on correct verdicts and low confidence on uncertain ones.**Network detection** uses edge coverage: what fraction of ground-truth fraud ring connections did the agent discover via `link_accounts`?**Coverage bonus** rewards breadth over depth - agents that review more ads (rather than deep-diving a single one) score higher on Task 3.## Baseline ScoresGenerated with `seed=42` using `meta-llama/Llama-3.1-8B-Instruct`. Reproducible via `python inference.py`.| Task | Score | Steps | Verdicts ||---|---:|---:|---:|| Task 1 (Easy) | 0.953 | 10 | 5/5 || Task 2 (Medium) | 0.882 | 23 | 12/12 || Task 3 (Hard) | 0.415 | 35 | 20/20 |The sharp drop on Task 3 reflects the difficulty of cross-ad reasoning under tight budget - the baseline agent investigates and renders verdicts well but struggles to detect coordinated fraud rings.## Project Structure```ad_fraud_env/+-- __init__.py # Package exports+-- client.py # WebSocket client (extends EnvClient)+-- models.py # Action, Observation, State types+-- inference.py # Baseline LLM agent with mandatory stdout logging+-- openenv.yaml # OpenEnv manifest+-- pyproject.toml # Dependencies and package config+-- Dockerfile # Multi-stage Docker build+-- baseline_scores.json # Cached baseline results+-- data/| +-- ad_generator.py # Episode generation, task configs, campaign profiles| +-- advertiser_profiles.py # Synthetic advertiser history| +-- fraud_patterns.py # Fraud + legit ad templates (easy/medium/hard)| +-- landing_pages.py # Simulated landing page investigation data| +-- network_generator.py # Fraud ring topologies via networkx+-- graders/| +-- base_grader.py # Shared normalization and reward logic| +-- task1_grader.py # Verdict accuracy only| +-- task2_grader.py # + calibration bonus| +-- task3_grader.py # + network detection + coverage bonus+-- server/| +-- app.py # FastAPI app with /tasks, /baseline, /grader endpoints| +-- environment.py # Core environment (reset/step/state)| +-- requirements.txt # Server dependencies+-- tests/+-- test_data_generation.py # Determinism, cross-ref checks, decoy validation+-- test_environment.py # Step logic, state tracking, anti-exploit+-- test_graders.py # Score ranges, calibration, network scoring```## API Endpoints| Endpoint | Method | Description ||---|---|---|| `/health` | GET | Health check || `/schema` | GET | Action/Observation JSON schemas || `/ws` | WS | WebSocket for `step()` / `reset()` / `state()` || `/tasks` | GET | Task list with configs and action schema || `/baseline` | GET | Baseline scores (cached or live) || `/grader` | GET | Last episode's grader result || `/web` | GET | Auto-generated Gradio UI |## LicenseBSD 3-Clause License
1234567891011121314151617181920212223242526272829"""
Ad Fraud Investigation Environment for OpenEnv.
A real-world simulation where an AI agent investigates a queue of ads
for fraud, making sequential investigation and verdict decisions under
a limited action budget.
Example:
>>> from ad_fraud_env import AdFraudEnv, AdReviewAction
>>>
>>> with AdFraudEnv(base_url="http://localhost:8000").sync() as env:
... result = env.reset(seed=42, task_id="task_1")
... result = env.step(AdReviewAction(
... action_type="investigate",
... ad_id="ad_001",
... investigation_target="landing_page",
... ))
... print(result.observation.feedback)
"""
from .client import AdFraudEnv
from .models import AdFraudState, AdReviewAction, AdReviewObservation
__all__ = [
"AdFraudEnv",
"AdReviewAction",
"AdReviewObservation",
"AdFraudState",
]123456789101112131415161718192021222324252627{
"baseline_model": "llama3.1:8b",
"seed": 42,
"tasks": {
"task_1": {
"task_id": "task_1",
"score": 0.9603547186637474,
"steps": 9,
"verdicts": 5,
"total_ads": 5
},
"task_2": {
"task_id": "task_2",
"score": 0.8877459920214088,
"steps": 24,
"verdicts": 12,
"total_ads": 12
},
"task_3": {
"task_id": "task_3",
"score": 0.4817339313969324,
"steps": 35,
"verdicts": 20,
"total_ads": 20
}
}
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384"""
Ad Fraud Investigation Environment Client.
Provides programmatic access via WebSocket. Users and evaluators interact
with the environment using:
env = AdFraudEnv.from_hub("your-org/ad-fraud-env")
# or
env = AdFraudEnv(base_url="http://localhost:8000")
"""
from __future__ import annotations
from typing import Any, Dict
from openenv.core.client_types import StepResult
from openenv.core.env_client import EnvClient
from .models import AdFraudState, AdReviewAction, AdReviewObservation
class AdFraudEnv(EnvClient[AdReviewAction, AdReviewObservation, AdFraudState]):
"""
WebSocket client for the Ad Fraud Investigation Environment.
Example:
>>> with AdFraudEnv(base_url="http://localhost:8000").sync() as env:
... result = env.reset(seed=42, task_id="task_1")
... print(result.observation.queue_summary)
... result = env.step(AdReviewAction(
... action_type="investigate",
... ad_id="ad_001",
... investigation_target="advertiser_history",
... ))
... print(result.observation.feedback)
"""
def _step_payload(self, action: AdReviewAction) -> Dict[str, Any]:
"""Convert action to JSON payload for the WebSocket step message."""
return action.model_dump(exclude_none=True, exclude={"metadata"})
def _parse_result(
self, payload: Dict[str, Any]
) -> StepResult[AdReviewObservation]:
"""Parse server response into a typed StepResult.
OpenEnv serializes as {"observation": {...}, "reward": float, "done": bool}
with reward/done at the top level, excluded from the observation dict.
"""
obs_data = payload.get("observation", {})
reward = payload.get("reward", 0.0) or 0.0
done = payload.get("done", False)
observation = AdReviewObservation(
done=done,
reward=reward,
queue_summary=obs_data.get("queue_summary", ""),
current_ad_info=obs_data.get("current_ad_info", ""),
investigation_findings=obs_data.get("investigation_findings", ""),
verdict_history_summary=obs_data.get("verdict_history_summary", ""),
feedback=obs_data.get("feedback", ""),
available_ads=obs_data.get("available_ads", []),
queue_status=obs_data.get("queue_status", {}),
metadata=obs_data.get("metadata", {}),
)
return StepResult(
observation=observation,
reward=reward,
done=done,
)
def _parse_state(self, payload: Dict[str, Any]) -> AdFraudState:
"""Parse server state response into AdFraudState."""
return AdFraudState(
episode_id=payload.get("episode_id"),
step_count=payload.get("step_count", 0),
task_id=payload.get("task_id", ""),
total_ads=payload.get("total_ads", 0),
reviewed_count=payload.get("reviewed_count", 0),
remaining_budget=payload.get("remaining_budget", 0),
verdicts=payload.get("verdicts", {}),
grader_score=payload.get("grader_score"),
)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666# Episode Log — task_1
## Step 0
### Observation (sent to LLM)
```
Queue: Task: Basic Ad Triage (easy)
Total ads: 5 | Reviewed: 0 | Pending: 5 | Steps remaining: 25/25 | Investigation budget: 25 | Step: 0
Current Ad: === Ad in Focus: ad_001 ===
Category: local_service
Ad copy: "Award-winning pizza delivery in Brooklyn. Family recipes since 1985. Order from Sal's Pizzeria."
Targeting: Adults 18-55, Brooklyn, interests: food delivery
Initial risk signals: None
Advertiser country: Germany
Account age: 1132 days
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity, campaign_structure
Feedback: Episode started. Review the ad queue and begin your investigation.
Available ads: ad_001, ad_002, ad_003, ad_004, ad_005
```
### LLM Response
```json
{
"action_type": "investigate",
"ad_id": "ad_001",
"investigation_target": "targeting_overlap"
}
```
### Parsed Action
```json
{
"action_type": "investigate",
"ad_id": "ad_001",
"investigation_target": "targeting_overlap"
}
```
### Environment Response
- **Reward:** `-0.02`
- **Done:** `False`
- **Feedback:** Investigation complete: targeting_overlap for ad_001.
--- Findings ---
Targeting Analysis for ad_001:
Declared targeting: Adults 18-55, Brooklyn, interests: food delivery
Targeting fingerprint: seg_20328
Audience overlap with platform average for category: 27%
Geographic regions targeted: 2
## Step 1
### Observation (sent to LLM)
```
Queue: Task: Basic Ad Triage (easy)
Total ads: 5 | Reviewed: 0 | Pending: 5 | Steps remaining: 24/25 | Investigation budget: 24 | Step: 1
Current Ad: === Ad in Focus: ad_001 ===
Category: local_service
Ad copy: "Award-winning pizza delivery in Brooklyn. Family recipes since 1985. Order from Sal's Pizzeria."
Targeting: Adults 18-55, Brooklyn, interests: food delivery
Initial risk signals: None
Advertiser country: Germany
Account age: 1132 days
Investigations completed: targeting_overlap
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity, campaign_structure
Feedback: Investigation complete: targeting_overlap for ad_001.
--- Findings ---
Targeting Analysis for ad_001:
Declared targeting: Adults 18-55, Brooklyn, interests: food delivery
Targeting fingerprint: seg_20328
Audience overlap with platform average for category: 27%
Geographic regions targeted: 2
Available ads: ad_001, ad_002, ad_003, ad_004, ad_005
Findings:
[ad_001 / targeting_overlap]
Targeting Analysis for ad_001:
Declared targeting: Adults 18-55, Brooklyn, interests: food delivery
Targeting fingerprint: seg_20328
Audience overlap with platform average for category: 27%
Geographic regions targeted: 2
```
### LLM Response
```json
{
"action_type": "verdict",
"ad_id": "ad_001",
"verdict": "approve",
"confidence": 0.9
}
```
### Parsed Action
```json
{
"action_type": "verdict",
"ad_id": "ad_001",
"verdict": "approve",
"confidence": 0.9
}
```
### Environment Response
- **Reward:** `+0.10`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_001: approve (confidence: 0.90). 4 ad(s) remaining in queue.
## Step 2
### Observation (sent to LLM)
```
Queue: Task: Basic Ad Triage (easy)
Total ads: 5 | Reviewed: 1 | Pending: 4 | Steps remaining: 23/25 | Investigation budget: 24 | Step: 2
Current Ad: === Ad in Focus: ad_002 ===
Category: counterfeit_goods
Ad copy: "Rolex watches starting at $49.99! 100% genuine! Free worldwide shipping! LuxWatchDeals.net"
Targeting: Men 25-55, interests: watches, luxury
Initial risk signals: impossibly low prices for luxury goods, unfamiliar domain, claims of authenticity with extreme discounts
Advertiser country: Estonia
Account age: 6 days
Flag: New account (< 30 days)
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity, campaign_structure
Feedback: Verdict recorded for ad_001: approve (confidence: 0.90). 4 ad(s) remaining in queue.
Available ads: ad_002, ad_003, ad_004, ad_005
Verdicts: Reviewed 1 ad(s): 1 approve.
approve: ad_001
Findings:
[ad_001 / targeting_overlap] Declared targeting: Adults 18-55, Brooklyn, interests: food delivery | Targeting fingerprint: seg_20328 | Audience overlap with platform average for category: 27% | Geographic regions targeted: 2
```
### LLM Response
```json
{
"action_type": "investigate",
"ad_id": "ad_002",
"investigation_target": "landing_page"
}
```
### Parsed Action
```json
{
"action_type": "investigate",
"ad_id": "ad_002",
"investigation_target": "landing_page"
}
```
### Environment Response
- **Reward:** `-0.02`
- **Done:** `False`
- **Feedback:** Investigation complete: landing_page for ad_002.
--- Findings ---
Domain: elite2813.buzz
Domain age: 35 days
SSL: NO SSL / expired certificate
Registrar: Epik
WHOIS privacy: Disabled (registrant info public)
Redirect chain: elite2813.buzz -> redirect948.xyz -> redirect705.xyz -> redirect225.xyz -> final-333.site
Similarity to known scam templates: 71%
Key claims on page:
- Authentic products
- Direct from manufacturer
- 90% below retail price
Suspicious elements:
- Product images appear stolen from official brand site
- Terms of service link returns 404
Content summary: Product catalog showing luxury branded items at extreme discounts. Stock photos. Payment accepted via wire transfer and crypto only.
## Step 3
### Observation (sent to LLM)
```
Queue: Task: Basic Ad Triage (easy)
Total ads: 5 | Reviewed: 1 | Pending: 4 | Steps remaining: 22/25 | Investigation budget: 23 | Step: 3
Current Ad: === Ad in Focus: ad_002 ===
Category: counterfeit_goods
Ad copy: "Rolex watches starting at $49.99! 100% genuine! Free worldwide shipping! LuxWatchDeals.net"
Targeting: Men 25-55, interests: watches, luxury
Initial risk signals: impossibly low prices for luxury goods, unfamiliar domain, claims of authenticity with extreme discounts
Advertiser country: Estonia
Account age: 6 days
Flag: New account (< 30 days)
Investigations completed: landing_page
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity, campaign_structure
Feedback: Investigation complete: landing_page for ad_002.
--- Findings ---
Domain: elite2813.buzz
Domain age: 35 days
SSL: NO SSL / expired certificate
Registrar: Epik
WHOIS privacy: Disabled (registrant info public)
Redirect chain: elite2813.buzz -> redirect948.xyz -> redirect705.xyz -> redirect225.xyz -> final-333.site
Similarity to known scam templates: 71%
Key claims on page:
- Authentic products
- Direct from manufacturer
- 90% below retail price
Suspicious elements:
- Product images appear stolen from official brand site
- Terms of service link returns 404
Content summary: Product catalog showing luxury branded items at extreme discounts. Stock photos. Payment accepted via wire transfer and crypto only.
Available ads: ad_002, ad_003, ad_004, ad_005
Verdicts: Reviewed 1 ad(s): 1 approve.
approve: ad_001
Findings:
[ad_001 / targeting_overlap] Declared targeting: Adults 18-55, Brooklyn, interests: food delivery | Targeting fingerprint: seg_20328 | Audience overlap with platform average for category: 27% | Geographic regions targeted: 2
[ad_002 / landing_page]
Domain: elite2813.buzz
Domain age: 35 days
SSL: NO SSL / expired certificate
Registrar: Epik
WHOIS privacy: Disabled (registrant info public)
Redirect chain: elite2813.buzz -> redirect948.xyz -> redirect705.xyz -> redirect225.xyz -> final-333.site
Similarity to known scam templates: 71%
Key claims on page:
- Authentic products
- Direct from manufacturer
- 90% below retail price
Suspicious elements:
- Product images appear stolen from official brand site
- Terms of service link returns 404
Content summary: Product catalog showing luxury branded items at extreme discounts. Stock photos. Payment accepted via wire transfer and crypto only.
```
### LLM Response
```json
{
"action_type": "verdict",
"ad_id": "ad_002",
"verdict": "reject",
"confidence": 0.95
}
```
### Parsed Action
```json
{
"action_type": "verdict",
"ad_id": "ad_002",
"verdict": "reject",
"confidence": 0.95
}
```
### Environment Response
- **Reward:** `+0.38`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_002: reject (confidence: 0.95). 3 ad(s) remaining in queue.
## Step 4
### Observation (sent to LLM)
```
Queue: Task: Basic Ad Triage (easy)
Total ads: 5 | Reviewed: 2 | Pending: 3 | Steps remaining: 21/25 | Investigation budget: 23 | Step: 4
Current Ad: === Ad in Focus: ad_003 ===
Category: fake_giveaway
Ad copy: "EXCLUSIVE: Win a Tesla Model 3! Enter your email NOW! Drawing ends tonight!!!"
Targeting: Adults 18-55, interests: cars, Tesla, electric vehicles
Initial risk signals: excessive urgency language, too-good-to-be-true offer, excessive punctuation/caps, no purchase necessary claims
Advertiser country: Estonia
Account age: 19 days
Flag: New account (< 30 days)
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity, campaign_structure
Feedback: Verdict recorded for ad_002: reject (confidence: 0.95). 3 ad(s) remaining in queue.
Available ads: ad_003, ad_004, ad_005
Verdicts: Reviewed 2 ad(s): 1 approve, 1 reject.
reject: ad_002
approve: ad_001
Findings:
[ad_001 / targeting_overlap] Declared targeting: Adults 18-55, Brooklyn, interests: food delivery | Targeting fingerprint: seg_20328 | Audience overlap with platform average for category: 27% | Geographic regions targeted: 2
[ad_002 / landing_page] Domain: elite2813.buzz | Domain age: 35 days | SSL: NO SSL / expired certificate | Registrar: Epik | WHOIS privacy: Disabled (registrant info public) | Redirect chain: elite2813.buzz -> redirect948.xyz -> redirect705.xyz -> redirect225.xyz -> final-333.site | Similarity to known scam templates: 71% | Authentic products | Direct from manufacturer | 90% below retail price | Product images appear stolen from official brand site | Terms of service link returns 404 | Content summary: Product catalog showing luxury branded items at extreme discounts. Stock photos. Payment accepted via wire transfer and crypto only.
```
### LLM Response
```json
{
"action_type": "investigate",
"ad_id": "ad_003",
"investigation_target": "landing_page"
}
```
### Parsed Action
```json
{
"action_type": "investigate",
"ad_id": "ad_003",
"investigation_target": "landing_page"
}
```
### Environment Response
- **Reward:** `-0.02`
- **Done:** `False`
- **Feedback:** Investigation complete: landing_page for ad_003.
--- Findings ---
Domain: shop2631.buzz
Domain age: 51 days
SSL: NO SSL / expired certificate
Registrar: Openprovider
WHOIS privacy: Disabled (registrant info public)
Redirect chain: shop2631.buzz -> redirect611.top -> redirect542.top -> redirect995.xyz -> redirect882.click -> final-697.site
Similarity to known scam templates: 53%
Key claims on page:
- 100% free, no purchase necessary
- Guaranteed winner
- Act now — expires in 2 hours
Suspicious elements:
- No physical address listed
- No contact phone number
Content summary: Landing page features a large countdown timer and a form requesting name, email, phone, and address. No clear sponsor or rules disclosure.
## Step 5
### Observation (sent to LLM)
```
Queue: Task: Basic Ad Triage (easy)
Total ads: 5 | Reviewed: 2 | Pending: 3 | Steps remaining: 20/25 | Investigation budget: 22 | Step: 5
Current Ad: === Ad in Focus: ad_003 ===
Category: fake_giveaway
Ad copy: "EXCLUSIVE: Win a Tesla Model 3! Enter your email NOW! Drawing ends tonight!!!"
Targeting: Adults 18-55, interests: cars, Tesla, electric vehicles
Initial risk signals: excessive urgency language, too-good-to-be-true offer, excessive punctuation/caps, no purchase necessary claims
Advertiser country: Estonia
Account age: 19 days
Flag: New account (< 30 days)
Investigations completed: landing_page
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity, campaign_structure
Feedback: Investigation complete: landing_page for ad_003.
--- Findings ---
Domain: shop2631.buzz
Domain age: 51 days
SSL: NO SSL / expired certificate
Registrar: Openprovider
WHOIS privacy: Disabled (registrant info public)
Redirect chain: shop2631.buzz -> redirect611.top -> redirect542.top -> redirect995.xyz -> redirect882.click -> final-697.site
Similarity to known scam templates: 53%
Key claims on page:
- 100% free, no purchase necessary
- Guaranteed winner
- Act now — expires in 2 hours
Suspicious elements:
- No physical address listed
- No contact phone number
Content summary: Landing page features a large countdown timer and a form requesting name, email, phone, and address. No clear sponsor or rules disclosure.
Available ads: ad_003, ad_004, ad_005
Verdicts: Reviewed 2 ad(s): 1 approve, 1 reject.
reject: ad_002
approve: ad_001
Findings:
[ad_001 / targeting_overlap] Declared targeting: Adults 18-55, Brooklyn, interests: food delivery | Targeting fingerprint: seg_20328 | Audience overlap with platform average for category: 27% | Geographic regions targeted: 2
[ad_002 / landing_page] Domain: elite2813.buzz | Domain age: 35 days | SSL: NO SSL / expired certificate | Registrar: Epik | WHOIS privacy: Disabled (registrant info public) | Redirect chain: elite2813.buzz -> redirect948.xyz -> redirect705.xyz -> redirect225.xyz -> final-333.site | Similarity to known scam templates: 71% | Authentic products | Direct from manufacturer | 90% below retail price | Product images appear stolen from official brand site | Terms of service link returns 404 | Content summary: Product catalog showing luxury branded items at extreme discounts. Stock photos. Payment accepted via wire transfer and crypto only.
[ad_003 / landing_page]
Domain: shop2631.buzz
Domain age: 51 days
SSL: NO SSL / expired certificate
Registrar: Openprovider
WHOIS privacy: Disabled (registrant info public)
Redirect chain: shop2631.buzz -> redirect611.top -> redirect542.top -> redirect995.xyz -> redirect882.click -> final-697.site
Similarity to known scam templates: 53%
Key claims on page:
- 100% free, no purchase necessary
- Guaranteed winner
- Act now — expires in 2 hours
Suspicious elements:
- No physical address listed
- No contact phone number
Content summary: Landing page features a large countdown timer and a form requesting name, email, phone, and address. No clear sponsor or rules disclosure.
```
### LLM Response
```json
{
"action_type": "verdict",
"ad_id": "ad_003",
"verdict": "reject",
"confidence": 0.85
}
```
### Parsed Action
```json
{
"action_type": "verdict",
"ad_id": "ad_003",
"verdict": "reject",
"confidence": 0.85
}
```
### Environment Response
- **Reward:** `+0.39`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_003: reject (confidence: 0.85). 2 ad(s) remaining in queue.
## Step 6
### Observation (sent to LLM)
```
Queue: Task: Basic Ad Triage (easy)
Total ads: 5 | Reviewed: 3 | Pending: 2 | Steps remaining: 19/25 | Investigation budget: 22 | Step: 6
Current Ad: === Ad in Focus: ad_004 ===
Category: ecommerce
Ad copy: "Spring Sale — Up to 30% off home essentials. Free shipping on orders over $50. Shop now at HomeNest."
Targeting: Women 25-54, interests: home decor, shopping
Initial risk signals: None
Advertiser country: Germany
Account age: 615 days
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity, campaign_structure
Feedback: Verdict recorded for ad_003: reject (confidence: 0.85). 2 ad(s) remaining in queue.
Available ads: ad_004, ad_005
Verdicts: Reviewed 3 ad(s): 1 approve, 2 reject.
reject: ad_002, ad_003
approve: ad_001
Findings:
[ad_001 / targeting_overlap] Declared targeting: Adults 18-55, Brooklyn, interests: food delivery | Targeting fingerprint: seg_20328 | Audience overlap with platform average for category: 27% | Geographic regions targeted: 2
[ad_002 / landing_page] Domain: elite2813.buzz | Domain age: 35 days | SSL: NO SSL / expired certificate | Registrar: Epik | WHOIS privacy: Disabled (registrant info public) | Redirect chain: elite2813.buzz -> redirect948.xyz -> redirect705.xyz -> redirect225.xyz -> final-333.site | Similarity to known scam templates: 71% | Authentic products | Direct from manufacturer | 90% below retail price | Product images appear stolen from official brand site | Terms of service link returns 404 | Content summary: Product catalog showing luxury branded items at extreme discounts. Stock photos. Payment accepted via wire transfer and crypto only.
[ad_003 / landing_page] Domain: shop2631.buzz | Domain age: 51 days | SSL: NO SSL / expired certificate | Registrar: Openprovider | WHOIS privacy: Disabled (registrant info public) | Redirect chain: shop2631.buzz -> redirect611.top -> redirect542.top -> redirect995.xyz -> redirect882.click -> final-697.site | Similarity to known scam templates: 53% | 100% free, no purchase necessary | Guaranteed winner | Act now — expires in 2 hours | No physical address listed | No contact phone number | Content summary: Landing page features a large countdown timer and a form requesting name, email, phone, and address. No clear sponsor or rules disclosure.
```
### LLM Response
```json
{
"action_type": "investigate",
"ad_id": "ad_004",
"investigation_target": "landing_page"
}
```
### Parsed Action
```json
{
"action_type": "investigate",
"ad_id": "ad_004",
"investigation_target": "landing_page"
}
```
### Environment Response
- **Reward:** `-0.02`
- **Done:** `False`
- **Feedback:** Investigation complete: landing_page for ad_004.
--- Findings ---
Domain: homenest.com
Domain age: 3338 days
SSL: Valid SSL certificate
Registrar: Google Domains
WHOIS privacy: Disabled (registrant info public)
Redirect chain: No redirects (direct)
Similarity to known scam templates: 4%
Key claims on page:
- 14-day free trial
- Money-back guarantee
Suspicious elements:
None detected
Content summary: SaaS landing page with feature breakdown, pricing tiers, integration docs, and live demo option.
## Step 7
### Observation (sent to LLM)
```
Queue: Task: Basic Ad Triage (easy)
Total ads: 5 | Reviewed: 3 | Pending: 2 | Steps remaining: 18/25 | Investigation budget: 21 | Step: 7
Current Ad: === Ad in Focus: ad_004 ===
Category: ecommerce
Ad copy: "Spring Sale — Up to 30% off home essentials. Free shipping on orders over $50. Shop now at HomeNest."
Targeting: Women 25-54, interests: home decor, shopping
Initial risk signals: None
Advertiser country: Germany
Account age: 615 days
Investigations completed: landing_page
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity, campaign_structure
Feedback: Investigation complete: landing_page for ad_004.
--- Findings ---
Domain: homenest.com
Domain age: 3338 days
SSL: Valid SSL certificate
Registrar: Google Domains
WHOIS privacy: Disabled (registrant info public)
Redirect chain: No redirects (direct)
Similarity to known scam templates: 4%
Key claims on page:
- 14-day free trial
- Money-back guarantee
Suspicious elements:
None detected
Content summary: SaaS landing page with feature breakdown, pricing tiers, integration docs, and live demo option.
Available ads: ad_004, ad_005
Verdicts: Reviewed 3 ad(s): 1 approve, 2 reject.
reject: ad_002, ad_003
approve: ad_001
Findings:
[ad_001 / targeting_overlap] Declared targeting: Adults 18-55, Brooklyn, interests: food delivery | Targeting fingerprint: seg_20328 | Audience overlap with platform average for category: 27% | Geographic regions targeted: 2
[ad_002 / landing_page] Domain: elite2813.buzz | Domain age: 35 days | SSL: NO SSL / expired certificate | Registrar: Epik | WHOIS privacy: Disabled (registrant info public) | Redirect chain: elite2813.buzz -> redirect948.xyz -> redirect705.xyz -> redirect225.xyz -> final-333.site | Similarity to known scam templates: 71% | Authentic products | Direct from manufacturer | 90% below retail price | Product images appear stolen from official brand site | Terms of service link returns 404 | Content summary: Product catalog showing luxury branded items at extreme discounts. Stock photos. Payment accepted via wire transfer and crypto only.
[ad_003 / landing_page] Domain: shop2631.buzz | Domain age: 51 days | SSL: NO SSL / expired certificate | Registrar: Openprovider | WHOIS privacy: Disabled (registrant info public) | Redirect chain: shop2631.buzz -> redirect611.top -> redirect542.top -> redirect995.xyz -> redirect882.click -> final-697.site | Similarity to known scam templates: 53% | 100% free, no purchase necessary | Guaranteed winner | Act now — expires in 2 hours | No physical address listed | No contact phone number | Content summary: Landing page features a large countdown timer and a form requesting name, email, phone, and address. No clear sponsor or rules disclosure.
[ad_004 / landing_page]
Domain: homenest.com
Domain age: 3338 days
SSL: Valid SSL certificate
Registrar: Google Domains
WHOIS privacy: Disabled (registrant info public)
Redirect chain: No redirects (direct)
Similarity to known scam templates: 4%
Key claims on page:
- 14-day free trial
- Money-back guarantee
Suspicious elements:
None detected
Content summary: SaaS landing page with feature breakdown, pricing tiers, integration docs, and live demo option.
```
### LLM Response
```json
{
"action_type": "verdict",
"ad_id": "ad_004",
"verdict": "approve",
"confidence": 0.95
}
```
### Parsed Action
```json
{
"action_type": "verdict",
"ad_id": "ad_004",
"verdict": "approve",
"confidence": 0.95
}
```
### Environment Response
- **Reward:** `+0.10`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_004: approve (confidence: 0.95). 1 ad(s) remaining in queue.
## Step 8
### Observation (sent to LLM)
```
Queue: Task: Basic Ad Triage (easy)
Total ads: 5 | Reviewed: 4 | Pending: 1 | Steps remaining: 17/25 | Investigation budget: 21 | Step: 8
Current Ad: === Ad in Focus: ad_005 ===
Category: fake_giveaway
Ad copy: "EXCLUSIVE: Win a Tesla Model 3! Enter your email NOW! Drawing ends tonight!!!"
Targeting: Adults 18-55, interests: cars, Tesla, electric vehicles
Initial risk signals: excessive urgency language, too-good-to-be-true offer, excessive punctuation/caps, no purchase necessary claims
Advertiser country: Singapore
Account age: 40 days
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity, campaign_structure
Feedback: Verdict recorded for ad_004: approve (confidence: 0.95). 1 ad(s) remaining in queue.
Available ads: ad_005
Verdicts: Reviewed 4 ad(s): 2 approve, 2 reject.
reject: ad_002, ad_003
approve: ad_001, ad_004
Findings:
[ad_001 / targeting_overlap] Declared targeting: Adults 18-55, Brooklyn, interests: food delivery | Targeting fingerprint: seg_20328 | Audience overlap with platform average for category: 27% | Geographic regions targeted: 2
[ad_002 / landing_page] Domain: elite2813.buzz | Domain age: 35 days | SSL: NO SSL / expired certificate | Registrar: Epik | WHOIS privacy: Disabled (registrant info public) | Redirect chain: elite2813.buzz -> redirect948.xyz -> redirect705.xyz -> redirect225.xyz -> final-333.site | Similarity to known scam templates: 71% | Authentic products | Direct from manufacturer | 90% below retail price | Product images appear stolen from official brand site | Terms of service link returns 404 | Content summary: Product catalog showing luxury branded items at extreme discounts. Stock photos. Payment accepted via wire transfer and crypto only.
[ad_003 / landing_page] Domain: shop2631.buzz | Domain age: 51 days | SSL: NO SSL / expired certificate | Registrar: Openprovider | WHOIS privacy: Disabled (registrant info public) | Redirect chain: shop2631.buzz -> redirect611.top -> redirect542.top -> redirect995.xyz -> redirect882.click -> final-697.site | Similarity to known scam templates: 53% | 100% free, no purchase necessary | Guaranteed winner | Act now — expires in 2 hours | No physical address listed | No contact phone number | Content summary: Landing page features a large countdown timer and a form requesting name, email, phone, and address. No clear sponsor or rules disclosure.
[ad_004 / landing_page] Domain: homenest.com | Domain age: 3338 days | SSL: Valid SSL certificate | Registrar: Google Domains | WHOIS privacy: Disabled (registrant info public) | Redirect chain: No redirects (direct) | Similarity to known scam templates: 4% | 14-day free trial | Money-back guarantee | None detected | Content summary: SaaS landing page with feature breakdown, pricing tiers, integration docs, and live demo option.
```
### LLM Response
```json
{
"action_type": "verdict",
"ad_id": "ad_005",
"verdict": "reject",
"confidence": 0.9
}
```
### Parsed Action
```json
{
"action_type": "verdict",
"ad_id": "ad_005",
"verdict": "reject",
"confidence": 0.9
}
```
### Environment Response
- **Reward:** `+0.39`
- **Done:** `True`
- **Feedback:** Episode complete. Grader score: 0.960/1.000
Verdicts rendered: 5/5
Correct decisions: 5/5
False positives (legit rejected): 0
False negatives (fraud approved): 0
Unreviewed ads auto-approved: 0
---
## Result
**Score: 0.960 | Steps: 9 | Verdicts: 5/5**123456789101112131415161718"""Synthetic data generation for the Ad Fraud Investigation Environment."""
from .ad_generator import TASK_CONFIGS, CampaignProfile, generate_episode
from .advertiser_profiles import generate_advertiser_profile
from .fraud_patterns import FRAUD_TEMPLATES, LEGIT_TEMPLATES
from .landing_pages import generate_landing_page
from .network_generator import generate_fraud_networks
__all__ = [
"generate_episode",
"generate_advertiser_profile",
"generate_landing_page",
"generate_fraud_networks",
"CampaignProfile",
"FRAUD_TEMPLATES",
"LEGIT_TEMPLATES",
"TASK_CONFIGS",
]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561"""
Synthetic ad queue generation.
Generates a complete queue of ads for a given task configuration,
including all pre-generated investigation data. When the agent
investigates, the environment just reveals pre-computed data.
"""
from __future__ import annotations
import random
from dataclasses import dataclass, field
from typing import Any, Dict, List, Optional, Tuple
from .advertiser_profiles import AdvertiserProfile, generate_advertiser_profile
from .fraud_patterns import FRAUD_TEMPLATES, LEGIT_TEMPLATES, AdTemplate
from .landing_pages import LandingPageData, generate_landing_page
from .network_generator import FraudRing, generate_fraud_networks
# Decoy pools: values that can appear in both legit and fraud ads,
# making naive pattern-matching unreliable.
_DECOY_REGISTRARS = ["NameSilo", "Cloudflare Registrar", "GoDaddy", "Tucows (privacy proxy)"]
_DECOY_PAYMENT_TYPES = ["credit_card", "prepaid_card", "corporate_card"]
_COMMON_TARGETING_SEGMENTS = [
"Adults 25-54, interests: shopping, lifestyle",
"Adults 18-45, interests: technology, gadgets",
"Adults 30-55, interests: finance, investing",
]
@dataclass
class TaskConfig:
task_id: str
name: str
difficulty: str
queue_size: int
action_budget: int
n_legit: int
n_fraud: int
n_escalate: int
include_networks: bool
n_fraud_rings: int
allowed_difficulties: List[str]
description: str
TASK_CONFIGS: Dict[str, TaskConfig] = {
"task_1": TaskConfig(
task_id="task_1",
name="Basic Ad Triage",
difficulty="easy",
queue_size=5,
action_budget=25,
n_legit=2,
n_fraud=3,
n_escalate=0,
include_networks=False,
n_fraud_rings=0,
allowed_difficulties=["easy"],
description=(
"Learn the investigation loop. Queue of 5 ads with obviously "
"fraudulent or clearly legitimate signals. Generous budget of 25 "
"actions (5 per ad)."
),
),
"task_2": TaskConfig(
task_id="task_2",
name="Sophisticated Fraud Under Budget Pressure",
difficulty="medium",
queue_size=12,
action_budget=30,
n_legit=5,
n_fraud=5,
n_escalate=2,
include_networks=False,
n_fraud_rings=0,
allowed_difficulties=["easy", "medium"],
description=(
"Triage under budget constraints. Mix of legit ads, sophisticated "
"scams, and gray-area cases. 12 ads but only 30 actions (~2.5 per ad). "
"Agent must prioritize which ads to investigate deeply."
),
),
"task_3": TaskConfig(
task_id="task_3",
name="Coordinated Fraud Network Detection",
difficulty="hard",
queue_size=20,
action_budget=35,
n_legit=6,
n_fraud=10,
n_escalate=4,
include_networks=True,
n_fraud_rings=3,
allowed_difficulties=["easy", "medium", "hard"],
description=(
"Full challenge including coordinated fraud rings. 20 ads with 3 "
"hidden fraud networks using varied topologies (cliques, chains, "
"hub-and-spoke). Budget of 35 actions (~1.75 per ad). Ring member "
"ads look borderline individually — the agent must cross-reference "
"investigation data across ads to detect shared signals."
),
),
}
@dataclass
class CampaignProfile:
"""Campaign-level metadata associated with an ad."""
objective: str # e.g. "conversions", "traffic", "awareness", "app_installs"
bid_strategy: str # e.g. "lowest_cost", "cost_cap", "bid_cap"
daily_budget_usd: float
ad_set_count: int
placements: List[str]
def to_investigation_text(self, account_age_days: int) -> str:
budget_age_ratio = (
self.daily_budget_usd / max(account_age_days, 1)
)
placements_str = ", ".join(self.placements)
lines = [
f"Campaign Objective: {self.objective}",
f"Bid Strategy: {self.bid_strategy}",
f"Daily Budget: ${self.daily_budget_usd:,.2f} "
f"(account is {account_age_days} days old — "
f"budget/age ratio: ${budget_age_ratio:,.2f}/day)",
f"Active Ad Sets: {self.ad_set_count}",
f"Placements: {placements_str}",
]
warnings = []
if budget_age_ratio > 50:
warnings.append(
"Budget-to-account-age ratio exceeds typical thresholds."
)
if self.ad_set_count > 15:
warnings.append(
f"High ad set count ({self.ad_set_count}) — "
"possible policy evasion testing via creative variation."
)
if self.objective in ("traffic", "awareness") and self.bid_strategy == "lowest_cost":
warnings.append(
f"Optimizing for {self.objective} with lowest-cost bidding "
"— common in spray-and-pray fraud campaigns."
)
if "Audience Network" in self.placements and len(self.placements) <= 2:
warnings.append(
"Heavy reliance on Audience Network placement — "
"higher bot traffic exposure."
)
if warnings:
for w in warnings:
lines.append(f" WARNING: {w}")
else:
lines.append("Budget and pacing consistent with historical account behavior.")
return "\n".join(lines)
@dataclass
class Ad:
ad_id: str
ad_copy: str
category: str
targeting_summary: str
initial_risk_signals: List[str]
ground_truth_label: str # "fraud", "legit", or "escalate"
fraud_type: str
severity: float
difficulty: str
@dataclass
class GeneratedEpisode:
"""All pre-generated data for one episode."""
task_config: TaskConfig
ads: List[Ad]
advertiser_profiles: Dict[str, AdvertiserProfile]
campaign_profiles: Dict[str, CampaignProfile]
landing_pages: Dict[str, LandingPageData]
fraud_rings: List[FraudRing]
ad_to_rings: Dict[str, List[str]]
investigation_data: Dict[str, Dict[str, str]]
def generate_episode(seed: int, task_id: str = "task_1") -> GeneratedEpisode:
"""Generate a complete episode with all pre-computed investigation data."""
rng = random.Random(seed)
config = TASK_CONFIGS[task_id]
ads = _generate_ad_queue(rng, config)
fraud_ad_ids = [a.ad_id for a in ads if a.ground_truth_label == "fraud"]
fraud_rings: List[FraudRing] = []
ad_to_rings: Dict[str, List[str]] = {}
ring_shared_payments: Dict[str, str] = {}
if config.include_networks and config.n_fraud_rings > 0:
fraud_rings, ad_to_rings = generate_fraud_networks(
rng, config.n_fraud_rings, fraud_ad_ids
)
for ring in fraud_rings:
if "payment_method" in ring.shared_signals:
for ad_id in ring.member_ad_ids:
ring_shared_payments[ad_id] = ring.shared_signals["payment_method"]
advertiser_profiles: Dict[str, AdvertiserProfile] = {}
campaign_profiles: Dict[str, CampaignProfile] = {}
landing_pages: Dict[str, LandingPageData] = {}
investigation_data: Dict[str, Dict[str, str]] = {}
ring_campaign_overrides: Dict[str, Dict[str, Any]] = {}
ring_created_dates: Dict[str, str] = {}
for ring in fraud_rings:
shared_objective = rng.choice(["traffic", "awareness"])
shared_bid = "lowest_cost"
# Ring members share account creation dates within the same week
from datetime import date, timedelta
base_date = date(2026, 4, 6) - timedelta(days=rng.randint(5, 45))
for ad_id in ring.member_ad_ids:
ring_campaign_overrides[ad_id] = {
"objective": shared_objective,
"bid_strategy": shared_bid,
}
offset = timedelta(days=rng.randint(0, 6))
ring_created_dates[ad_id] = (base_date + offset).isoformat()
for ad in ads:
is_fraud = ad.ground_truth_label in ("fraud", "escalate")
profile = generate_advertiser_profile(
rng, ad.ad_id, is_fraud,
payment_method_id=ring_shared_payments.get(ad.ad_id),
ring_created_date=ring_created_dates.get(ad.ad_id),
)
advertiser_profiles[ad.ad_id] = profile
campaign = _generate_campaign_profile(
rng, ad, is_fraud,
ring_overrides=ring_campaign_overrides.get(ad.ad_id),
)
campaign_profiles[ad.ad_id] = campaign
landing_page_kwargs = {}
if ad.ad_id in ad_to_rings:
ring = next(r for r in fraud_rings if ad.ad_id in r.member_ad_ids)
if "domain_registrar" in ring.shared_signals:
landing_page_kwargs["registrar_override"] = ring.shared_signals["domain_registrar"]
elif not is_fraud and rng.random() < 0.25:
landing_page_kwargs["registrar_override"] = rng.choice(_DECOY_REGISTRARS)
lp = generate_landing_page(
rng, ad.ad_id, is_fraud, ad.fraud_type, **landing_page_kwargs
)
landing_pages[ad.ad_id] = lp
inv = {}
inv["advertiser_history"] = profile.to_investigation_text()
inv["landing_page"] = lp.to_investigation_text()
inv["payment_method"] = _generate_payment_investigation(rng, profile, ad.ad_id, ad_to_rings, fraud_rings)
inv["targeting_overlap"] = _generate_targeting_investigation(rng, ad, ads, ad_to_rings, fraud_rings)
inv["creative_similarity"] = _generate_creative_investigation(rng, ad, ads, ad_to_rings, fraud_rings)
inv["campaign_structure"] = _generate_campaign_investigation(
rng, ad, campaign, profile, ad_to_rings, fraud_rings,
)
investigation_data[ad.ad_id] = inv
return GeneratedEpisode(
task_config=config,
ads=ads,
advertiser_profiles=advertiser_profiles,
campaign_profiles=campaign_profiles,
landing_pages=landing_pages,
fraud_rings=fraud_rings,
ad_to_rings=ad_to_rings,
investigation_data=investigation_data,
)
def _generate_ad_queue(rng: random.Random, config: TaskConfig) -> List[Ad]:
"""Build the ad queue by sampling from templates."""
ads: List[Ad] = []
ad_counter = 0
legit_templates = [t for t in LEGIT_TEMPLATES]
fraud_templates = [
t for t in FRAUD_TEMPLATES
if t.difficulty in config.allowed_difficulties and t.label == "fraud"
]
escalate_templates = [
t for t in FRAUD_TEMPLATES
if t.difficulty in config.allowed_difficulties and t.label == "escalate"
]
if not escalate_templates:
escalate_templates = [
t for t in FRAUD_TEMPLATES if t.label == "escalate"
]
for _ in range(config.n_legit):
template = rng.choice(legit_templates)
idx = rng.randint(0, len(template.ad_copies) - 1)
ad_counter += 1
ads.append(Ad(
ad_id=f"ad_{ad_counter:03d}",
ad_copy=template.ad_copies[idx],
category=template.category,
targeting_summary=template.targeting_hints[idx % len(template.targeting_hints)],
initial_risk_signals=list(template.risk_signals),
ground_truth_label=template.label,
fraud_type=template.fraud_type,
severity=template.severity,
difficulty=template.difficulty,
))
for _ in range(config.n_fraud):
if fraud_templates:
template = rng.choice(fraud_templates)
else:
template = rng.choice(FRAUD_TEMPLATES)
idx = rng.randint(0, len(template.ad_copies) - 1)
ad_counter += 1
ads.append(Ad(
ad_id=f"ad_{ad_counter:03d}",
ad_copy=template.ad_copies[idx],
category=template.category,
targeting_summary=template.targeting_hints[idx % len(template.targeting_hints)],
initial_risk_signals=list(template.risk_signals),
ground_truth_label="fraud",
fraud_type=template.fraud_type,
severity=template.severity,
difficulty=template.difficulty,
))
for _ in range(config.n_escalate):
if escalate_templates:
template = rng.choice(escalate_templates)
idx = rng.randint(0, len(template.ad_copies) - 1)
ad_counter += 1
ads.append(Ad(
ad_id=f"ad_{ad_counter:03d}",
ad_copy=template.ad_copies[idx],
category=template.category,
targeting_summary=template.targeting_hints[idx % len(template.targeting_hints)],
initial_risk_signals=list(template.risk_signals),
ground_truth_label="escalate",
fraud_type=template.fraud_type,
severity=template.severity,
difficulty=template.difficulty,
))
rng.shuffle(ads)
renumbered = []
for i, ad in enumerate(ads):
ad.ad_id = f"ad_{i + 1:03d}"
renumbered.append(ad)
return renumbered
def _generate_payment_investigation(
rng: random.Random,
profile: AdvertiserProfile,
ad_id: str,
ad_to_rings: Dict[str, List[str]],
fraud_rings: List[FraudRing],
) -> str:
"""Generate payment method investigation text.
Ring signals are embedded as raw data values (shared payment IDs) without
explicitly naming other ads. The agent must cross-reference across ads.
"""
lines = [
f"Payment Method Analysis for {ad_id}:",
f" Method type: {profile.payment_method_type}",
f" Payment ID: {profile.payment_method_id}",
]
if profile.payment_method_type in ("prepaid_card", "crypto", "virtual_card"):
lines.append(f" Note: {profile.payment_method_type} payments have elevated fraud correlation in platform data.")
if profile.previous_violations > 0:
lines.append(f" Chargeback/dispute history: {profile.previous_violations} incident(s) on record.")
else:
lines.append(" Chargeback/dispute history: Clean record.")
velocity = rng.randint(1, 5) if ad_id not in ad_to_rings else rng.randint(3, 12)
lines.append(f" Payment method added to {velocity} advertiser account(s) in the last 90 days.")
if profile.account_age_days < 30:
lines.append(f" First charge on this method: {profile.account_age_days} days ago.")
return "\n".join(lines)
def _generate_targeting_investigation(
rng: random.Random,
ad: Ad,
all_ads: List[Ad],
ad_to_rings: Dict[str, List[str]],
fraud_rings: List[FraudRing],
) -> str:
"""Generate targeting overlap investigation text.
Ring members share an exact targeting fingerprint, presented as raw data.
The agent must compare fingerprints across ads to detect collusion.
"""
lines = [
f"Targeting Analysis for {ad.ad_id}:",
f" Declared targeting: {ad.targeting_summary}",
]
if ad.ad_id in ad_to_rings:
ring = next(r for r in fraud_rings if ad.ad_id in r.member_ad_ids)
if "targeting_overlap" in ring.shared_signals:
lines.append(f" Targeting fingerprint: {ring.shared_signals['targeting_overlap']}")
overlap_pct = rng.randint(85, 98)
lines.append(f" Audience overlap with platform average for category: {overlap_pct}%")
else:
fingerprint = f"seg_{rng.randint(10000, 99999)}"
lines.append(f" Targeting fingerprint: {fingerprint}")
overlap_pct = rng.randint(20, 55)
lines.append(f" Audience overlap with platform average for category: {overlap_pct}%")
else:
fingerprint = f"seg_{rng.randint(10000, 99999)}"
lines.append(f" Targeting fingerprint: {fingerprint}")
similar = [a for a in all_ads if a.ad_id != ad.ad_id and a.category == ad.category]
if similar:
overlap_pct = rng.randint(30, 65)
lines.append(f" {len(similar)} other ad(s) in same category ({ad.category}) in queue.")
lines.append(f" Audience overlap with platform average for category: {overlap_pct}%")
else:
overlap_pct = rng.randint(10, 40)
lines.append(f" Audience overlap with platform average for category: {overlap_pct}%")
geo_regions = rng.randint(1, 8) if ad.ground_truth_label != "legit" else rng.randint(1, 3)
lines.append(f" Geographic regions targeted: {geo_regions}")
return "\n".join(lines)
def _generate_creative_investigation(
rng: random.Random,
ad: Ad,
all_ads: List[Ad],
ad_to_rings: Dict[str, List[str]],
fraud_rings: List[FraudRing],
) -> str:
"""Generate creative similarity investigation text.
Ring members share a template hash, presented as raw data. The agent
must compare hashes across ads to detect reuse.
"""
lines = [
f"Creative Analysis for {ad.ad_id}:",
]
if ad.ad_id in ad_to_rings:
ring = next(r for r in fraud_rings if ad.ad_id in r.member_ad_ids)
if "creative_template" in ring.shared_signals:
lines.append(f" Template hash: {ring.shared_signals['creative_template']}")
lines.append(f" Image dimensions: {rng.choice(['1200x628', '1080x1080', '1200x1200'])} px")
lines.append(f" Color palette hash: pal_{rng.randint(100, 999)}")
lines.append(f" Text-to-image ratio: {rng.randint(18, 25)}%")
else:
lines.append(f" Template hash: tmpl_{rng.randint(10000, 99999)}")
lines.append(f" Image dimensions: {rng.choice(['1200x628', '1080x1080', '1200x1200', '600x600'])} px")
lines.append(f" Text-to-image ratio: {rng.randint(10, 30)}%")
else:
lines.append(f" Template hash: tmpl_{rng.randint(10000, 99999)}")
lines.append(f" Image dimensions: {rng.choice(['1200x628', '1080x1080'])} px")
lines.append(f" Text-to-image ratio: {rng.randint(8, 22)}%")
if ad.ground_truth_label == "fraud" and ad.fraud_type:
similarity = rng.uniform(0.3, 0.7)
else:
similarity = rng.uniform(0.0, 0.15)
lines.append(f" Similarity to known scam templates: {similarity:.0%}")
return "\n".join(lines)
_LEGIT_OBJECTIVES = ["conversions", "leads", "sales", "app_installs"]
_FRAUD_OBJECTIVES = ["traffic", "awareness", "reach", "engagement"]
_LEGIT_BID_STRATEGIES = ["cost_cap", "bid_cap", "target_cost"]
_FRAUD_BID_STRATEGIES = ["lowest_cost", "lowest_cost", "lowest_cost", "cost_cap"]
_LEGIT_PLACEMENTS = [
["Facebook Feed", "Instagram Feed"],
["Facebook Feed", "Instagram Feed", "Instagram Stories"],
["Facebook Feed"],
["Facebook Feed", "Instagram Feed", "Instagram Reels"],
]
_FRAUD_PLACEMENTS = [
["Audience Network", "Facebook Feed"],
["Audience Network", "Facebook Feed", "Instagram Stories"],
["Facebook Feed", "Instagram Feed", "Audience Network", "Messenger"],
["Audience Network"],
]
def _generate_campaign_profile(
rng: random.Random,
ad: Ad,
is_fraud: bool,
*,
ring_overrides: Optional[Dict[str, Any]] = None,
) -> CampaignProfile:
"""Generate campaign-level metadata for an ad."""
if is_fraud:
objective = rng.choice(_FRAUD_OBJECTIVES)
bid_strategy = rng.choice(_FRAUD_BID_STRATEGIES)
daily_budget = round(rng.uniform(500, 5000), 2)
ad_set_count = rng.randint(8, 50)
placements = rng.choice(_FRAUD_PLACEMENTS)
else:
objective = rng.choice(_LEGIT_OBJECTIVES)
bid_strategy = rng.choice(_LEGIT_BID_STRATEGIES)
daily_budget = round(rng.uniform(20, 500), 2)
ad_set_count = rng.randint(1, 5)
placements = rng.choice(_LEGIT_PLACEMENTS)
if ring_overrides:
objective = ring_overrides.get("objective", objective)
bid_strategy = ring_overrides.get("bid_strategy", bid_strategy)
return CampaignProfile(
objective=objective,
bid_strategy=bid_strategy,
daily_budget_usd=daily_budget,
ad_set_count=ad_set_count,
placements=list(placements),
)
def _generate_campaign_investigation(
rng: random.Random,
ad: Ad,
campaign: CampaignProfile,
profile: AdvertiserProfile,
ad_to_rings: Dict[str, List[str]],
fraud_rings: List[FraudRing],
) -> str:
"""Generate campaign structure investigation text.
Ring members share campaign configurations but no explicit cross-references.
The agent must compare objective/bid/budget patterns across ads.
"""
lines = [
f"Campaign Structure Analysis for {ad.ad_id}:",
campaign.to_investigation_text(profile.account_age_days),
]
config_hash = f"cfg_{hash((campaign.objective, campaign.bid_strategy)) & 0xFFFF:04x}"
lines.append(f" Campaign configuration fingerprint: {config_hash}")
return "\n".join(lines)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160"""
Synthetic advertiser profile generation.
Each ad has an associated advertiser with history data
that becomes available when the agent investigates 'advertiser_history'.
"""
from __future__ import annotations
import random
from dataclasses import dataclass, field
from typing import List
@dataclass
class AdvertiserProfile:
advertiser_id: str
account_name: str
account_age_days: int
total_spend_usd: float
previous_violations: int
previous_bans: int
ad_volume_last_30d: int
historical_approval_rate: float
payment_method_id: str
payment_method_type: str
country: str
verified_business: bool
account_created_date: str = ""
spend_velocity: str = ""
ad_submission_pattern: str = ""
def to_investigation_text(self) -> str:
status = "Verified Business" if self.verified_business else "Unverified"
violation_note = ""
if self.previous_violations > 0:
violation_note = f" ({self.previous_violations} policy violations on record, {self.previous_bans} previous bans)"
elif self.previous_bans > 0:
violation_note = f" ({self.previous_bans} previous bans on record)"
lines = [
f"Advertiser: {self.account_name} ({status})",
f"Account age: {self.account_age_days} days",
f"Account created: {self.account_created_date}" if self.account_created_date else None,
f"Country: {self.country}",
f"Total historical spend: ${self.total_spend_usd:,.2f}",
f"Ads submitted in last 30 days: {self.ad_volume_last_30d}",
f"Historical approval rate: {self.historical_approval_rate:.0%}{violation_note}",
f"Payment method: {self.payment_method_type} (ID: {self.payment_method_id})",
f"Spend velocity: {self.spend_velocity}" if self.spend_velocity else None,
f"Submission pattern: {self.ad_submission_pattern}" if self.ad_submission_pattern else None,
]
return "\n".join(l for l in lines if l is not None)
_LEGIT_NAMES = [
"HomeNest LLC", "StyleHaven Inc", "Chef's Choice Store", "GlowNatural Co",
"ArtisanHide Crafts", "TaskFlow Pro", "InvoiceSimple Inc", "PeopleFirst HR",
"VaultBackup Solutions", "MailCraft Inc", "Mike's Plumbing", "Sal's Pizzeria",
"SparkleHome Services", "Williams Tax Group", "PawPals Chicago",
"CodeAcademy Pro", "StateU Online", "PrepMaster Tutoring",
"LensArt Studio", "LinguaViva Education", "FitLife Fitness",
"ZenFlow Yoga", "NutriPlan Co", "SwiftStride Athletics", "FitVisit",
]
_SCAM_NAMES = [
"Digital Marketing Solutions LLC", "Global Deals Marketplace",
"Premium Offers International", "Quick Rewards Corp",
"NextGen Trading Ltd", "Elite Ventures Group",
"Horizon Brands LLC", "TrustPoint Commerce",
"Alpha Innovations Inc", "PrimeEdge Solutions",
"Quantum Returns Ltd", "FuturePath Holdings",
"BlueChip Partners", "ClearView Enterprises",
"Apex Growth Strategies", "SilverLine Dynamics",
]
_COUNTRIES_LEGIT = ["United States", "United Kingdom", "Canada", "Australia", "Germany"]
_COUNTRIES_MIXED = [
"United States", "United Kingdom", "Netherlands", "Singapore",
"Hong Kong", "United Arab Emirates", "Estonia", "Georgia",
]
def generate_advertiser_profile(
rng: random.Random,
ad_id: str,
is_fraud: bool,
*,
payment_method_id: str | None = None,
ring_created_date: str | None = None,
) -> AdvertiserProfile:
"""Generate a synthetic advertiser profile for a single ad."""
from datetime import date, timedelta
if is_fraud:
account_name = rng.choice(_SCAM_NAMES)
account_age = rng.randint(1, 90)
total_spend = round(rng.uniform(0, 500), 2)
violations = rng.choices([0, 1, 2, 3], weights=[40, 30, 20, 10])[0]
bans = rng.choices([0, 1, 2], weights=[60, 30, 10])[0]
ad_volume = rng.randint(5, 80)
approval_rate = round(rng.uniform(0.3, 0.75), 2)
country = rng.choice(_COUNTRIES_MIXED)
verified = rng.random() < 0.15
pmt_type = rng.choice(["prepaid_card", "crypto", "virtual_card", "wire_transfer", "credit_card"])
else:
account_name = rng.choice(_LEGIT_NAMES)
account_age = rng.randint(180, 2500)
total_spend = round(rng.uniform(5000, 500000), 2)
violations = 0
bans = 0
ad_volume = rng.randint(1, 20)
approval_rate = round(rng.uniform(0.9, 1.0), 2)
country = rng.choice(_COUNTRIES_LEGIT)
verified = rng.random() < 0.85
pmt_type = rng.choice(["credit_card", "bank_account", "corporate_card"])
if payment_method_id is None:
payment_method_id = f"pmt_{rng.randint(100000, 999999)}"
# Temporal signals
if ring_created_date:
created_date = ring_created_date
else:
created = date(2026, 4, 6) - timedelta(days=account_age)
created_date = created.isoformat()
if is_fraud:
spend_per_day = total_spend / max(account_age, 1)
if spend_per_day > 20:
spend_velocity = f"${spend_per_day:,.0f}/day avg — ramped from $0 to ${total_spend:,.0f} in {account_age} days"
else:
spend_velocity = f"${spend_per_day:,.0f}/day avg over account lifetime"
if ad_volume > 20:
submission_pattern = f"{ad_volume} ads in 30 days (burst: {rng.randint(8, ad_volume)} in a single 24h window)"
else:
submission_pattern = f"{ad_volume} ads in 30 days (steady cadence)"
else:
spend_per_day = total_spend / max(account_age, 1)
spend_velocity = f"${spend_per_day:,.0f}/day avg — consistent growth over {account_age} days"
submission_pattern = f"{ad_volume} ads in 30 days (steady cadence)"
return AdvertiserProfile(
advertiser_id=f"adv_{ad_id}",
account_name=account_name,
account_age_days=account_age,
total_spend_usd=total_spend,
previous_violations=violations,
previous_bans=bans,
ad_volume_last_30d=ad_volume,
historical_approval_rate=approval_rate,
payment_method_id=payment_method_id,
payment_method_type=pmt_type,
country=country,
verified_business=verified,
account_created_date=created_date,
spend_velocity=spend_velocity,
ad_submission_pattern=submission_pattern,
)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432"""
Fraud and legitimate ad templates for synthetic data generation.
Templates are organized by difficulty: obvious scams for Task 1,
sophisticated scams for Task 2, and network-ready scams for Task 3.
"""
from __future__ import annotations
from dataclasses import dataclass, field
from typing import List
@dataclass
class AdTemplate:
category: str
ad_copies: List[str]
targeting_hints: List[str]
risk_signals: List[str]
label: str # "fraud", "legit", or "escalate"
fraud_type: str = ""
severity: float = 0.0 # 0.0-1.0
difficulty: str = "easy" # easy, medium, hard
LEGIT_TEMPLATES: List[AdTemplate] = [
AdTemplate(
category="ecommerce",
ad_copies=[
"Spring Sale — Up to 30% off home essentials. Free shipping on orders over $50. Shop now at HomeNest.",
"New arrivals in women's fashion. Curated styles for every occasion. Visit StyleHaven today.",
"Upgrade your kitchen with premium cookware. Professional-grade, lifetime warranty. Chef's Choice Store.",
"Organic skincare products made with natural ingredients. Dermatologist tested. GlowNatural.com",
"Handcrafted leather bags — designed to last. Each piece unique. ArtisanHide.com",
],
targeting_hints=[
"Women 25-54, interests: home decor, shopping",
"Women 18-45, interests: fashion, lifestyle",
"Adults 30-60, interests: cooking, kitchen",
"Women 22-50, interests: beauty, wellness",
"Adults 25-55, interests: fashion, luxury goods",
],
risk_signals=[],
label="legit",
severity=0.0,
),
AdTemplate(
category="saas",
ad_copies=[
"Streamline your project management. 14-day free trial, no credit card required. Try TaskFlow Pro.",
"Automate your invoicing in minutes. Trusted by 50,000+ small businesses. InvoiceSimple.",
"HR management made easy. Onboarding, payroll, compliance — all in one platform. PeopleFirst.",
"Secure cloud backup for your business. 256-bit encryption. Plans from $9/mo. VaultBackup.",
"Email marketing that converts. AI-powered subject lines, drag-and-drop editor. MailCraft.",
],
targeting_hints=[
"Professionals 25-55, interests: business, productivity",
"Small business owners, interests: finance, accounting",
"HR managers 30-50, interests: management, recruiting",
"IT professionals 25-55, interests: cloud, security",
"Marketers 25-45, interests: digital marketing, email",
],
risk_signals=[],
label="legit",
severity=0.0,
),
AdTemplate(
category="local_service",
ad_copies=[
"Need a plumber? Same-day service, licensed & insured. Call Mike's Plumbing — serving Portland since 2008.",
"Award-winning pizza delivery in Brooklyn. Family recipes since 1985. Order from Sal's Pizzeria.",
"Professional house cleaning. Eco-friendly products, background-checked staff. SparkleHome Services.",
"Expert tax preparation. CPA with 15 years experience. Free consultation. Williams Tax Group.",
"Dog walking and pet sitting. GPS-tracked walks, daily photo updates. PawPals Chicago.",
],
targeting_hints=[
"Homeowners 30-65, Portland metro area",
"Adults 18-55, Brooklyn, interests: food delivery",
"Homeowners 25-60, interests: home services",
"Adults 25-65, tax season, interests: finance",
"Pet owners 25-50, Chicago metro area",
],
risk_signals=[],
label="legit",
severity=0.0,
),
AdTemplate(
category="education",
ad_copies=[
"Learn Python programming in 12 weeks. Live instructor, project-based curriculum. CodeAcademy Pro.",
"MBA programs online — AACSB accredited. Flexible schedule for working professionals. StateU Online.",
"SAT prep that works. Average 150-point score improvement. Guaranteed. PrepMaster Tutoring.",
"Professional photography workshops. Small class sizes, hands-on practice. LensArt Studio.",
"Spanish fluency in 6 months. Native instructors, conversation-first approach. LinguaViva.",
],
targeting_hints=[
"Adults 18-35, interests: programming, tech careers",
"Professionals 25-45, interests: MBA, business education",
"Parents of teens, interests: college prep, SAT",
"Adults 25-55, interests: photography, creative arts",
"Adults 18-50, interests: language learning, travel",
],
risk_signals=[],
label="legit",
severity=0.0,
),
AdTemplate(
category="fitness",
ad_copies=[
"Join our community gym. No contracts, cancel anytime. First month $19.99. FitLife Fitness.",
"Yoga for beginners — online classes with certified instructors. 7-day free trial. ZenFlow Yoga.",
"Custom meal plans designed by registered dietitians. Achieve your health goals. NutriPlan.",
"Running shoes engineered for comfort. 90-day return policy. SwiftStride Athletics.",
"Personal training at home. Certified trainers, flexible scheduling. FitVisit.",
],
targeting_hints=[
"Adults 18-55, interests: fitness, gym",
"Adults 25-50, interests: yoga, wellness, mindfulness",
"Health-conscious adults 22-55, interests: nutrition, diet",
"Runners 18-55, interests: running, athletics",
"Adults 25-50, interests: personal training, fitness",
],
risk_signals=[],
label="legit",
severity=0.0,
),
]
FRAUD_TEMPLATES: List[AdTemplate] = [
# === OBVIOUS SCAMS (Task 1) ===
AdTemplate(
category="fake_giveaway",
ad_copies=[
"CONGRATULATIONS!! You've been selected to win a FREE iPhone 16 Pro!! Click NOW before offer expires!!!",
"🎉 WINNER ALERT 🎉 Claim your FREE $1000 Amazon Gift Card! Limited time only! Act NOW!",
"You are the 1,000,000th visitor! Click here to claim your FREE MacBook Pro! Don't miss out!!!",
"FREE PS5 GIVEAWAY! Just complete a quick survey! Only 3 left! Hurry!!!",
"EXCLUSIVE: Win a Tesla Model 3! Enter your email NOW! Drawing ends tonight!!!",
],
targeting_hints=[
"All adults 18+, broad targeting, worldwide",
"Adults 18-65, interests: shopping, deals, coupons",
"Adults 18-35, interests: technology, gaming",
"Young adults 16-30, interests: gaming, PlayStation",
"Adults 18-55, interests: cars, Tesla, electric vehicles",
],
risk_signals=[
"excessive urgency language",
"too-good-to-be-true offer",
"excessive punctuation/caps",
"no purchase necessary claims",
],
label="fraud",
fraud_type="fake_giveaway",
severity=0.9,
difficulty="easy",
),
AdTemplate(
category="counterfeit_goods",
ad_copies=[
"Designer handbags 90% OFF! Gucci, Louis Vuitton, Prada — all authentic! Limited stock! BargainLux.shop",
"Rolex watches starting at $49.99! 100% genuine! Free worldwide shipping! LuxWatchDeals.net",
"Nike Air Jordan CLEARANCE — $29.99! All sizes available! Original quality guaranteed! SneakerVault.store",
"Ray-Ban sunglasses factory direct! 95% discount! Premium quality! SunDealz.com",
"Canada Goose jackets $79.99! Authentic merchandise, warehouse clearance! ArcticDeals.shop",
],
targeting_hints=[
"Adults 18-45, interests: luxury brands, fashion deals",
"Men 25-55, interests: watches, luxury",
"Young adults 16-30, interests: sneakers, streetwear",
"Adults 18-50, interests: fashion, sunglasses, deals",
"Adults 20-45, interests: outdoor gear, fashion",
],
risk_signals=[
"impossibly low prices for luxury goods",
"unfamiliar domain",
"claims of authenticity with extreme discounts",
],
label="fraud",
fraud_type="counterfeit",
severity=0.8,
difficulty="easy",
),
AdTemplate(
category="miracle_cure",
ad_copies=[
"DOCTORS HATE THIS! One simple trick cures diabetes in 7 days! Big Pharma doesn't want you to know!",
"Lose 30 pounds in 2 weeks with this ancient herb! No diet, no exercise! MiracleSlim pills!",
"CURE CANCER NATURALLY! This secret remedy has a 99% success rate! Order now before it's banned!",
"Reverse aging in 14 days! Scientists discover fountain of youth pill! Limited supply!",
"Grow 3 inches taller at ANY age! Patented growth formula! 100% guaranteed results!",
],
targeting_hints=[
"Adults 35-70, interests: health, diabetes, natural remedies",
"Adults 25-60, interests: weight loss, diet, fitness",
"Adults 40-75, interests: cancer, health, alternative medicine",
"Adults 35-65, interests: anti-aging, beauty, health",
"Men 18-40, interests: fitness, height, self-improvement",
],
risk_signals=[
"unsubstantiated medical claims",
"conspiracy language ('they don't want you to know')",
"impossible health promises",
"urgency/scarcity tactics",
],
label="fraud",
fraud_type="miracle_cure",
severity=0.95,
difficulty="easy",
),
AdTemplate(
category="advance_fee",
ad_copies=[
"URGENT: I am Prince Adebayo of Nigeria. I need your help to transfer $4.5 million. You keep 30%.",
"Congratulations! You've inherited $2.8 million from a distant relative. Pay $200 processing fee to claim.",
"WORK FROM HOME! Earn $5000/week stuffing envelopes! No experience needed! Send $50 registration fee.",
"URGENT BUSINESS PROPOSAL: Oil company executive needs foreign partner. $10M deal. Reply immediately.",
"You've won the UK National Lottery! Send $100 for tax processing to receive your $1.5M prize.",
],
targeting_hints=[
"All adults 18+, broad targeting",
"Adults 30-70, interests: finance, inheritance",
"Adults 18-65, interests: work from home, jobs",
"Adults 30-65, interests: business, investment",
"Adults 25-70, interests: lottery, gambling, luck",
],
risk_signals=[
"advance fee request",
"unsolicited money offer",
"urgency pressure",
"request for personal information",
],
label="fraud",
fraud_type="advance_fee_scam",
severity=0.85,
difficulty="easy",
),
# === SOPHISTICATED SCAMS (Task 2) ===
AdTemplate(
category="fake_crypto",
ad_copies=[
"Invest in DeFi with confidence. Our AI-powered trading platform delivers 12-15% monthly returns. Audited smart contracts. Join CryptoYield Pro.",
"Stake your crypto with institutional-grade security. 8% APY on BTC, 12% on ETH. Regulated in Singapore. VaultStake Finance.",
"New token launch: GreenChain ($GRNC) — carbon credit blockchain. Pre-sale live. Backed by major VCs. Read our whitepaper.",
"Automated crypto arbitrage — our algorithm exploits price differences across exchanges. Average 20% monthly. QuantBot Trading.",
"Web3 real estate tokenization. Own fractions of premium properties. Starting at $100. Licensed broker-dealer. PropChain.io",
],
targeting_hints=[
"Men 25-45, interests: cryptocurrency, DeFi, investing",
"Adults 25-55, interests: crypto staking, passive income",
"Tech-savvy adults 20-40, interests: blockchain, Web3, tokens",
"Adults 25-50, interests: algo trading, crypto, finance",
"Adults 30-55, interests: real estate, investing, crypto",
],
risk_signals=[
"high guaranteed returns",
"complex financial product",
],
label="fraud",
fraud_type="fake_crypto",
severity=0.7,
difficulty="medium",
),
AdTemplate(
category="celebrity_endorsement_fraud",
ad_copies=[
"Elon Musk reveals his #1 investment for 2026. 'This will be bigger than Tesla.' Exclusive interview inside.",
"Warren Buffett's secret stock pick leaked! Financial advisors are scrambling. See the details before it's removed.",
"Oprah's favorite weight loss secret finally revealed. 'I lost 40 pounds without dieting.' Doctor-approved method.",
"Mark Cuban: 'I'm putting everything into this AI company.' Find out which stock billionaires are buying.",
"Taylor Swift partners with new wellness brand. 'It changed my life.' Limited celebrity edition available.",
],
targeting_hints=[
"Adults 25-55, interests: investing, Elon Musk, technology",
"Adults 35-70, interests: stocks, Warren Buffett, investing",
"Women 25-60, interests: weight loss, Oprah, wellness",
"Adults 25-50, interests: AI, investing, Mark Cuban",
"Adults 18-45, interests: Taylor Swift, wellness, beauty",
],
risk_signals=[
"celebrity name used without verification",
"urgency/exclusivity language",
],
label="fraud",
fraud_type="fake_endorsement",
severity=0.65,
difficulty="medium",
),
AdTemplate(
category="clone_brand",
ad_copies=[
"Amaz0n Warehouse Clearance — Electronics up to 70% off. Official overstock sale. Limited time. amaz0n-deals.com",
"PayPaI Security Alert: Your account needs verification. Update your information to avoid suspension. Secure portal.",
"Walmrt+ Members: Exclusive flash sale this weekend only. Save an extra 25% on groceries. Members-only link.",
"App1e Trade-In Event: Get up to $800 for your old device. Upgrade to iPhone 16. Authorized reseller.",
"Netfliix Premium — Get 1 year for $29.99! Special promotional price. Activate through our partner link.",
],
targeting_hints=[
"Adults 18-65, interests: Amazon, deals, electronics",
"Adults 18-65, interests: online payments, PayPal",
"Adults 25-60, interests: Walmart, grocery shopping",
"Adults 18-55, interests: Apple, iPhone, technology",
"Adults 18-50, interests: Netflix, streaming, entertainment",
],
risk_signals=[
"brand name misspelling",
"unofficial domain",
],
label="fraud",
fraud_type="brand_impersonation",
severity=0.75,
difficulty="medium",
),
AdTemplate(
category="gray_area_supplements",
ad_copies=[
"NeuroPeak — clinically studied nootropic for enhanced focus and memory. 30-day money-back guarantee. FDA-registered facility.",
"TestoMax Elite — natural testosterone support for men over 40. Doctor-formulated. Published clinical trial results.",
"SlimBiome Pro — proprietary probiotic blend for healthy weight management. Featured in Health Magazine. GMP certified.",
"Joint Restore Plus — advanced collagen peptide formula. Thousands of 5-star reviews. Orthopedist recommended.",
"SleepDeep Ultra — melatonin-free natural sleep aid. Non-habit forming. Money-back guarantee. PharmGrade Labs.",
],
targeting_hints=[
"Adults 25-55, interests: nootropics, productivity, brain health",
"Men 40-65, interests: men's health, testosterone, fitness",
"Adults 30-60, interests: weight loss, probiotics, gut health",
"Adults 45-75, interests: joint health, supplements, arthritis",
"Adults 30-65, interests: sleep, insomnia, wellness",
],
risk_signals=[
"supplement with strong efficacy claims",
"medical-sounding language",
],
label="escalate",
fraud_type="gray_area",
severity=0.4,
difficulty="medium",
),
# === NETWORK SCAMS (Task 3 — individual ads that belong to fraud rings) ===
# These templates look almost entirely legitimate on the surface.
# The fraud is only detectable through cross-ad investigation.
AdTemplate(
category="network_crypto",
ad_copies=[
"Earn passive income with our DeFi staking pool. Community-driven, transparent governance. BlockYield.io",
"Next-gen DEX with lowest fees. Trade with zero slippage on major pairs. SwapNova Protocol.",
"NFT marketplace for digital artists. Mint, list, and sell with 2% fees. Creator-first platform. ArtBlock.exchange",
"Cross-chain bridge with military-grade security. Move assets between chains in seconds. ChainLink Pro.",
"Crypto tax software — auto-import from 50+ exchanges. CPA-approved reports. TaxChain Solutions.",
],
targeting_hints=[
"Adults 20-40, interests: DeFi, crypto staking",
"Adults 20-45, interests: crypto trading, DEX",
"Adults 20-40, interests: NFT, digital art, crypto",
"Adults 25-45, interests: cross-chain, crypto bridges",
"Adults 25-55, interests: crypto, tax, finance",
],
risk_signals=[],
label="fraud",
fraud_type="coordinated_network",
severity=0.6,
difficulty="hard",
),
AdTemplate(
category="network_ecommerce",
ad_copies=[
"Premium wireless earbuds — ANC, 40hr battery. Compare to AirPods Pro at half the price. SoundElite Store.",
"Smart home security camera — 2K resolution, night vision, cloud storage. TechGuard Home.",
"Portable power station for camping. 1000W, solar-ready. Adventure-proof design. PowerTrail Gear.",
"Ergonomic office chair — lumbar support, breathable mesh. 5-year warranty. WorkComfort Direct.",
"Robot vacuum with LiDAR mapping. Self-emptying dock. Smart home compatible. CleanBot Pro.",
],
targeting_hints=[
"Adults 18-45, interests: tech, audio, headphones",
"Adults 25-55, interests: home security, smart home",
"Adults 25-50, interests: camping, outdoor gear",
"Adults 25-55, interests: home office, ergonomics",
"Adults 25-55, interests: smart home, cleaning",
],
risk_signals=[],
label="fraud",
fraud_type="coordinated_network",
severity=0.5,
difficulty="hard",
),
AdTemplate(
category="network_fintech",
ad_copies=[
"Simplify your bookkeeping. AI-powered categorization, bank sync, tax-ready reports. LedgerFlow.",
"Expense management for growing teams. Real-time tracking, receipt scanning, approval workflows. SpendWise.",
"Invoicing made simple. Send professional invoices in 30 seconds. Accept 40+ payment methods. BillStream.",
"Payroll for startups — automated tax filings, direct deposit, compliance included. PayRun HR.",
"Business credit monitoring. Real-time alerts, score tracking, credit-building tips. BizCredit Insights.",
],
targeting_hints=[
"Small business owners 28-55, interests: accounting, bookkeeping",
"Finance managers 30-50, interests: expense management, SaaS",
"Freelancers 22-45, interests: invoicing, self-employment",
"Startup founders 25-45, interests: payroll, HR tech",
"Entrepreneurs 30-55, interests: business credit, finance",
],
risk_signals=[],
label="fraud",
fraud_type="coordinated_network",
severity=0.55,
difficulty="hard",
),
AdTemplate(
category="network_health",
ad_copies=[
"Telehealth appointments in minutes. Board-certified physicians, prescriptions delivered. MediConnect Health.",
"Mental wellness platform. Licensed therapists, flexible scheduling, insurance accepted. MindBridge Care.",
"At-home lab testing. Comprehensive panels, fast results, doctor-reviewed. HealthCheck Direct.",
"Nutrition coaching backed by science. Personalized meal plans from registered dietitians. NutriGuide Pro.",
"Fitness tracking reimagined. AI-powered workout plans, progress analytics, community support. FitMetrics.",
],
targeting_hints=[
"Adults 25-60, interests: telemedicine, healthcare",
"Adults 25-50, interests: mental health, therapy, wellness",
"Health-conscious adults 30-55, interests: lab testing, preventive health",
"Adults 25-50, interests: nutrition, diet planning, health",
"Fitness enthusiasts 20-45, interests: fitness tracking, wearables",
],
risk_signals=[],
label="fraud",
fraud_type="coordinated_network",
severity=0.5,
difficulty="hard",
),
]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187"""
Simulated landing page investigation data.
When the agent investigates 'landing_page' for an ad, this module
generates the findings text based on the ad's ground truth label.
"""
from __future__ import annotations
import random
from dataclasses import dataclass
from typing import List
@dataclass
class LandingPageData:
domain: str
domain_age_days: int
ssl_valid: bool
registrar: str
content_summary: str
redirect_chain: List[str]
similarity_to_known_scams: float # 0.0-1.0
key_claims: List[str]
suspicious_elements: List[str]
def to_investigation_text(self) -> str:
ssl_status = "Valid SSL certificate" if self.ssl_valid else "NO SSL / expired certificate"
redirects = " -> ".join(self.redirect_chain) if self.redirect_chain else "No redirects (direct)"
suspicious = "\n".join(f" - {s}" for s in self.suspicious_elements) if self.suspicious_elements else " None detected"
claims = "\n".join(f" - {c}" for c in self.key_claims) if self.key_claims else " None"
lines = [
f"Domain: {self.domain}",
f"Domain age: {self.domain_age_days} days",
f"SSL: {ssl_status}",
f"Registrar: {self.registrar}",
f"WHOIS privacy: {'Enabled' if 'privacy' in self.registrar.lower() or 'proxy' in self.registrar.lower() else 'Disabled (registrant info public)'}",
f"Redirect chain: {redirects}",
f"Similarity to known scam templates: {self.similarity_to_known_scams:.0%}",
f"Key claims on page:\n{claims}",
f"Suspicious elements:\n{suspicious}",
f"Content summary: {self.content_summary}",
]
return "\n".join(lines)
_LEGIT_REGISTRARS = ["GoDaddy", "Namecheap", "Google Domains", "Cloudflare Registrar", "AWS Route 53"]
_SUSPICIOUS_REGISTRARS = ["NameSilo", "Epik", "Njalla (privacy)", "Tucows (privacy proxy)", "Openprovider"]
_LEGIT_DOMAINS_SUFFIXES = [".com", ".co", ".org", ".io", ".net"]
_SCAM_DOMAINS_SUFFIXES = [".shop", ".store", ".xyz", ".click", ".top", ".buzz", ".site"]
def generate_landing_page(
rng: random.Random,
ad_id: str,
is_fraud: bool,
fraud_type: str = "",
*,
domain_override: str | None = None,
registrar_override: str | None = None,
) -> LandingPageData:
"""Generate simulated landing page investigation data."""
base_word = rng.choice(["deal", "offer", "shop", "store", "buy", "get", "best", "top", "pro", "elite"])
if is_fraud:
suffix = rng.choice(_SCAM_DOMAINS_SUFFIXES)
domain = domain_override or f"{base_word}{rng.randint(10, 9999)}{suffix}"
domain_age = rng.randint(1, 60)
ssl_valid = rng.random() < 0.4
registrar = registrar_override or rng.choice(_SUSPICIOUS_REGISTRARS)
similarity = round(rng.uniform(0.5, 0.95), 2)
redirect_count = rng.randint(1, 4)
redirect_chain = [domain]
for _ in range(redirect_count):
redirect_chain.append(f"redirect{rng.randint(1, 999)}{rng.choice(['.click', '.top', '.xyz'])}")
redirect_chain.append(f"final-{rng.randint(1, 999)}{rng.choice(['.site', '.store'])}")
suspicious = _get_fraud_suspicious_elements(rng, fraud_type)
claims = _get_fraud_claims(rng, fraud_type)
content = _get_fraud_content_summary(rng, fraud_type)
else:
suffix = rng.choice(_LEGIT_DOMAINS_SUFFIXES)
brand = rng.choice(["homenest", "stylehaven", "taskflow", "fitlife", "sparkle", "codeacademy", "nutri"])
domain = domain_override or f"{brand}{suffix}"
domain_age = rng.randint(365, 5000)
ssl_valid = True
registrar = registrar_override or rng.choice(_LEGIT_REGISTRARS)
similarity = round(rng.uniform(0.0, 0.15), 2)
redirect_chain = []
suspicious = []
claims = _get_legit_claims(rng)
content = _get_legit_content_summary(rng)
return LandingPageData(
domain=domain,
domain_age_days=domain_age,
ssl_valid=ssl_valid,
registrar=registrar,
content_summary=content,
redirect_chain=redirect_chain,
similarity_to_known_scams=similarity,
key_claims=claims,
suspicious_elements=suspicious,
)
def _get_fraud_suspicious_elements(rng: random.Random, fraud_type: str) -> List[str]:
common = [
"No physical address listed",
"No contact phone number",
"Privacy policy copied from template",
"Terms of service link returns 404",
]
type_specific = {
"fake_giveaway": ["Countdown timer with fake urgency", "Requests personal info before any value provided"],
"counterfeit": ["Product images appear stolen from official brand site", "Price comparison shows 90%+ discount vs retail"],
"miracle_cure": ["FDA disclaimer buried in footer", "Before/after photos appear digitally altered"],
"advance_fee_scam": ["Wire transfer requested upfront", "No company registration found"],
"fake_crypto": ["Smart contract not verified on-chain", "Team photos are stock images"],
"fake_endorsement": ["Celebrity quote not found in any verified source", "Affiliate tracking parameters in URL"],
"brand_impersonation": ["Domain mimics well-known brand with character substitution", "Logo appears edited from official assets"],
"gray_area": ["Citations reference unpublished or retracted studies", "Testimonials lack verifiable details"],
"coordinated_network": ["Identical page template used across multiple domains", "Contact form submits to third-party aggregator"],
}
elements = list(common)
elements.extend(type_specific.get(fraud_type, []))
rng.shuffle(elements)
return elements[: rng.randint(2, min(5, len(elements)))]
def _get_fraud_claims(rng: random.Random, fraud_type: str) -> List[str]:
by_type = {
"fake_giveaway": ["100% free, no purchase necessary", "Guaranteed winner", "Act now — expires in 2 hours"],
"counterfeit": ["Authentic products", "Direct from manufacturer", "90% below retail price"],
"miracle_cure": ["Clinically proven results", "Works in 7 days or less", "Endorsed by doctors"],
"advance_fee_scam": ["Guaranteed returns", "Low processing fee required", "Confidential opportunity"],
"fake_crypto": ["12-15% monthly returns guaranteed", "Audited by top security firms", "Risk-free investment"],
"fake_endorsement": ["As seen on TV", "Celebrity recommended", "Limited exclusive offer"],
"brand_impersonation": ["Official authorized retailer", "Factory direct pricing", "Same quality, lower price"],
"gray_area": ["Clinically studied ingredients", "Doctor recommended", "30-day money-back guarantee"],
"coordinated_network": ["Limited stock available", "Thousands of 5-star reviews", "Fast free shipping"],
}
return by_type.get(fraud_type, ["Special limited offer", "Act now"])
def _get_fraud_content_summary(rng: random.Random, fraud_type: str) -> str:
summaries = {
"fake_giveaway": "Landing page features a large countdown timer and a form requesting name, email, phone, and address. No clear sponsor or rules disclosure.",
"counterfeit": "Product catalog showing luxury branded items at extreme discounts. Stock photos. Payment accepted via wire transfer and crypto only.",
"miracle_cure": "Long-form sales page with testimonials, before/after images, and pseudoscientific explanations. Multiple urgency CTAs.",
"advance_fee_scam": "Simple page with a letter-style appeal requesting wire transfer. Grammar errors. No company details.",
"fake_crypto": "Professional-looking platform with dashboard screenshots. Whitepaper link leads to a generic PDF. Team bios use stock photos.",
"fake_endorsement": "News article-style page with celebrity photos. Comments section appears pre-populated with positive feedback.",
"brand_impersonation": "Near-replica of the official brand website. URL uses character substitution. Cart and checkout flow functional but data destination unclear.",
"gray_area": "Well-designed supplement product page. Ingredient list present but efficacy claims exceed scientific evidence. Has a real return policy.",
"coordinated_network": "Standard e-commerce template. Products appear legitimate but company details are vague. Identical template to other flagged sites.",
}
return summaries.get(fraud_type, "Generic landing page with minimal content and heavy use of urgency language.")
def _get_legit_claims(rng: random.Random) -> List[str]:
options = [
"Free shipping on orders over $50",
"14-day free trial",
"Money-back guarantee",
"Established since 2010",
"4.5-star average customer rating",
"Licensed and insured",
"BBB accredited",
"Certified organic ingredients",
]
rng.shuffle(options)
return options[: rng.randint(2, 4)]
def _get_legit_content_summary(rng: random.Random) -> str:
options = [
"Well-structured business website with clear product catalog, about page, contact information, and shipping policy.",
"Professional service website with team bios, case studies, client testimonials, and clear pricing.",
"E-commerce store with detailed product descriptions, customer reviews, FAQ section, and accessible support.",
"SaaS landing page with feature breakdown, pricing tiers, integration docs, and live demo option.",
]
return rng.choice(options)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194"""
Fraud network (ring) generation for Task 3 using networkx.
Generates complex fraud ring topologies:
- Simple cliques (3-5 ads fully connected)
- Chain structures (A-B via payment, B-C via creative — transitive reasoning required)
- Hub-and-spoke (one master account linked to satellites)
Individual ads in a ring may look borderline; the signal is in the connections.
Each edge in the graph carries the signal type that connects the two ads.
"""
from __future__ import annotations
import random
from dataclasses import dataclass, field
from typing import Dict, List, Set, Tuple
import networkx as nx
@dataclass
class FraudRing:
ring_id: str
member_ad_ids: List[str]
shared_signals: Dict[str, str] # signal_type -> shared_value
topology: str = "clique" # clique, chain, hub_spoke
@property
def size(self) -> int:
return len(self.member_ad_ids)
_RING_TOPOLOGIES = ["clique", "chain", "hub_spoke"]
_SIGNAL_POOL_KEYS = ["payment_method", "domain_registrar", "creative_template", "targeting_overlap"]
_REGISTRAR_CHOICES = ["Njalla (privacy)", "Epik", "NameSilo", "Tucows (privacy proxy)"]
_TARGETING_CHOICES = [
"Men 25-45, crypto+investing, US+UK+AU",
"Adults 18-35, tech+gaming, worldwide",
"Women 25-55, health+beauty, US+CA",
"Adults 30-60, finance+real-estate, US+UK",
"Adults 20-40, e-commerce+dropshipping, US+EU",
]
def _make_signal_pool(rng: random.Random, ring_index: int) -> Dict[str, str]:
"""Generate a pool of shared signal values for one ring."""
return {
"payment_method": f"pmt_ring_{rng.randint(10000, 99999)}",
"domain_registrar": rng.choice(_REGISTRAR_CHOICES),
"creative_template": f"tmpl_{rng.randint(1000, 9999)}",
"targeting_overlap": rng.choice(_TARGETING_CHOICES),
}
def generate_fraud_networks(
rng: random.Random,
n_rings: int,
available_fraud_ad_ids: List[str],
) -> Tuple[List[FraudRing], Dict[str, List[str]]]:
"""
Generate fraud ring structures with complex topologies.
Returns:
rings: list of FraudRing objects
ad_to_rings: mapping from ad_id to list of ring_ids it belongs to
"""
G = nx.Graph()
rings: List[FraudRing] = []
ad_to_rings: Dict[str, List[str]] = {}
remaining = list(available_fraud_ad_ids)
rng.shuffle(remaining)
for i in range(n_rings):
if len(remaining) < 3:
break
ring_size = rng.randint(3, min(5, len(remaining)))
members = remaining[:ring_size]
remaining = remaining[ring_size:]
topology = rng.choice(_RING_TOPOLOGIES)
signal_pool = _make_signal_pool(rng, i)
signal_keys = list(_SIGNAL_POOL_KEYS)
rng.shuffle(signal_keys)
n_shared = rng.randint(2, len(signal_keys))
shared_signals = {k: signal_pool[k] for k in signal_keys[:n_shared]}
_add_edges_for_topology(G, members, shared_signals, topology, rng)
ring_id = f"ring_{i}"
ring = FraudRing(
ring_id=ring_id,
member_ad_ids=members,
shared_signals=shared_signals,
topology=topology,
)
rings.append(ring)
for ad_id in members:
ad_to_rings.setdefault(ad_id, []).append(ring_id)
G.add_node(ad_id, ring_id=ring_id)
# Optionally create bridge nodes between rings for extra complexity
if len(rings) >= 2 and remaining:
_add_bridge_ads(G, rings, remaining, ad_to_rings, rng)
return rings, ad_to_rings
def _add_edges_for_topology(
G: nx.Graph,
members: List[str],
shared_signals: Dict[str, str],
topology: str,
rng: random.Random,
) -> None:
"""Add edges to the graph based on the ring topology."""
signal_types = list(shared_signals.keys())
if topology == "clique":
for i, a in enumerate(members):
for b in members[i + 1:]:
signal = rng.choice(signal_types)
G.add_edge(a, b, signal_type=signal, signal_value=shared_signals[signal])
elif topology == "chain":
for idx in range(len(members) - 1):
signal = signal_types[idx % len(signal_types)]
G.add_edge(
members[idx], members[idx + 1],
signal_type=signal, signal_value=shared_signals[signal],
)
elif topology == "hub_spoke":
hub = members[0]
for spoke in members[1:]:
signal = rng.choice(signal_types)
G.add_edge(hub, spoke, signal_type=signal, signal_value=shared_signals[signal])
def _add_bridge_ads(
G: nx.Graph,
rings: List[FraudRing],
remaining: List[str],
ad_to_rings: Dict[str, List[str]],
rng: random.Random,
) -> None:
"""Optionally link two rings via a shared bridge ad from the remaining pool."""
if len(remaining) < 1 or len(rings) < 2:
return
bridge_ad = remaining.pop(0)
r1, r2 = rings[0], rings[1]
bridge_to_r1 = rng.choice(r1.member_ad_ids)
bridge_to_r2 = rng.choice(r2.member_ad_ids)
r1.member_ad_ids.append(bridge_ad)
ad_to_rings.setdefault(bridge_ad, []).extend([r1.ring_id, r2.ring_id])
sig_key = rng.choice(list(r1.shared_signals.keys()))
G.add_edge(bridge_ad, bridge_to_r1, signal_type=sig_key, signal_value=r1.shared_signals[sig_key])
sig_key2 = rng.choice(list(r2.shared_signals.keys()))
G.add_edge(bridge_ad, bridge_to_r2, signal_type=sig_key2, signal_value=r2.shared_signals[sig_key2])
def get_ring_shared_signal_text(ring: FraudRing) -> str:
"""Describe the shared signals in a ring (for grader/debug use)."""
lines = [f"Fraud Ring {ring.ring_id} ({ring.size} members, topology={ring.topology}):"]
lines.append(f" Members: {', '.join(ring.member_ad_ids)}")
lines.append(" Shared signals:")
for signal_type, value in ring.shared_signals.items():
lines.append(f" - {signal_type}: {value}")
return "\n".join(lines)
def build_ground_truth_graph(rings: List[FraudRing]) -> nx.Graph:
"""Reconstruct the full ground truth network graph from rings.
Used by graders to compute the expected set of edges.
"""
G = nx.Graph()
for ring in rings:
for i, a in enumerate(ring.member_ad_ids):
G.add_node(a, ring_id=ring.ring_id)
for b in ring.member_ad_ids[i + 1:]:
G.add_edge(a, b, ring_id=ring.ring_id)
return G1234567891011121314"""Graders for scoring agent performance on each task."""
from .base_grader import grade_episode
from .task1_grader import Task1Grader
from .task2_grader import Task2Grader
from .task3_grader import Task3Grader
GRADERS = {
"task_1": Task1Grader(),
"task_2": Task2Grader(),
"task_3": Task3Grader(),
}
__all__ = ["grade_episode", "Task1Grader", "Task2Grader", "Task3Grader", "GRADERS"]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113"""
Shared grading logic for all tasks.
Each grader produces a 0.0-1.0 score by normalizing raw reward
between theoretical worst and best cases.
"""
from __future__ import annotations
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import Any, Dict, List, Optional
_NORM_EPS = 1e-8 # For numerical stability
@dataclass
class VerdictResult:
ad_id: str
verdict: str # approve, reject, escalate
confidence: float
ground_truth: str # fraud, legit, escalate
auto_approved: bool = False
@dataclass
class LinkResult:
ad_id_1: str
ad_id_2: str
correct: bool
@dataclass
class EpisodeRecord:
"""All data needed for grading a completed episode."""
task_id: str
total_steps: int
action_budget: int
verdicts: List[VerdictResult]
links: List[LinkResult]
ads_metadata: List[Dict[str, Any]] # [{ad_id, ground_truth, severity, ...}]
n_fraud_rings: int = 0
ring_sizes: List[int] = None
def __post_init__(self):
if self.ring_sizes is None:
self.ring_sizes = []
class BaseGrader(ABC):
"""Abstract grader that scores an episode 0.0-1.0."""
@abstractmethod
def grade(self, record: EpisodeRecord) -> float:
"""Return a score in [0.0, 1.0]."""
...
def _count_correct_verdicts(self, verdicts: List[VerdictResult]) -> int:
return sum(1 for v in verdicts if self._is_correct(v))
def _count_false_positives(self, verdicts: List[VerdictResult]) -> int:
return sum(
1 for v in verdicts
if v.verdict == "reject" and v.ground_truth == "legit"
)
def _count_false_negatives(self, verdicts: List[VerdictResult]) -> int:
return sum(
1 for v in verdicts
if v.verdict == "approve" and v.ground_truth == "fraud"
)
def _is_correct(self, v: VerdictResult) -> bool:
return (
(v.verdict == "reject" and v.ground_truth == "fraud")
or (v.verdict == "approve" and v.ground_truth == "legit")
or (v.verdict == "escalate" and v.ground_truth == "escalate")
)
def _verdict_reward(self, v: VerdictResult, severity: float = 0.5) -> float:
if v.verdict == "reject" and v.ground_truth == "fraud":
return 0.3 + 0.1 * severity
elif v.verdict == "approve" and v.ground_truth == "legit":
return 0.1
elif v.verdict == "escalate" and v.ground_truth == "escalate":
return 0.15
elif v.verdict == "reject" and v.ground_truth == "legit":
return -0.35
elif v.verdict == "approve" and v.ground_truth == "fraud":
return -0.5
elif v.verdict == "escalate":
return -0.05
elif v.verdict == "approve" and v.ground_truth == "escalate":
return -0.15
elif v.verdict == "reject" and v.ground_truth == "escalate":
return -0.1
return -0.05
def _normalize(self, raw: float, best: float, worst: float) -> float:
score_range = best - worst
if score_range <= 0:
return 0.5
normalized = (raw - worst) / (score_range + _NORM_EPS)
return max(0.0, min(1.0, normalized))
def grade_episode(record: EpisodeRecord) -> float:
"""Grade an episode using the appropriate task grader."""
from . import GRADERS
grader = GRADERS.get(record.task_id)
if grader is None:
raise ValueError(f"Unknown task_id: {record.task_id}")
return grader.grade(record)12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849"""
Task 1 Grader: Basic Ad Triage (Easy).
Scores based on verdict accuracy only. No network or calibration bonuses.
5 ads, 25 budget — a decent LLM should score 0.6-0.8.
"""
from __future__ import annotations
from .base_grader import BaseGrader, EpisodeRecord
class Task1Grader(BaseGrader):
def grade(self, record: EpisodeRecord) -> float:
raw = 0.0
best = 0.0
worst = 0.0
severity_map = {
m["ad_id"]: m.get("severity", 0.5) for m in record.ads_metadata
}
for v in record.verdicts:
severity = severity_map.get(v.ad_id, 0.5)
raw += self._verdict_reward(v, severity)
if v.ground_truth == "fraud":
best += 0.3 + 0.1 * severity
worst -= 0.5
elif v.ground_truth == "legit":
best += 0.1
worst -= 0.35
elif v.ground_truth == "escalate":
best += 0.15
worst -= 0.15
n_investigations = max(0, record.total_steps - len([
v for v in record.verdicts if not v.auto_approved
]))
raw -= n_investigations * 0.02
worst -= record.action_budget * 0.02
best += 0.2
if record.total_steps > 0:
correct = self._count_correct_verdicts(record.verdicts)
raw += (correct / record.total_steps) * 0.2
return self._normalize(raw, best, worst)1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889"""
Task 2 Grader: Sophisticated Fraud Under Budget Pressure (Medium).
Adds budget efficiency bonus and calibration scoring on top of verdict accuracy.
12 ads, 30 budget — requires triage, expected baseline 0.3-0.5.
"""
from __future__ import annotations
from .base_grader import BaseGrader, EpisodeRecord
class Task2Grader(BaseGrader):
def grade(self, record: EpisodeRecord) -> float:
raw = 0.0
best = 0.0
worst = 0.0
severity_map = {
m["ad_id"]: m.get("severity", 0.5) for m in record.ads_metadata
}
for v in record.verdicts:
severity = severity_map.get(v.ad_id, 0.5)
raw += self._verdict_reward(v, severity)
if v.ground_truth == "fraud":
best += 0.3 + 0.1 * severity
worst -= 0.5
elif v.ground_truth == "legit":
best += 0.1
worst -= 0.35
elif v.ground_truth == "escalate":
best += 0.15
worst -= 0.15
n_investigations = max(0, record.total_steps - len([
v for v in record.verdicts if not v.auto_approved
]))
raw -= n_investigations * 0.02
worst -= record.action_budget * 0.02
# Budget efficiency bonus
best += 0.2
if record.total_steps > 0:
correct = self._count_correct_verdicts(record.verdicts)
raw += (correct / record.total_steps) * 0.2
# Calibration bonus: reward agents whose stated confidence
# correlates with actual accuracy
calibration = self._compute_calibration(record)
raw += calibration * 0.15
best += 0.15
return self._normalize(raw, best, worst)
def _compute_calibration(self, record: EpisodeRecord) -> float:
"""
Measure how well confidence tracks correctness.
Bins verdicts by confidence and checks if the fraction correct
in each bin roughly matches the stated confidence.
"""
manual = [v for v in record.verdicts if not v.auto_approved]
if len(manual) < 3:
return 0.5
bins = {"low": [], "mid": [], "high": []}
for v in manual:
if v.confidence < 0.4:
bins["low"].append(v)
elif v.confidence < 0.7:
bins["mid"].append(v)
else:
bins["high"].append(v)
errors = []
for _label, group in bins.items():
if not group:
continue
avg_conf = sum(v.confidence for v in group) / len(group)
avg_acc = sum(1 for v in group if self._is_correct(v)) / len(group)
errors.append(abs(avg_conf - avg_acc))
if not errors:
return 0.5
avg_error = sum(errors) / len(errors)
return max(0.0, 1.0 - 2.0 * avg_error)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133"""
Task 3 Grader: Coordinated Fraud Network Detection (Hard).
Adds graph-based network detection scoring on top of verdict accuracy,
budget efficiency, and calibration. 20 ads, 35 budget, 3 fraud rings
with varied topologies. Expected baseline 0.1-0.3.
Network scoring uses ground truth edge coverage: what fraction of
ground-truth ring connections did the agent discover via link_accounts?
"""
from __future__ import annotations
from .base_grader import BaseGrader, EpisodeRecord
class Task3Grader(BaseGrader):
def grade(self, record: EpisodeRecord) -> float:
raw = 0.0
best = 0.0
worst = 0.0
severity_map = {
m["ad_id"]: m.get("severity", 0.5) for m in record.ads_metadata
}
for v in record.verdicts:
severity = severity_map.get(v.ad_id, 0.5)
raw += self._verdict_reward(v, severity)
if v.ground_truth == "fraud":
best += 0.3 + 0.1 * severity
worst -= 0.5
elif v.ground_truth == "legit":
best += 0.1
worst -= 0.35
elif v.ground_truth == "escalate":
best += 0.15
worst -= 0.15
n_investigations = max(0, record.total_steps - len([
v for v in record.verdicts if not v.auto_approved
]))
raw -= n_investigations * 0.02
worst -= record.action_budget * 0.02
# Budget efficiency bonus
best += 0.2
if record.total_steps > 0:
correct = self._count_correct_verdicts(record.verdicts)
raw += (correct / record.total_steps) * 0.2
# Calibration bonus
calibration = self._compute_calibration(record)
raw += calibration * 0.15
best += 0.15
# Graph-based network detection scoring
network_reward = self._compute_network_score(record)
raw += network_reward
# Best case: discover all ground truth edges
total_gt_edges = self._count_ground_truth_edges(record)
best += max(total_gt_edges, 1) * 0.4
worst -= max(len(record.links), 1) * 0.2
# Investigation coverage bonus: reward breadth over depth
coverage = self._compute_coverage_bonus(record)
raw += coverage * 0.1
best += 0.1
return self._normalize(raw, best, worst)
def _compute_calibration(self, record: EpisodeRecord) -> float:
manual = [v for v in record.verdicts if not v.auto_approved]
if len(manual) < 3:
return 0.5
bins = {"low": [], "mid": [], "high": []}
for v in manual:
if v.confidence < 0.4:
bins["low"].append(v)
elif v.confidence < 0.7:
bins["mid"].append(v)
else:
bins["high"].append(v)
errors = []
for _label, group in bins.items():
if not group:
continue
avg_conf = sum(v.confidence for v in group) / len(group)
avg_acc = sum(1 for v in group if self._is_correct(v)) / len(group)
errors.append(abs(avg_conf - avg_acc))
if not errors:
return 0.5
avg_error = sum(errors) / len(errors)
return max(0.0, 1.0 - 2.0 * avg_error)
def _count_ground_truth_edges(self, record: EpisodeRecord) -> int:
"""Count the total number of ground truth edges across all rings."""
total = 0
for ring_size in record.ring_sizes:
total += ring_size * (ring_size - 1) // 2
return total
def _compute_network_score(self, record: EpisodeRecord) -> float:
"""Score link_accounts actions against ground truth fraud rings.
Uses edge-coverage: correct links earn +0.4 each, incorrect
links incur -0.25 each (heavier penalty since decoys exist).
"""
correct_links = sum(1 for l in record.links if l.correct)
incorrect_links = sum(1 for l in record.links if not l.correct)
reward = correct_links * 0.4
reward -= incorrect_links * 0.25
return reward
def _compute_coverage_bonus(self, record: EpisodeRecord) -> float:
"""Reward agents that investigate across multiple ads (breadth).
Agents that only deep-dive a single ad miss network signals.
"""
if not record.ads_metadata:
return 0.0
total_ads = len(record.ads_metadata)
reviewed = sum(1 for v in record.verdicts if not v.auto_approved)
coverage_ratio = reviewed / total_ads if total_ads > 0 else 0.0
return min(1.0, coverage_ratio)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451"""
Inference Script — Ad Fraud Investigation Environment
===================================
MANDATORY
- Before submitting, ensure the following variables are defined in your environment configuration:
API_BASE_URL The API endpoint for the LLM.
MODEL_NAME The model identifier to use for inference.
HF_TOKEN Your Hugging Face / API key.
- The inference script must be named `inference.py` and placed in the root directory of the project
- Participants must use OpenAI Client for all LLM calls using above variables
STDOUT FORMAT
- The script must emit exactly three line types to stdout, in this order:
[START] task=<task_name> env=<benchmark> model=<model_name>
[STEP] step=<n> action=<action_str> reward=<0.00> done=<true|false> error=<msg|null>
[END] success=<true|false> steps=<n> score=<score> rewards=<r1,r2,...,rn>
"""
from __future__ import annotations
import json
import logging
import os
import re
import sys
from pathlib import Path
from typing import Any, Dict, List, Optional
from openai import OpenAI
try:
from .client import AdFraudEnv
from .models import AdReviewAction
from .data.ad_generator import TASK_CONFIGS
except ImportError:
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from ad_fraud_env.client import AdFraudEnv
from ad_fraud_env.models import AdReviewAction
from ad_fraud_env.data.ad_generator import TASK_CONFIGS
from dotenv import load_dotenv
load_dotenv()
API_BASE_URL = os.getenv("API_BASE_URL") or "https://router.huggingface.co/v1"
API_KEY = os.getenv("HF_TOKEN") or os.getenv("API_KEY")
MODEL_NAME = os.getenv("MODEL_NAME") or "meta-llama/Llama-3.1-8B-Instruct"
ENV_URL = os.getenv("AD_FRAUD_ENV_URL", "https://QuantumTransformer-AdArena.hf.space")
BENCHMARK = "ad_fraud_env"
TEMPERATURE = 0.1
MAX_TOKENS = 256
FALLBACK_VERDICT = "escalate"
logger = logging.getLogger(__name__)
LOG_DIR = Path(__file__).resolve().parent / "convo_logging"
# ---------------------------------------------------------------------------
# Mandatory structured stdout logging
# ---------------------------------------------------------------------------
def log_start(task: str, env: str, model: str) -> None:
print(f"[START] task={task} env={env} model={model}", flush=True)
def log_step(step: int, action: str, reward: float, done: bool, error: Optional[str]) -> None:
error_val = error if error else "null"
done_val = str(done).lower()
print(
f"[STEP] step={step} action={action} reward={reward:.2f} "
f"done={done_val} error={error_val}",
flush=True,
)
def log_end(success: bool, steps: int, score: float, rewards: List[float]) -> None:
rewards_str = ",".join(f"{r:.2f}" for r in rewards)
print(
f"[END] success={str(success).lower()} steps={steps} "
f"score={score:.2f} rewards={rewards_str}",
flush=True,
)
def _format_action(action: AdReviewAction) -> str:
"""Compact action string for [STEP] log line."""
if action.action_type == "investigate":
return f"investigate({action.ad_id},{action.investigation_target})"
elif action.action_type == "verdict":
conf = action.confidence if action.confidence is not None else 0.5
return f"verdict({action.ad_id},{action.verdict},{conf:.2f})"
elif action.action_type == "link_accounts":
return f"link_accounts({action.ad_id},{action.linked_ad_id})"
return f"unknown({action.ad_id})"
# ---------------------------------------------------------------------------
# System prompt & helpers
# ---------------------------------------------------------------------------
SYSTEM_PROMPT = """\
You are an ad fraud investigator reviewing a queue of advertisements.
Your job is to investigate suspicious ads and render verdicts (approve, reject, or escalate).
For each step, you must output a single JSON action. The action schema is:
{
"action_type": "investigate" | "verdict" | "link_accounts",
"ad_id": "<ad ID, e.g. ad_001>",
// For investigate actions:
"investigation_target": "advertiser_history" | "landing_page" | "payment_method" | "targeting_overlap" | "creative_similarity" | "campaign_structure",
// For verdict actions:
"verdict": "approve" | "reject" | "escalate",
"confidence": <float 0.0-1.0>,
// For link_accounts actions:
"linked_ad_id": "<other ad ID>",
"link_reason": "<reason>"
}
Strategy:
1. Start by reading the queue summary and the first ad's information.
2. For obviously suspicious ads, investigate 1-2 signals then reject.
3. For clearly legitimate ads, approve quickly with high confidence.
4. For ambiguous ads, investigate more deeply before deciding.
5. Manage your budget — you cannot investigate everything.
6. For link_accounts, only flag connections when you see shared signals across ads (same payment method, similar creative template, targeting overlap).
Output ONLY the JSON action, no other text.
"""
JSON_BLOCK_RE = re.compile(r"```(?:json)?\s*\n(.*?)```", re.DOTALL)
_FINDING_BLOCK_RE = re.compile(r"\[(ad_\d+)\s*/\s*([a-z_]+)\]")
_ANALYSIS_HEADER_RE = re.compile(
r"^(?:Payment Method|Targeting|Creative|Campaign Structure) Analysis for ad_\d+:$"
)
def _extract_json(text: str) -> Dict[str, Any]:
"""Extract JSON from LLM response, handling markdown code blocks."""
text = text.strip()
m = JSON_BLOCK_RE.search(text)
if m:
text = m.group(1).strip()
elif text.startswith("```"):
lines = text.split("\n")
lines = [l for l in lines if not l.strip().startswith("```")]
text = "\n".join(lines).strip()
return json.loads(text)
def _compact_finding(text: str) -> str:
"""Compress one investigation finding block into a compact key-value line.
Strips analysis headers and section labels but preserves ALL data fields
(both signal and noise) so the agent must still reason about relevance.
"""
parts: List[str] = []
for line in text.strip().split("\n"):
stripped = line.strip()
if not stripped:
continue
if _ANALYSIS_HEADER_RE.match(stripped):
continue
if stripped in ("Key claims on page:", "Suspicious elements:"):
continue
if stripped.startswith("- "):
stripped = stripped[2:]
parts.append(stripped)
return " | ".join(parts)
def _build_compact_findings(raw: str, focused_ad: Optional[str]) -> str:
"""Parse findings blocks; full prose for focused ad, compact lines for others.
Each block in the raw findings string is delimited by [ad_XXX / target].
The focused ad keeps full investigation prose for deep reasoning.
Other ads are compressed to single-line key-value summaries that still
contain all extracted fields (payment type, IDs, template hashes,
fingerprints, domain ages, etc.) mixed with noise fields — the agent
must determine which values are meaningful for cross-ad comparison.
"""
blocks: List[tuple] = []
current_ad: Optional[str] = None
current_header: Optional[str] = None
current_lines: List[str] = []
for line in raw.split("\n"):
m = _FINDING_BLOCK_RE.match(line.strip())
if m:
if current_ad is not None:
blocks.append((current_ad, current_header, "\n".join(current_lines)))
current_ad = m.group(1)
current_header = line.strip()
current_lines = []
else:
current_lines.append(line)
if current_ad is not None:
blocks.append((current_ad, current_header, "\n".join(current_lines)))
result: List[str] = []
for ad_id, header, text in blocks:
if focused_ad and ad_id == focused_ad:
result.append(f"\n{header}\n{text}")
else:
compact = _compact_finding(text)
if compact:
result.append(f"{header} {compact}")
return "\n".join(result)
def build_obs_prompt(obs: Any) -> str:
"""Format an observation into the user prompt for the LLM.
The focused ad gets full investigation prose for deep reasoning.
Other investigated ads are compressed to compact key-value summaries
that preserve all fields (signal + noise) for cross-ad comparison.
"""
focused_ad: Optional[str] = None
if obs.current_ad_info:
m = re.search(r"Ad in Focus:\s*(ad_\d+)", obs.current_ad_info)
if m:
focused_ad = m.group(1)
parts = [
f"Queue: {obs.queue_summary}",
f"Current Ad: {obs.current_ad_info}",
f"Feedback: {obs.feedback}",
f"Available ads: {', '.join(obs.available_ads)}",
]
if obs.verdict_history_summary and obs.verdict_history_summary != "No verdicts yet.":
parts.append(f"Verdicts: {obs.verdict_history_summary}")
if obs.investigation_findings:
findings = _build_compact_findings(obs.investigation_findings, focused_ad)
if findings:
parts.append(f"Findings:\n{findings}")
return "\n\n".join(parts)
# ---------------------------------------------------------------------------
# Episode logger (markdown, for debugging — separate from mandatory stdout)
# ---------------------------------------------------------------------------
class EpisodeLogger:
"""Logs the full agent-environment conversation to a markdown file."""
def __init__(self, task_id: str, log_dir: Path) -> None:
self.task_id = task_id
self.lines: List[str] = []
log_dir.mkdir(parents=True, exist_ok=True)
self.path = log_dir / f"{task_id}_conversation.md"
self._md(f"# Episode Log — {task_id}\n")
def step_start(self, step: int, obs_prompt: str) -> None:
self._md(f"\n## Step {step}\n")
self._md(f"### Observation (sent to LLM)\n```\n{obs_prompt}\n```\n")
def llm_response(self, step: int, raw: str, action: AdReviewAction | None, fallback: bool) -> None:
tag = " [FALLBACK]" if fallback else ""
self._md(f"### LLM Response\n```json\n{raw.strip()}\n```\n")
if action:
act_dict = action.model_dump(exclude_none=True, exclude={"metadata"})
self._md(f"### Parsed Action{tag}\n```json\n{json.dumps(act_dict, indent=2)}\n```\n")
def env_feedback(self, step: int, reward: float, done: bool, feedback: str) -> None:
self._md(f"### Environment Response\n- **Reward:** `{reward:+.2f}`\n- **Done:** `{done}`\n")
self._md(f"- **Feedback:** {feedback}\n")
def episode_end(self, score: float, steps: int, verdicts: int, total: int) -> None:
summary = f"Score: {score:.3f} | Steps: {steps} | Verdicts: {verdicts}/{total}"
self._md(f"\n---\n## Result\n**{summary}**\n")
self._flush()
def _md(self, text: str) -> None:
self.lines.append(text)
def _flush(self) -> None:
with open(self.path, "w", encoding="utf-8") as f:
f.write("\n".join(self.lines))
# ---------------------------------------------------------------------------
# Core task runner
# ---------------------------------------------------------------------------
def run_single_task(
task_id: str,
seed: int = 42,
env_base_url: str = "https://QuantumTransformer-AdArena.hf.space",
) -> Dict[str, Any]:
"""Run the baseline agent on a single task with mandatory [START]/[STEP]/[END] logging."""
base_url = os.getenv("API_BASE_URL") or API_BASE_URL
api_key = os.getenv("HF_TOKEN") or os.getenv("API_KEY") or API_KEY
model = os.getenv("MODEL_NAME") or MODEL_NAME
client = OpenAI(base_url=base_url, api_key=api_key, timeout=60.0)
env = AdFraudEnv(base_url=env_base_url).sync()
elog = EpisodeLogger(task_id, LOG_DIR)
config = TASK_CONFIGS.get(task_id)
max_steps = config.action_budget if config else 25
rewards: List[float] = []
steps_taken = 0
score = 0.0
success = False
log_start(task=task_id, env=BENCHMARK, model=model)
try:
env.connect()
result = env.reset(seed=seed, task_id=task_id)
messages: List[Dict[str, str]] = [
{"role": "system", "content": SYSTEM_PROMPT},
]
while not result.done and steps_taken < max_steps:
obs = result.observation
user_prompt = build_obs_prompt(obs)
messages.append({"role": "user", "content": user_prompt})
elog.step_start(steps_taken, user_prompt)
try:
completion = client.chat.completions.create(
model=model,
messages=messages,
temperature=TEMPERATURE,
max_tokens=MAX_TOKENS,
stream=False,
)
response_text = completion.choices[0].message.content or "{}"
except Exception as exc:
logger.warning("Model request failed on step %d: %s", steps_taken, exc)
response_text = "{}"
messages.append({"role": "assistant", "content": response_text})
error_msg = None
fallback = False
try:
action_data = _extract_json(response_text)
action = AdReviewAction(**action_data)
except Exception as e:
logger.warning("Failed to parse action on step %d: %s", steps_taken, e)
fallback = True
error_msg = str(e)
if obs.available_ads:
action = AdReviewAction(
action_type="verdict",
ad_id=obs.available_ads[0],
verdict=FALLBACK_VERDICT,
confidence=0.3,
)
else:
elog.llm_response(steps_taken, response_text, None, True)
break
elog.llm_response(steps_taken, response_text, action, fallback)
result = env.step(action)
steps_taken += 1
reward = result.reward or 0.0
rewards.append(reward)
log_step(
step=steps_taken,
action=_format_action(action),
reward=reward,
done=result.done,
error=error_msg,
)
elog.env_feedback(steps_taken, reward, result.done, result.observation.feedback)
# Each observation is self-contained (all findings + verdict summary),
# so we only keep system prompt + last 2 exchanges to stay within
# context limits while preserving the agent's reasoning continuity.
if len(messages) > 6:
messages = messages[:1] + messages[-4:]
state = env.state()
score = state.grader_score if state.grader_score is not None else 0.0
score = max(0.0, min(1.0, score))
success = score > 0.0
elog.episode_end(score, steps_taken, state.reviewed_count, state.total_ads)
return {
"task_id": task_id,
"score": score,
"steps": steps_taken,
"verdicts": state.reviewed_count,
"total_ads": state.total_ads,
}
except Exception as e:
logger.error("Task %s failed: %s", task_id, e)
return {"task_id": task_id, "score": 0.0, "error": str(e)}
finally:
try:
env.close()
except Exception as e:
print(f"[DEBUG] env.close() error: {e}", flush=True)
log_end(success=success, steps=steps_taken, score=score, rewards=rewards)
def run_baseline(
env_base_url: str = "https://QuantumTransformer-AdArena.hf.space",
) -> Dict[str, Any]:
"""Run baseline inference on all 3 tasks."""
model = os.getenv("MODEL_NAME") or MODEL_NAME
results: Dict[str, Any] = {}
for task_id in ["task_1", "task_2", "task_3"]:
logger.info("Running baseline for %s...", task_id)
try:
task_result = run_single_task(
task_id, seed=42, env_base_url=env_base_url,
)
results[task_id] = task_result
logger.info(" %s score: %.3f", task_id, task_result["score"])
except Exception as e:
logger.error(" %s failed: %s", task_id, e)
results[task_id] = {"task_id": task_id, "score": 0.0, "error": str(e)}
return {"baseline_model": model, "seed": 42, "tasks": results}
def main() -> None:
logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s")
if not API_KEY:
print("Error: HF_TOKEN (or API_KEY) environment variable is required.", file=sys.stderr)
sys.exit(1)
env_base_url = os.getenv("AD_FRAUD_ENV_URL", "https://QuantumTransformer-AdArena.hf.space")
print(f"Running baseline inference against {env_base_url} with model {MODEL_NAME}...", file=sys.stderr)
scores = run_baseline(env_base_url=env_base_url)
output_path = Path(__file__).resolve().parent / "baseline_scores.json"
with open(output_path, "w") as f:
json.dump(scores, f, indent=2)
print(f"\nBaseline scores saved to {output_path}", file=sys.stderr)
print(json.dumps(scores, indent=2), file=sys.stderr)
if __name__ == "__main__":
main()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100"""
Data models for the Ad Fraud Investigation Environment.
Defines the Action, Observation, and State types used by the OpenEnv interface.
The agent interacts with a queue of ads, investigating them and rendering verdicts.
"""
from __future__ import annotations
from typing import Dict, List, Literal, Optional
from openenv.core.env_server.types import Action, Observation, State
from pydantic import Field
class AdReviewAction(Action):
"""
Action space for the ad fraud investigation agent.
Three action types:
- investigate: Spend budget to reveal information about an ad
- verdict: Approve, reject, or escalate an ad
- link_accounts: Flag two ads as part of the same fraud network
"""
action_type: Literal["investigate", "verdict", "link_accounts"]
ad_id: str = Field(..., description="Target ad identifier (e.g. 'ad_001')")
investigation_target: Optional[
Literal[
"advertiser_history",
"landing_page",
"payment_method",
"targeting_overlap",
"creative_similarity",
"campaign_structure",
]
] = Field(None, description="What to investigate (required for action_type='investigate')")
verdict: Optional[Literal["approve", "reject", "escalate"]] = Field(
None, description="Verdict decision (required for action_type='verdict')"
)
confidence: Optional[float] = Field(
None, ge=0.0, le=1.0, description="Agent's confidence in verdict (0.0-1.0)"
)
linked_ad_id: Optional[str] = Field(
None, description="Other ad in suspected fraud ring (required for action_type='link_accounts')"
)
link_reason: Optional[str] = Field(
None, description="Why the agent believes these ads are connected"
)
class AdReviewObservation(Observation):
"""
Observation returned after each step.
Text-heavy by design so LLM agents can reason about the content naturally.
Structured data is in queue_status for programmatic access.
"""
queue_summary: str = Field(
default="", description="Natural language overview of the ad queue"
)
current_ad_info: str = Field(
default="", description="Details of the ad currently in focus"
)
investigation_findings: str = Field(
default="", description="Accumulated investigation results"
)
verdict_history_summary: str = Field(
default="", description="Summary of verdicts rendered so far"
)
feedback: str = Field(
default="", description="Natural language feedback on the last action taken"
)
available_ads: List[str] = Field(
default_factory=list, description="Ad IDs still pending review"
)
queue_status: Dict = Field(
default_factory=dict,
description="Structured status: total_ads, reviewed, pending, budget, step",
)
class AdFraudState(State):
"""
Internal environment state exposed via the state() property.
Inherits episode_id and step_count from State.
Uses extra='allow' so custom fields are permitted.
"""
task_id: str = ""
total_ads: int = 0
reviewed_count: int = 0
remaining_budget: int = 0
verdicts: Dict = Field(default_factory=dict)
grader_score: Optional[float] = None1234567spec_version: 1
name: ad_fraud_env
type: space
sdk: docker
runtime: fastapi
app: server.app:app
port: 8000123456789101112131415161718Metadata-Version: 2.4
Name: openenv-ad-fraud-env
Version: 0.1.0
Summary: Ad Fraud Investigation Environment for OpenEnv — real-world ad fraud detection and investigation simulation
Requires-Python: >=3.11
Requires-Dist: openenv-core[core]>=0.2.2
Requires-Dist: fastapi>=0.115.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: uvicorn[standard]>=0.24.0
Requires-Dist: requests>=2.31.0
Requires-Dist: faker==33.1.0
Requires-Dist: networkx>=3.2
Requires-Dist: openai>=1.0.0
Requires-Dist: python-dotenv>=1.0.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"123456789101112131415161718192021222324252627282930313233README.md__init__.pyclient.pyinference.pymodels.pypyproject.toml./__init__.py./client.py./inference.py./models.pydata/__init__.pydata/ad_generator.pydata/advertiser_profiles.pydata/fraud_patterns.pydata/landing_pages.pydata/network_generator.pygraders/__init__.pygraders/base_grader.pygraders/task1_grader.pygraders/task2_grader.pygraders/task3_grader.pyopenenv_ad_fraud_env.egg-info/PKG-INFOopenenv_ad_fraud_env.egg-info/SOURCES.txtopenenv_ad_fraud_env.egg-info/dependency_links.txtopenenv_ad_fraud_env.egg-info/entry_points.txtopenenv_ad_fraud_env.egg-info/requires.txtopenenv_ad_fraud_env.egg-info/top_level.txtserver/__init__.pyserver/app.pyserver/environment.pytests/test_data_generation.pytests/test_environment.pytests/test_graders.py1
12[console_scripts]server = ad_fraud_env.server.app:main1234567891011121314openenv-core[core]>=0.2.2fastapi>=0.115.0pydantic>=2.0.0uvicorn[standard]>=0.24.0requests>=2.31.0faker==33.1.0networkx>=3.2openai>=1.0.0python-dotenv>=1.0.0
[dev]pytest>=8.0.0pytest-cov>=4.0.0pytest-asyncio>=0.23.01ad_fraud_env123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840# Episode Log — task_1
## Step 0
### Observation (sent to LLM)
```
Queue: Task: Basic Ad Triage (easy)
Total ads: 5 | Reviewed: 0 | Pending: 5 | Budget remaining: 25 actions | Step: 0
Current Ad: === Ad in Focus: ad_001 ===
Category: local_service
Ad copy: "Award-winning pizza delivery in Brooklyn. Family recipes since 1985. Order from Sal's Pizzeria."
Targeting: Adults 18-55, Brooklyn, interests: food delivery
Initial risk signals: None
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Episode started. Review the ad queue and begin your investigation.
Available ads: ad_001, ad_002, ad_003, ad_004, ad_005
```
### LLM Response
```json
{
"action_type": "investigate",
"ad_id": "ad_001",
"investigation_target": "landing_page"
}
```
### Parsed Action
```json
{
"action_type": "investigate",
"ad_id": "ad_001",
"investigation_target": "landing_page"
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Investigation complete: landing_page for ad_001.
--- Findings ---
Domain: nutri.com
Domain age: 1672 days
SSL: Valid SSL certificate
Registrar: Cloudflare Registrar
Redirect chain: No redirects (direct)
Similarity to known scam templates: 5%
Key claims on page:
- Licensed and insured
- Established since 2010
- BBB accredited
Suspicious elements:
None detected
Content summary: E-commerce store with detailed product descriptions, customer reviews, FAQ section, and accessible support.
## Step 1
### Observation (sent to LLM)
```
Queue: Task: Basic Ad Triage (easy)
Total ads: 5 | Reviewed: 0 | Pending: 5 | Budget remaining: 24 actions | Step: 1
Current Ad: === Ad in Focus: ad_001 ===
Category: local_service
Ad copy: "Award-winning pizza delivery in Brooklyn. Family recipes since 1985. Order from Sal's Pizzeria."
Targeting: Adults 18-55, Brooklyn, interests: food delivery
Initial risk signals: None
Investigations completed: landing_page
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Investigation complete: landing_page for ad_001.
--- Findings ---
Domain: nutri.com
Domain age: 1672 days
SSL: Valid SSL certificate
Registrar: Cloudflare Registrar
Redirect chain: No redirects (direct)
Similarity to known scam templates: 5%
Key claims on page:
- Licensed and insured
- Established since 2010
- BBB accredited
Suspicious elements:
None detected
Content summary: E-commerce store with detailed product descriptions, customer reviews, FAQ section, and accessible support.
Available ads: ad_001, ad_002, ad_003, ad_004, ad_005
Findings:
[ad_001 / landing_page]
Domain: nutri.com
Domain age: 1672 days
SSL: Valid SSL certificate
Registrar: Cloudflare Registrar
Redirect chain: No redirects (direct)
Similarity to known scam templates: 5%
Key claims on page:
- Licensed and insured
- Established since 2010
- BBB accredited
Suspicious elements:
None detected
Content summary: E-commerce store with detailed product descrip
```
### LLM Response
```json
{
"action_type": "verdict",
"ad_id": "ad_001",
"verdict": "approve",
"confidence": 0.9
}
```
### Parsed Action
```json
{
"action_type": "verdict",
"ad_id": "ad_001",
"verdict": "approve",
"confidence": 0.9
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_001: approve (confidence: 0.90). Correct decision. Reward: +0.10
## Step 2
### Observation (sent to LLM)
```
Queue: Task: Basic Ad Triage (easy)
Total ads: 5 | Reviewed: 1 | Pending: 4 | Budget remaining: 24 actions | Step: 2
Current Ad: === Ad in Focus: ad_002 ===
Category: counterfeit_goods
Ad copy: "Rolex watches starting at $49.99! 100% genuine! Free worldwide shipping! LuxWatchDeals.net"
Targeting: Men 25-55, interests: watches, luxury
Initial risk signals: impossibly low prices for luxury goods, unfamiliar domain, claims of authenticity with extreme discounts
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_001: approve (confidence: 0.90). Correct decision. Reward: +0.10
Available ads: ad_002, ad_003, ad_004, ad_005
Verdicts: ad_001: approve (confidence: 0.90)
Findings:
[ad_001 / landing_page]
Domain: nutri.com
Domain age: 1672 days
SSL: Valid SSL certificate
Registrar: Cloudflare Registrar
Redirect chain: No redirects (direct)
Similarity to known scam templates: 5%
Key claims on page:
- Licensed and insured
- Established since 2010
- BBB accredited
Suspicious elements:
None detected
Content summary: E-commerce store with detailed product descriptions, customer reviews, FAQ section, and accessible support.
```
### LLM Response
```json
{
"action_type": "investigate",
"ad_id": "ad_002",
"investigation_target": "landing_page"
}
```
### Parsed Action
```json
{
"action_type": "investigate",
"ad_id": "ad_002",
"investigation_target": "landing_page"
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Investigation complete: landing_page for ad_002.
--- Findings ---
Domain: store4751.site
Domain age: 6 days
SSL: NO SSL / expired certificate
Registrar: NameSilo
Redirect chain: store4751.site -> redirect651..top -> redirect167..top -> redirect364..click -> redirect687..top -> final-719..site
Similarity to known scam templates: 67%
Key claims on page:
- Authentic products
- Direct from manufacturer
- 90% below retail price
Suspicious elements:
- Privacy policy copied from template
- Terms of service link returns 404
- No physical address listed
- Price comparison shows 90%+ discount vs retail
- No contact phone number
Content summary: Product catalog showing luxury branded items at extreme discounts. Stock photos. Payment accepted via wire transfer and crypto only.
## Step 3
### Observation (sent to LLM)
```
Queue: Task: Basic Ad Triage (easy)
Total ads: 5 | Reviewed: 1 | Pending: 4 | Budget remaining: 23 actions | Step: 3
Current Ad: === Ad in Focus: ad_002 ===
Category: counterfeit_goods
Ad copy: "Rolex watches starting at $49.99! 100% genuine! Free worldwide shipping! LuxWatchDeals.net"
Targeting: Men 25-55, interests: watches, luxury
Initial risk signals: impossibly low prices for luxury goods, unfamiliar domain, claims of authenticity with extreme discounts
Investigations completed: landing_page
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Investigation complete: landing_page for ad_002.
--- Findings ---
Domain: store4751.site
Domain age: 6 days
SSL: NO SSL / expired certificate
Registrar: NameSilo
Redirect chain: store4751.site -> redirect651..top -> redirect167..top -> redirect364..click -> redirect687..top -> final-719..site
Similarity to known scam templates: 67%
Key claims on page:
- Authentic products
- Direct from manufacturer
- 90% below retail price
Suspicious elements:
- Privacy policy copied from template
- Terms of service link returns 404
- No physical address listed
- Price comparison shows 90%+ disco... [truncated]
Available ads: ad_002, ad_003, ad_004, ad_005
Verdicts: ad_001: approve (confidence: 0.90)
Findings:
[ad_001 / landing_page]
Domain: nutri.com
Domain age: 1672 days
SSL: Valid SSL certificate
Registrar: Cloudflare Registrar
Redirect chain: No
```
### LLM Response
```json
{
"action_type": "verdict",
"ad_id": "ad_002",
"verdict": "reject",
"confidence": 0.95
}
```
### Parsed Action
```json
{
"action_type": "verdict",
"ad_id": "ad_002",
"verdict": "reject",
"confidence": 0.95
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_002: reject (confidence: 0.95). Correct decision. Reward: +0.38
## Step 4
### Observation (sent to LLM)
```
Queue: Task: Basic Ad Triage (easy)
Total ads: 5 | Reviewed: 2 | Pending: 3 | Budget remaining: 23 actions | Step: 4
Current Ad: === Ad in Focus: ad_003 ===
Category: fake_giveaway
Ad copy: "EXCLUSIVE: Win a Tesla Model 3! Enter your email NOW! Drawing ends tonight!!!"
Targeting: Adults 18-55, interests: cars, Tesla, electric vehicles
Initial risk signals: excessive urgency language, too-good-to-be-true offer, excessive punctuation/caps, no purchase necessary claims
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_002: reject (confidence: 0.95). Correct decision. Reward: +0.38
Available ads: ad_003, ad_004, ad_005
Verdicts: ad_001: approve (confidence: 0.90)
ad_002: reject (confidence: 0.95)
Findings:
[ad_001 / landing_page]
Domain: nutri.com
Domain age: 1672 days
SSL: Valid SSL certificate
Registrar: Cloudflare Registrar
Redirect chain: No redirects (direct)
Similarity to known scam templates: 5%
Key claims on page:
- Licensed and insured
- Established since 2010
- BBB accredited
Suspicious elements:
None detected
Content summary: E-commerce store with detailed product descriptions, customer reviews, FAQ section, and accessible support.
[ad_002 / landing_page]
Domain: store4751.site
Domain age: 6 days
SSL: NO SSL / expired certificate
Registrar: NameSilo
Redirect chain: store4751.... [truncated]
```
### LLM Response
```json
{
"action_type": "investigate",
"ad_id": "ad_003",
"investigation_target": "landing_page"
}
```
### Parsed Action
```json
{
"action_type": "investigate",
"ad_id": "ad_003",
"investigation_target": "landing_page"
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Investigation complete: landing_page for ad_003.
--- Findings ---
Domain: get8189.store
Domain age: 26 days
SSL: NO SSL / expired certificate
Registrar: Tucows (privacy proxy)
Redirect chain: get8189.store -> redirect253..xyz -> redirect575..xyz -> final-270..store
Similarity to known scam templates: 56%
Key claims on page:
- 100% free, no purchase necessary
- Guaranteed winner
- Act now — expires in 2 hours
Suspicious elements:
- No contact phone number
- Requests personal info before any value provided
- No physical address listed
- Privacy policy copied from template
- Terms of service link returns 404
Content summary: Landing page features a large countdown timer and a form requesting name, email, phone, and address. No clear sponsor or rules disclosure.
## Step 5
### Observation (sent to LLM)
```
Queue: Task: Basic Ad Triage (easy)
Total ads: 5 | Reviewed: 2 | Pending: 3 | Budget remaining: 22 actions | Step: 5
Current Ad: === Ad in Focus: ad_003 ===
Category: fake_giveaway
Ad copy: "EXCLUSIVE: Win a Tesla Model 3! Enter your email NOW! Drawing ends tonight!!!"
Targeting: Adults 18-55, interests: cars, Tesla, electric vehicles
Initial risk signals: excessive urgency language, too-good-to-be-true offer, excessive punctuation/caps, no purchase necessary claims
Investigations completed: landing_page
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Investigation complete: landing_page for ad_003.
--- Findings ---
Domain: get8189.store
Domain age: 26 days
SSL: NO SSL / expired certificate
Registrar: Tucows (privacy proxy)
Redirect chain: get8189.store -> redirect253..xyz -> redirect575..xyz -> final-270..store
Similarity to known scam templates: 56%
Key claims on page:
- 100% free, no purchase necessary
- Guaranteed winner
- Act now — expires in 2 hours
Suspicious elements:
- No contact phone number
- Requests personal info before any value provided
- No physical address listed
- Privacy policy copied from template
- Terms... [truncated]
Available ads: ad_003, ad_004, ad_005
Verdicts: ad_001: approve (confidence: 0.90)
ad_002: reject (confidence: 0.95)
Findings:
[ad_001 / landing_page]
Domain: nutri.com
Domain age: 1672 days
SSL: Valid SSL certificate
Registrar: Clou
```
### LLM Response
```json
{
"action_type": "verdict",
"ad_id": "ad_003",
"verdict": "reject",
"confidence": 0.98
}
```
### Parsed Action
```json
{
"action_type": "verdict",
"ad_id": "ad_003",
"verdict": "reject",
"confidence": 0.98
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_003: reject (confidence: 0.98). Correct decision. Reward: +0.39
## Step 6
### Observation (sent to LLM)
```
Queue: Task: Basic Ad Triage (easy)
Total ads: 5 | Reviewed: 3 | Pending: 2 | Budget remaining: 22 actions | Step: 6
Current Ad: === Ad in Focus: ad_004 ===
Category: ecommerce
Ad copy: "Spring Sale — Up to 30% off home essentials. Free shipping on orders over $50. Shop now at HomeNest."
Targeting: Women 25-54, interests: home decor, shopping
Initial risk signals: None
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_003: reject (confidence: 0.98). Correct decision. Reward: +0.39
Available ads: ad_004, ad_005
Verdicts: ad_001: approve (confidence: 0.90)
ad_002: reject (confidence: 0.95)
ad_003: reject (confidence: 0.98)
Findings:
[ad_001 / landing_page]
Domain: nutri.com
Domain age: 1672 days
SSL: Valid SSL certificate
Registrar: Cloudflare Registrar
Redirect chain: No redirects (direct)
Similarity to known scam templates: 5%
Key claims on page:
- Licensed and insured
- Established since 2010
- BBB accredited
Suspicious elements:
None detected
Content summary: E-commerce store with detailed product descriptions, customer reviews, FAQ section, and accessible support.
[ad_002 / landing_page]
Domain: store4751.site
Domain age: 6 days
SSL: NO SSL / expired certificate
Registrar: NameSilo
Redirect chain: store4751.... [truncated]
```
### LLM Response
```json
{
"action_type": "investigate",
"ad_id": "ad_004",
"investigation_target": "landing_page"
}
```
### Parsed Action
```json
{
"action_type": "investigate",
"ad_id": "ad_004",
"investigation_target": "landing_page"
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Investigation complete: landing_page for ad_004.
--- Findings ---
Domain: sparkle.io
Domain age: 2424 days
SSL: Valid SSL certificate
Registrar: AWS Route 53
Redirect chain: No redirects (direct)
Similarity to known scam templates: 13%
Key claims on page:
- 4.5-star average customer rating
- 14-day free trial
Suspicious elements:
None detected
Content summary: E-commerce store with detailed product descriptions, customer reviews, FAQ section, and accessible support.
## Step 7
### Observation (sent to LLM)
```
Queue: Task: Basic Ad Triage (easy)
Total ads: 5 | Reviewed: 3 | Pending: 2 | Budget remaining: 21 actions | Step: 7
Current Ad: === Ad in Focus: ad_004 ===
Category: ecommerce
Ad copy: "Spring Sale — Up to 30% off home essentials. Free shipping on orders over $50. Shop now at HomeNest."
Targeting: Women 25-54, interests: home decor, shopping
Initial risk signals: None
Investigations completed: landing_page
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Investigation complete: landing_page for ad_004.
--- Findings ---
Domain: sparkle.io
Domain age: 2424 days
SSL: Valid SSL certificate
Registrar: AWS Route 53
Redirect chain: No redirects (direct)
Similarity to known scam templates: 13%
Key claims on page:
- 4.5-star average customer rating
- 14-day free trial
Suspicious elements:
None detected
Content summary: E-commerce store with detailed product descriptions, customer reviews, FAQ section, and accessible support.
Available ads: ad_004, ad_005
Verdicts: ad_001: approve (confidence: 0.90)
ad_002: reject (confidence: 0.95)
ad_003: reject (confidence: 0.98)
Findings:
[ad_001 / landing_page]
Domain: nutri.com
Domain age: 1672 days
SSL: Valid SSL certificate
Registrar: Cloudflare Registrar
Redirect chain: No redirects (direct)
Similarity to known scam templates: 5%
Key claims on page:
- Licensed and insured
- Established since 2010
- BBB accredited
Suspicious elements:
No
```
### LLM Response
```json
{
"action_type": "verdict",
"ad_id": "ad_004",
"verdict": "approve",
"confidence": 0.92
}
```
### Parsed Action
```json
{
"action_type": "verdict",
"ad_id": "ad_004",
"verdict": "approve",
"confidence": 0.92
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_004: approve (confidence: 0.92). Correct decision. Reward: +0.10
## Step 8
### Observation (sent to LLM)
```
Queue: Task: Basic Ad Triage (easy)
Total ads: 5 | Reviewed: 4 | Pending: 1 | Budget remaining: 21 actions | Step: 8
Current Ad: === Ad in Focus: ad_005 ===
Category: fake_giveaway
Ad copy: "EXCLUSIVE: Win a Tesla Model 3! Enter your email NOW! Drawing ends tonight!!!"
Targeting: Adults 18-55, interests: cars, Tesla, electric vehicles
Initial risk signals: excessive urgency language, too-good-to-be-true offer, excessive punctuation/caps, no purchase necessary claims
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_004: approve (confidence: 0.92). Correct decision. Reward: +0.10
Available ads: ad_005
Verdicts: ad_001: approve (confidence: 0.90)
ad_002: reject (confidence: 0.95)
ad_003: reject (confidence: 0.98)
ad_004: approve (confidence: 0.92)
Findings:
[ad_001 / landing_page]
Domain: nutri.com
Domain age: 1672 days
SSL: Valid SSL certificate
Registrar: Cloudflare Registrar
Redirect chain: No redirects (direct)
Similarity to known scam templates: 5%
Key claims on page:
- Licensed and insured
- Established since 2010
- BBB accredited
Suspicious elements:
None detected
Content summary: E-commerce store with detailed product descriptions, customer reviews, FAQ section, and accessible support.
[ad_002 / landing_page]
Domain: store4751.site
Domain age: 6 days
SSL: NO SSL / expired certificate
Registrar: NameSilo
Redire
```
### LLM Response
```json
{
"action_type": "investigate",
"ad_id": "ad_005",
"investigation_target": "landing_page"
}
```
### Parsed Action
```json
{
"action_type": "investigate",
"ad_id": "ad_005",
"investigation_target": "landing_page"
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Investigation complete: landing_page for ad_005.
--- Findings ---
Domain: pro3268.top
Domain age: 10 days
SSL: Valid SSL certificate
Registrar: Epik
Redirect chain: pro3268.top -> redirect614..top -> final-501..site
Similarity to known scam templates: 74%
Key claims on page:
- 100% free, no purchase necessary
- Guaranteed winner
- Act now — expires in 2 hours
Suspicious elements:
- No contact phone number
- Terms of service link returns 404
- Requests personal info before any value provided
Content summary: Landing page features a large countdown timer and a form requesting name, email, phone, and address. No clear sponsor or rules disclosure.
## Step 9
### Observation (sent to LLM)
```
Queue: Task: Basic Ad Triage (easy)
Total ads: 5 | Reviewed: 4 | Pending: 1 | Budget remaining: 20 actions | Step: 9
Current Ad: === Ad in Focus: ad_005 ===
Category: fake_giveaway
Ad copy: "EXCLUSIVE: Win a Tesla Model 3! Enter your email NOW! Drawing ends tonight!!!"
Targeting: Adults 18-55, interests: cars, Tesla, electric vehicles
Initial risk signals: excessive urgency language, too-good-to-be-true offer, excessive punctuation/caps, no purchase necessary claims
Investigations completed: landing_page
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Investigation complete: landing_page for ad_005.
--- Findings ---
Domain: pro3268.top
Domain age: 10 days
SSL: Valid SSL certificate
Registrar: Epik
Redirect chain: pro3268.top -> redirect614..top -> final-501..site
Similarity to known scam templates: 74%
Key claims on page:
- 100% free, no purchase necessary
- Guaranteed winner
- Act now — expires in 2 hours
Suspicious elements:
- No contact phone number
- Terms of service link returns 404
- Requests personal info before any value provided
Content summary: Landing page features a large countdown timer and a form requesting name, e... [truncated]
Available ads: ad_005
Verdicts: ad_001: approve (confidence: 0.90)
ad_002: reject (confidence: 0.95)
ad_003: reject (confidence: 0.98)
ad_004: approve (confidence: 0.92)
Findings:
[ad_001 / landing_page]
Domain: nutri.com
Domain
```
### LLM Response
```json
{
"action_type": "verdict",
"ad_id": "ad_005",
"verdict": "reject",
"confidence": 0.99
}
```
### Parsed Action
```json
{
"action_type": "verdict",
"ad_id": "ad_005",
"verdict": "reject",
"confidence": 0.99
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Episode complete. Grader score: 0.931/1.000
Verdicts rendered: 5/5
Auto-approved (unreviewed): 0 fraud ad(s) missed
Correct decisions: 5/5
## Step 10
### Observation (sent to LLM)
```
Queue: Task: Basic Ad Triage (easy)
Total ads: 5 | Reviewed: 5 | Pending: 0 | Budget remaining: 20 actions | Step: 10
Current Ad:
Feedback: Episode complete. Grader score: 0.931/1.000
Verdicts rendered: 5/5
Auto-approved (unreviewed): 0 fraud ad(s) missed
Correct decisions: 5/5
Available ads:
Verdicts: ad_001: approve (confidence: 0.90)
ad_002: reject (confidence: 0.95)
ad_003: reject (confidence: 0.98)
ad_004: approve (confidence: 0.92)
ad_005: reject (confidence: 0.99)
Findings:
[ad_001 / landing_page]
Domain: nutri.com
Domain age: 1672 days
SSL: Valid SSL certificate
Registrar: Cloudflare Registrar
Redirect chain: No redirects (direct)
Similarity to known scam templates: 5%
Key claims on page:
- Licensed and insured
- Established since 2010
- BBB accredited
Suspicious elements:
None detected
Content summary: E-commerce store with detailed product descriptions, customer reviews, FAQ section, and accessible support.
[ad_002 / landing_page]
Domain: store4751.site
Domain age: 6 days
SSL: NO SSL / expired certificate
Registrar: NameSilo
Redirect chain: store4751.... [truncated]
```
### LLM Response
```json
{}
```
---
## Result
**Score: 0.931 | Steps: 10 | Verdicts: 5/5**123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251# Episode Log — task_2
## Step 0
### Observation (sent to LLM)
```
Queue: Task: Sophisticated Fraud Under Budget Pressure (medium)
Total ads: 12 | Reviewed: 0 | Pending: 12 | Budget remaining: 30 actions | Step: 0
Current Ad: === Ad in Focus: ad_001 ===
Category: local_service
Ad copy: "Award-winning pizza delivery in Brooklyn. Family recipes since 1985. Order from Sal's Pizzeria."
Targeting: Adults 18-55, Brooklyn, interests: food delivery
Initial risk signals: None
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Episode started. Review the ad queue and begin your investigation.
Available ads: ad_001, ad_002, ad_003, ad_004, ad_005, ad_006, ad_007, ad_008, ad_009, ad_010, ad_011, ad_012
```
### LLM Response
```json
{
"action_type": "investigate",
"ad_id": "ad_001",
"investigation_target": "advertiser_history"
}
```
### Parsed Action
```json
{
"action_type": "investigate",
"ad_id": "ad_001",
"investigation_target": "advertiser_history"
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Investigation complete: advertiser_history for ad_001.
--- Findings ---
Advertiser: FitVisit (Verified Business)
Account age: 1558 days
Country: Canada
Total historical spend: $55,594.09
Ads submitted in last 30 days: 13
Historical approval rate: 91%
Payment method: credit_card (ID: pmt_865179)
## Step 1
### Observation (sent to LLM)
```
Queue: Task: Sophisticated Fraud Under Budget Pressure (medium)
Total ads: 12 | Reviewed: 0 | Pending: 12 | Budget remaining: 29 actions | Step: 1
Current Ad: === Ad in Focus: ad_001 ===
Category: local_service
Ad copy: "Award-winning pizza delivery in Brooklyn. Family recipes since 1985. Order from Sal's Pizzeria."
Targeting: Adults 18-55, Brooklyn, interests: food delivery
Initial risk signals: None
Investigations completed: advertiser_history
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Investigation complete: advertiser_history for ad_001.
--- Findings ---
Advertiser: FitVisit (Verified Business)
Account age: 1558 days
Country: Canada
Total historical spend: $55,594.09
Ads submitted in last 30 days: 13
Historical approval rate: 91%
Payment method: credit_card (ID: pmt_865179)
Available ads: ad_001, ad_002, ad_003, ad_004, ad_005, ad_006, ad_007, ad_008, ad_009, ad_010, ad_011, ad_012
Findings:
[ad_001 / advertiser_history]
Advertiser: FitVisit (Verified Business)
Account age: 1558 days
Country: Canada
Total historical spend: $55,594.09
Ads submitted in last 30 days: 13
Historical approval rate: 91%
Payment method: credit_card (ID: pmt_865179)
```
### LLM Response
```json
{
"action_type": "investigate",
"ad_id": "ad_001",
"investigation_target": "payment_method"
}
```
### Parsed Action
```json
{
"action_type": "investigate",
"ad_id": "ad_001",
"investigation_target": "payment_method"
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Investigation complete: payment_method for ad_001.
--- Findings ---
Payment Method Analysis for ad_001:
Method type: credit_card
Payment ID: pmt_865179
No other accounts in the current queue share this payment method.
## Step 2
### Observation (sent to LLM)
```
Queue: Task: Sophisticated Fraud Under Budget Pressure (medium)
Total ads: 12 | Reviewed: 0 | Pending: 12 | Budget remaining: 28 actions | Step: 2
Current Ad: === Ad in Focus: ad_001 ===
Category: local_service
Ad copy: "Award-winning pizza delivery in Brooklyn. Family recipes since 1985. Order from Sal's Pizzeria."
Targeting: Adults 18-55, Brooklyn, interests: food delivery
Initial risk signals: None
Investigations completed: advertiser_history, payment_method
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Investigation complete: payment_method for ad_001.
--- Findings ---
Payment Method Analysis for ad_001:
Method type: credit_card
Payment ID: pmt_865179
No other accounts in the current queue share this payment method.
Available ads: ad_001, ad_002, ad_003, ad_004, ad_005, ad_006, ad_007, ad_008, ad_009, ad_010, ad_011, ad_012
Findings:
[ad_001 / advertiser_history]
Advertiser: FitVisit (Verified Business)
Account age: 1558 days
Country: Canada
Total historical spend: $55,594.09
Ads submitted in last 30 days: 13
Historical approval rate: 91%
Payment method: credit_card (ID: pmt_865179)
[ad_001 / payment_method]
Payment Method Analysis for ad_001:
Method type: credit_card
Payment ID: pmt_865179
No other accounts in the current queue share this payment method.
```
### LLM Response
```json
{
"action_type": "verdict",
"ad_id": "ad_001",
"verdict": "approve",
"confidence": 0.9
}
```
### Parsed Action
```json
{
"action_type": "verdict",
"ad_id": "ad_001",
"verdict": "approve",
"confidence": 0.9
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_001: approve (confidence: 0.90). Correct decision. Reward: +0.10
## Step 3
### Observation (sent to LLM)
```
Queue: Task: Sophisticated Fraud Under Budget Pressure (medium)
Total ads: 12 | Reviewed: 1 | Pending: 11 | Budget remaining: 28 actions | Step: 3
Current Ad: === Ad in Focus: ad_002 ===
Category: fake_giveaway
Ad copy: "CONGRATULATIONS!! You've been selected to win a FREE iPhone 16 Pro!! Click NOW before offer expires!!!"
Targeting: All adults 18+, broad targeting, worldwide
Initial risk signals: excessive urgency language, too-good-to-be-true offer, excessive punctuation/caps, no purchase necessary claims
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_001: approve (confidence: 0.90). Correct decision. Reward: +0.10
Available ads: ad_002, ad_003, ad_004, ad_005, ad_006, ad_007, ad_008, ad_009, ad_010, ad_011, ad_012
Verdicts: ad_001: approve (confidence: 0.90)
Findings:
[ad_001 / advertiser_history]
Advertiser: FitVisit (Verified Business)
Account age: 1558 days
Country: Canada
Total historical spend: $55,594.09
Ads submitted in last 30 days: 13
Historical approval rate: 91%
Payment method: credit_card (ID: pmt_865179)
[ad_001 / payment_method]
Payment Method Analysis for ad_001:
Method type: credit_card
Payment ID: pmt_865179
No other accounts in the current queue share this payment method.
```
### LLM Response
```json
{
"action_type": "investigate",
"ad_id": "ad_002",
"investigation_target": "landing_page"
}
```
### Parsed Action
```json
{
"action_type": "investigate",
"ad_id": "ad_002",
"investigation_target": "landing_page"
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Investigation complete: landing_page for ad_002.
--- Findings ---
Domain: shop4020.top
Domain age: 11 days
SSL: NO SSL / expired certificate
Registrar: Njalla (privacy)
Redirect chain: shop4020.top -> redirect702..top -> redirect864..click -> final-235..site
Similarity to known scam templates: 95%
Key claims on page:
- 100% free, no purchase necessary
- Guaranteed winner
- Act now — expires in 2 hours
Suspicious elements:
- No contact phone number
- Countdown timer with fake urgency
- No physical address listed
- Requests personal info before any value provided
Content summary: Landing page features a large countdown timer and a form requesting name, email, phone, and address. No clear sponsor or rules disclosure.
## Step 4
### Observation (sent to LLM)
```
Queue: Task: Sophisticated Fraud Under Budget Pressure (medium)
Total ads: 12 | Reviewed: 1 | Pending: 11 | Budget remaining: 27 actions | Step: 4
Current Ad: === Ad in Focus: ad_002 ===
Category: fake_giveaway
Ad copy: "CONGRATULATIONS!! You've been selected to win a FREE iPhone 16 Pro!! Click NOW before offer expires!!!"
Targeting: All adults 18+, broad targeting, worldwide
Initial risk signals: excessive urgency language, too-good-to-be-true offer, excessive punctuation/caps, no purchase necessary claims
Investigations completed: landing_page
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Investigation complete: landing_page for ad_002.
--- Findings ---
Domain: shop4020.top
Domain age: 11 days
SSL: NO SSL / expired certificate
Registrar: Njalla (privacy)
Redirect chain: shop4020.top -> redirect702..top -> redirect864..click -> final-235..site
Similarity to known scam templates: 95%
Key claims on page:
- 100% free, no purchase necessary
- Guaranteed winner
- Act now — expires in 2 hours
Suspicious elements:
- No contact phone number
- Countdown timer with fake urgency
- No physical address listed
- Requests personal info before any value provided
Content summary: L... [truncated]
Available ads: ad_002, ad_003, ad_004, ad_005, ad_006, ad_007, ad_008, ad_009, ad_010, ad_011, ad_012
Verdicts: ad_001: approve (confidence: 0.90)
Findings:
[ad_001 / advertiser_history]
Advert
```
### LLM Response
```json
{
"action_type": "verdict",
"ad_id": "ad_002",
"verdict": "reject",
"confidence": 0.95
}
```
### Parsed Action
```json
{
"action_type": "verdict",
"ad_id": "ad_002",
"verdict": "reject",
"confidence": 0.95
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_002: reject (confidence: 0.95). Correct decision. Reward: +0.39
## Step 5
### Observation (sent to LLM)
```
Queue: Task: Sophisticated Fraud Under Budget Pressure (medium)
Total ads: 12 | Reviewed: 2 | Pending: 10 | Budget remaining: 27 actions | Step: 5
Current Ad: === Ad in Focus: ad_003 ===
Category: fake_crypto
Ad copy: "Web3 real estate tokenization. Own fractions of premium properties. Starting at $100. Licensed broker-dealer. PropChain.io"
Targeting: Adults 30-55, interests: real estate, investing, crypto
Initial risk signals: high guaranteed returns, complex financial product
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_002: reject (confidence: 0.95). Correct decision. Reward: +0.39
Available ads: ad_003, ad_004, ad_005, ad_006, ad_007, ad_008, ad_009, ad_010, ad_011, ad_012
Verdicts: ad_001: approve (confidence: 0.90)
ad_002: reject (confidence: 0.95)
Findings:
[ad_001 / advertiser_history]
Advertiser: FitVisit (Verified Business)
Account age: 1558 days
Country: Canada
Total historical spend: $55,594.09
Ads submitted in last 30 days: 13
Historical approval rate: 91%
Payment method: credit_card (ID: pmt_865179)
[ad_001 / payment_method]
Payment Method Analysis for ad_001:
Method type: credit_card
Payment ID: pmt_865179
No other accounts in the current queue share this payment method.
[ad_002 / landing_page]
Domain: shop4020.top
Domain age: 11 days
SSL: NO SSL / expired certificate
Registrar: Njalla (privacy)
Redir
```
### LLM Response
```json
{
"action_type": "investigate",
"ad_id": "ad_003",
"investigation_target": "landing_page"
}
```
### Parsed Action
```json
{
"action_type": "investigate",
"ad_id": "ad_003",
"investigation_target": "landing_page"
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Investigation complete: landing_page for ad_003.
--- Findings ---
Domain: best3603.xyz
Domain age: 9 days
SSL: NO SSL / expired certificate
Registrar: NameSilo
Redirect chain: best3603.xyz -> redirect157..xyz -> final-164..store
Similarity to known scam templates: 84%
Key claims on page:
- 12-15% monthly returns guaranteed
- Audited by top security firms
- Risk-free investment
Suspicious elements:
- Team photos are stock images
- Privacy policy copied from template
- No contact phone number
- Terms of service link returns 404
Content summary: Professional-looking platform with dashboard screenshots. Whitepaper link leads to a generic PDF. Team bios use stock photos.
## Step 6
### Observation (sent to LLM)
```
Queue: Task: Sophisticated Fraud Under Budget Pressure (medium)
Total ads: 12 | Reviewed: 2 | Pending: 10 | Budget remaining: 26 actions | Step: 6
Current Ad: === Ad in Focus: ad_003 ===
Category: fake_crypto
Ad copy: "Web3 real estate tokenization. Own fractions of premium properties. Starting at $100. Licensed broker-dealer. PropChain.io"
Targeting: Adults 30-55, interests: real estate, investing, crypto
Initial risk signals: high guaranteed returns, complex financial product
Investigations completed: landing_page
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Investigation complete: landing_page for ad_003.
--- Findings ---
Domain: best3603.xyz
Domain age: 9 days
SSL: NO SSL / expired certificate
Registrar: NameSilo
Redirect chain: best3603.xyz -> redirect157..xyz -> final-164..store
Similarity to known scam templates: 84%
Key claims on page:
- 12-15% monthly returns guaranteed
- Audited by top security firms
- Risk-free investment
Suspicious elements:
- Team photos are stock images
- Privacy policy copied from template
- No contact phone number
- Terms of service link returns 404
Content summary: Professional-looking platform with da... [truncated]
Available ads: ad_003, ad_004, ad_005, ad_006, ad_007, ad_008, ad_009, ad_010, ad_011, ad_012
Verdicts: ad_001: approve (confidence: 0.90)
ad_002: reject (confidence: 0.95)
Findings:
[ad_001 / advertiser_history]
Advertis
```
### LLM Response
```json
{
"action_type": "investigate",
"ad_id": "ad_003",
"investigation_target": "payment_method"
}
```
### Parsed Action
```json
{
"action_type": "investigate",
"ad_id": "ad_003",
"investigation_target": "payment_method"
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Investigation complete: payment_method for ad_003.
--- Findings ---
Payment Method Analysis for ad_003:
Method type: wire_transfer
Payment ID: pmt_711878
No other accounts in the current queue share this payment method.
Payment history: 1 chargebacks/disputes on record.
## Step 7
### Observation (sent to LLM)
```
Queue: Task: Sophisticated Fraud Under Budget Pressure (medium)
Total ads: 12 | Reviewed: 2 | Pending: 10 | Budget remaining: 25 actions | Step: 7
Current Ad: === Ad in Focus: ad_003 ===
Category: fake_crypto
Ad copy: "Web3 real estate tokenization. Own fractions of premium properties. Starting at $100. Licensed broker-dealer. PropChain.io"
Targeting: Adults 30-55, interests: real estate, investing, crypto
Initial risk signals: high guaranteed returns, complex financial product
Investigations completed: landing_page, payment_method
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Investigation complete: payment_method for ad_003.
--- Findings ---
Payment Method Analysis for ad_003:
Method type: wire_transfer
Payment ID: pmt_711878
No other accounts in the current queue share this payment method.
Payment history: 1 chargebacks/disputes on record.
Available ads: ad_003, ad_004, ad_005, ad_006, ad_007, ad_008, ad_009, ad_010, ad_011, ad_012
Verdicts: ad_001: approve (confidence: 0.90)
ad_002: reject (confidence: 0.95)
Findings:
[ad_001 / advertiser_history]
Advertiser: FitVisit (Verified Business)
Account age: 1558 days
Country: Canada
Total historical spend: $55,594.09
Ads submitted in last 30 days: 13
Historical approval rate: 91%
Payment method: credit_card (ID: pmt_865179)
[ad_001 / payment_method]
Payment Method Analysis for ad_001:
Method type: credit_card
Payment ID: p
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_003",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_003: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
## Step 8
### Observation (sent to LLM)
```
Queue: Task: Sophisticated Fraud Under Budget Pressure (medium)
Total ads: 12 | Reviewed: 3 | Pending: 9 | Budget remaining: 25 actions | Step: 8
Current Ad: === Ad in Focus: ad_004 ===
Category: gray_area_supplements
Ad copy: "SleepDeep Ultra — melatonin-free natural sleep aid. Non-habit forming. Money-back guarantee. PharmGrade Labs."
Targeting: Adults 30-65, interests: sleep, insomnia, wellness
Initial risk signals: supplement with strong efficacy claims, medical-sounding language
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_003: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
Available ads: ad_004, ad_005, ad_006, ad_007, ad_008, ad_009, ad_010, ad_011, ad_012
Verdicts: ad_001: approve (confidence: 0.90)
ad_002: reject (confidence: 0.95)
ad_003: escalate (confidence: 0.30)
Findings:
[ad_001 / advertiser_history]
Advertiser: FitVisit (Verified Business)
Account age: 1558 days
Country: Canada
Total historical spend: $55,594.09
Ads submitted in last 30 days: 13
Historical approval rate: 91%
Payment method: credit_card (ID: pmt_865179)
[ad_001 / payment_method]
Payment Method Analysis for ad_001:
Method type: credit_card
Payment ID: pmt_865179
No other accounts in the current queue share this payment method.
[ad_002 / landing_page]
Domain: shop4020.top
Domain age: 11 days
SSL: NO SSL / expired certi
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_004",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_004: escalate (confidence: 0.30). Correct decision. Reward: +0.15
## Step 9
### Observation (sent to LLM)
```
Queue: Task: Sophisticated Fraud Under Budget Pressure (medium)
Total ads: 12 | Reviewed: 4 | Pending: 8 | Budget remaining: 25 actions | Step: 9
Current Ad: === Ad in Focus: ad_005 ===
Category: gray_area_supplements
Ad copy: "TestoMax Elite — natural testosterone support for men over 40. Doctor-formulated. Published clinical trial results."
Targeting: Men 40-65, interests: men's health, testosterone, fitness
Initial risk signals: supplement with strong efficacy claims, medical-sounding language
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_004: escalate (confidence: 0.30). Correct decision. Reward: +0.15
Available ads: ad_005, ad_006, ad_007, ad_008, ad_009, ad_010, ad_011, ad_012
Verdicts: ad_001: approve (confidence: 0.90)
ad_002: reject (confidence: 0.95)
ad_003: escalate (confidence: 0.30)
ad_004: escalate (confidence: 0.30)
Findings:
[ad_001 / advertiser_history]
Advertiser: FitVisit (Verified Business)
Account age: 1558 days
Country: Canada
Total historical spend: $55,594.09
Ads submitted in last 30 days: 13
Historical approval rate: 91%
Payment method: credit_card (ID: pmt_865179)
[ad_001 / payment_method]
Payment Method Analysis for ad_001:
Method type: credit_card
Payment ID: pmt_865179
No other accounts in the current queue share this payment method.
[ad_002 / landing_page]
Domain: shop4020.top
Domain
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_005",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_005: escalate (confidence: 0.30). Correct decision. Reward: +0.15
## Step 10
### Observation (sent to LLM)
```
Queue: Task: Sophisticated Fraud Under Budget Pressure (medium)
Total ads: 12 | Reviewed: 5 | Pending: 7 | Budget remaining: 25 actions | Step: 10
Current Ad: === Ad in Focus: ad_006 ===
Category: ecommerce
Ad copy: "Handcrafted leather bags — designed to last. Each piece unique. ArtisanHide.com"
Targeting: Adults 25-55, interests: fashion, luxury goods
Initial risk signals: None
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_005: escalate (confidence: 0.30). Correct decision. Reward: +0.15
Available ads: ad_006, ad_007, ad_008, ad_009, ad_010, ad_011, ad_012
Verdicts: ad_001: approve (confidence: 0.90)
ad_002: reject (confidence: 0.95)
ad_003: escalate (confidence: 0.30)
ad_004: escalate (confidence: 0.30)
ad_005: escalate (confidence: 0.30)
Findings:
[ad_001 / advertiser_history]
Advertiser: FitVisit (Verified Business)
Account age: 1558 days
Country: Canada
Total historical spend: $55,594.09
Ads submitted in last 30 days: 13
Historical approval rate: 91%
Payment method: credit_card (ID: pmt_865179)
[ad_001 / payment_method]
Payment Method Analysis for ad_001:
Method type: credit_card
Payment ID: pmt_865179
No other accounts in the current queue share this payment method.
[ad_002 / landing_page]
Domain: shop4020.top
Domain age: 11 days
SSL: NO SSL / expired certificate
Registrar: Njalla (privacy)
Redirect chai
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_006",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_006: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
## Step 11
### Observation (sent to LLM)
```
Queue: Task: Sophisticated Fraud Under Budget Pressure (medium)
Total ads: 12 | Reviewed: 6 | Pending: 6 | Budget remaining: 25 actions | Step: 11
Current Ad: === Ad in Focus: ad_007 ===
Category: advance_fee
Ad copy: "URGENT: I am Prince Adebayo of Nigeria. I need your help to transfer $4.5 million. You keep 30%."
Targeting: All adults 18+, broad targeting
Initial risk signals: advance fee request, unsolicited money offer, urgency pressure, request for personal information
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_006: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
Available ads: ad_007, ad_008, ad_009, ad_010, ad_011, ad_012
Verdicts: ad_001: approve (confidence: 0.90)
ad_002: reject (confidence: 0.95)
ad_003: escalate (confidence: 0.30)
ad_004: escalate (confidence: 0.30)
ad_005: escalate (confidence: 0.30)
ad_006: escalate (confidence: 0.30)
Findings:
[ad_001 / advertiser_history]
Advertiser: FitVisit (Verified Business)
Account age: 1558 days
Country: Canada
Total historical spend: $55,594.09
Ads submitted in last 30 days: 13
Historical approval rate: 91%
Payment method: credit_card (ID: pmt_865179)
[ad_001 / payment_method]
Payment Method Analysis for ad_001:
Method type: credit_card
Payment ID: pmt_865179
No other accounts in the current queue share this payment method.
[ad_002 / la
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_007",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_007: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
## Step 12
### Observation (sent to LLM)
```
Queue: Task: Sophisticated Fraud Under Budget Pressure (medium)
Total ads: 12 | Reviewed: 7 | Pending: 5 | Budget remaining: 25 actions | Step: 12
Current Ad: === Ad in Focus: ad_008 ===
Category: saas
Ad copy: "Automate your invoicing in minutes. Trusted by 50,000+ small businesses. InvoiceSimple."
Targeting: Small business owners, interests: finance, accounting
Initial risk signals: None
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_007: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
Available ads: ad_008, ad_009, ad_010, ad_011, ad_012
Verdicts: ad_001: approve (confidence: 0.90)
ad_002: reject (confidence: 0.95)
ad_003: escalate (confidence: 0.30)
ad_004: escalate (confidence: 0.30)
ad_005: escalate (confidence: 0.30)
ad_006: escalate (confidence: 0.30)
ad_007: escalate (confidence: 0.30)
Findings:
[ad_001 / advertiser_history]
Advertiser: FitVisit (Verified Business)
Account age: 1558 days
Country: Canada
Total historical spend: $55,594.09
Ads submitted in last 30 days: 13
Historical approval rate: 91%
Payment method: credit_card (ID: pmt_865179)
[ad_001 / payment_method]
Payment Method Analysis for ad_001:
Method type: credit_card
Payment ID: pmt_865179
No other accounts in the current queue share this payment method.
[ad_002 / landing_page]
Domain: shop4020.top
Domain age: 11 days
SSL
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_008",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_008: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
## Step 13
### Observation (sent to LLM)
```
Queue: Task: Sophisticated Fraud Under Budget Pressure (medium)
Total ads: 12 | Reviewed: 8 | Pending: 4 | Budget remaining: 25 actions | Step: 13
Current Ad: === Ad in Focus: ad_009 ===
Category: ecommerce
Ad copy: "Spring Sale — Up to 30% off home essentials. Free shipping on orders over $50. Shop now at HomeNest."
Targeting: Women 25-54, interests: home decor, shopping
Initial risk signals: None
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_008: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
Available ads: ad_009, ad_010, ad_011, ad_012
Verdicts: ad_001: approve (confidence: 0.90)
ad_002: reject (confidence: 0.95)
ad_003: escalate (confidence: 0.30)
ad_004: escalate (confidence: 0.30)
ad_005: escalate (confidence: 0.30)
ad_006: escalate (confidence: 0.30)
ad_007: escalate (confidence: 0.30)
ad_008: escalate (confidence: 0.30)
Findings:
[ad_001 / advertiser_history]
Advertiser: FitVisit (Verified Business)
Account age: 1558 days
Country: Canada
Total historical spend: $55,594.09
Ads submitted in last 30 days: 13
Historical approval rate: 91%
Payment method: credit_card (ID: pmt_865179)
[ad_001 / payment_method]
Payment Method Analysis for ad_001:
Method type: credit_card
Payment ID: pmt_865179
No other accounts in the current queue share this payment method.
[ad_002 / landing_page]
Domai
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_009",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_009: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
## Step 14
### Observation (sent to LLM)
```
Queue: Task: Sophisticated Fraud Under Budget Pressure (medium)
Total ads: 12 | Reviewed: 9 | Pending: 3 | Budget remaining: 25 actions | Step: 14
Current Ad: === Ad in Focus: ad_010 ===
Category: ecommerce
Ad copy: "Handcrafted leather bags — designed to last. Each piece unique. ArtisanHide.com"
Targeting: Adults 25-55, interests: fashion, luxury goods
Initial risk signals: None
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_009: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
Available ads: ad_010, ad_011, ad_012
Verdicts: ad_001: approve (confidence: 0.90)
ad_002: reject (confidence: 0.95)
ad_003: escalate (confidence: 0.30)
ad_004: escalate (confidence: 0.30)
ad_005: escalate (confidence: 0.30)
ad_006: escalate (confidence: 0.30)
ad_007: escalate (confidence: 0.30)
ad_008: escalate (confidence: 0.30)
ad_009: escalate (confidence: 0.30)
Findings:
[ad_001 / advertiser_history]
Advertiser: FitVisit (Verified Business)
Account age: 1558 days
Country: Canada
Total historical spend: $55,594.09
Ads submitted in last 30 days: 13
Historical approval rate: 91%
Payment method: credit_card (ID: pmt_865179)
[ad_001 / payment_method]
Payment Method Analysis for ad_001:
Method type: credit_card
Payment ID: pmt_865179
No other accounts in the current queue share this payment method.
[ad_002 / landing_
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_010",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_010: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
## Step 15
### Observation (sent to LLM)
```
Queue: Task: Sophisticated Fraud Under Budget Pressure (medium)
Total ads: 12 | Reviewed: 10 | Pending: 2 | Budget remaining: 25 actions | Step: 15
Current Ad: === Ad in Focus: ad_011 ===
Category: fake_giveaway
Ad copy: "EXCLUSIVE: Win a Tesla Model 3! Enter your email NOW! Drawing ends tonight!!!"
Targeting: Adults 18-55, interests: cars, Tesla, electric vehicles
Initial risk signals: excessive urgency language, too-good-to-be-true offer, excessive punctuation/caps, no purchase necessary claims
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_010: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
Available ads: ad_011, ad_012
Verdicts: ad_001: approve (confidence: 0.90)
ad_002: reject (confidence: 0.95)
ad_003: escalate (confidence: 0.30)
ad_004: escalate (confidence: 0.30)
ad_005: escalate (confidence: 0.30)
ad_006: escalate (confidence: 0.30)
ad_007: escalate (confidence: 0.30)
ad_008: escalate (confidence: 0.30)
ad_009: escalate (confidence: 0.30)
ad_010: escalate (confidence: 0.30)
Findings:
[ad_001 / advertiser_history]
Advertiser: FitVisit (Verified Business)
Account age: 1558 days
Country: Canada
Total historical spend: $55,594.09
Ads submitted in last 30 days: 13
Historical approval rate: 91%
Payment method: credit_card (ID: pmt_865179)
[ad_001 / payment_method]
Payment Method Analysis fo
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_011",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_011: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
## Step 16
### Observation (sent to LLM)
```
Queue: Task: Sophisticated Fraud Under Budget Pressure (medium)
Total ads: 12 | Reviewed: 11 | Pending: 1 | Budget remaining: 25 actions | Step: 16
Current Ad: === Ad in Focus: ad_012 ===
Category: counterfeit_goods
Ad copy: "Rolex watches starting at $49.99! 100% genuine! Free worldwide shipping! LuxWatchDeals.net"
Targeting: Men 25-55, interests: watches, luxury
Initial risk signals: impossibly low prices for luxury goods, unfamiliar domain, claims of authenticity with extreme discounts
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_011: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
Available ads: ad_012
Verdicts: ad_001: approve (confidence: 0.90)
ad_002: reject (confidence: 0.95)
ad_003: escalate (confidence: 0.30)
ad_004: escalate (confidence: 0.30)
ad_005: escalate (confidence: 0.30)
ad_006: escalate (confidence: 0.30)
ad_007: escalate (confidence: 0.30)
ad_008: escalate (confidence: 0.30)
ad_009: escalate (confidence: 0.30)
ad_010: escalate (confidence: 0.30)
ad_011: escalate (con... [truncated]
Findings:
[ad_001 / advertiser_history]
Advertiser: FitVisit (Verified Business)
Account age: 1558 days
Country: Canada
Total historical spend: $55,594.09
Ads submitted in last 30 days: 13
Historical approval rate: 91%
Payment method: credit_card (ID: pmt_865179)
[ad_001 / payment_method]
Pay
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_012",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Episode complete. Grader score: 0.684/1.000
Verdicts rendered: 12/12
Auto-approved (unreviewed): 0 fraud ad(s) missed
Correct decisions: 4/12
## Step 17
### Observation (sent to LLM)
```
Queue: Task: Sophisticated Fraud Under Budget Pressure (medium)
Total ads: 12 | Reviewed: 12 | Pending: 0 | Budget remaining: 25 actions | Step: 17
Current Ad:
Feedback: Episode complete. Grader score: 0.684/1.000
Verdicts rendered: 12/12
Auto-approved (unreviewed): 0 fraud ad(s) missed
Correct decisions: 4/12
Available ads:
Verdicts: ad_001: approve (confidence: 0.90)
ad_002: reject (confidence: 0.95)
ad_003: escalate (confidence: 0.30)
ad_004: escalate (confidence: 0.30)
ad_005: escalate (confidence: 0.30)
ad_006: escalate (confidence: 0.30)
ad_007: escalate (confidence: 0.30)
ad_008: escalate (confidence: 0.30)
ad_009: escalate (confidence: 0.30)
ad_010: escalate (confidence: 0.30)
ad_011: escalate (con... [truncated]
Findings:
[ad_001 / advertiser_history]
Advertiser: FitVisit (Verified Business)
Account age: 1558 days
Country: Canada
Total historical spend: $55,594.09
Ads submitted in last 30 days: 13
Historical approval rate: 91%
Payment method: credit_card (ID: pmt_865179)
[ad_001 / payment_method]
Payment Method Analysis for ad_001:
Method type: credit_card
Payment ID: pmt_865179
No other accounts in the current queue share this payment method.
[ad_002 / landing_page]
Domain: shop4020.top
Domain age: 11 days
SSL: NO SSL / expired certificate
Registrar: Njalla (privacy)
Redirect chain: shop4020.top -> red... [truncated]
```
### LLM Response
```json
{}
```
---
## Result
**Score: 0.684 | Steps: 17 | Verdicts: 12/12**1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057# Episode Log — task_3
## Step 0
### Observation (sent to LLM)
```
Queue: Task: Coordinated Fraud Network Detection (hard)
Total ads: 20 | Reviewed: 0 | Pending: 20 | Budget remaining: 40 actions | Step: 0
Current Ad: === Ad in Focus: ad_001 ===
Category: saas
Ad copy: "Automate your invoicing in minutes. Trusted by 50,000+ small businesses. InvoiceSimple."
Targeting: Small business owners, interests: finance, accounting
Initial risk signals: None
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Episode started. Review the ad queue and begin your investigation.
Available ads: ad_001, ad_002, ad_003, ad_004, ad_005, ad_006, ad_007, ad_008, ad_009, ad_010, ad_011, ad_012, ad_013, ad_014, ad_015, ad_016, ad_017, ad_018, ad_019, ad_020
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_001",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_001: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
## Step 1
### Observation (sent to LLM)
```
Queue: Task: Coordinated Fraud Network Detection (hard)
Total ads: 20 | Reviewed: 1 | Pending: 19 | Budget remaining: 40 actions | Step: 1
Current Ad: === Ad in Focus: ad_002 ===
Category: advance_fee
Ad copy: "You've won the UK National Lottery! Send $100 for tax processing to receive your $1.5M prize."
Targeting: Adults 25-70, interests: lottery, gambling, luck
Initial risk signals: advance fee request, unsolicited money offer, urgency pressure, request for personal information
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_001: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
Available ads: ad_002, ad_003, ad_004, ad_005, ad_006, ad_007, ad_008, ad_009, ad_010, ad_011, ad_012, ad_013, ad_014, ad_015, ad_016, ad_017, ad_018, ad_019, ad_020
Verdicts: ad_001: escalate (confidence: 0.30)
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_002",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_002: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
## Step 2
### Observation (sent to LLM)
```
Queue: Task: Coordinated Fraud Network Detection (hard)
Total ads: 20 | Reviewed: 2 | Pending: 18 | Budget remaining: 40 actions | Step: 2
Current Ad: === Ad in Focus: ad_003 ===
Category: advance_fee
Ad copy: "Congratulations! You've inherited $2.8 million from a distant relative. Pay $200 processing fee to claim."
Targeting: Adults 30-70, interests: finance, inheritance
Initial risk signals: advance fee request, unsolicited money offer, urgency pressure, request for personal information
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_002: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
Available ads: ad_003, ad_004, ad_005, ad_006, ad_007, ad_008, ad_009, ad_010, ad_011, ad_012, ad_013, ad_014, ad_015, ad_016, ad_017, ad_018, ad_019, ad_020
Verdicts: ad_001: escalate (confidence: 0.30)
ad_002: escalate (confidence: 0.30)
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_003",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_003: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
## Step 3
### Observation (sent to LLM)
```
Queue: Task: Coordinated Fraud Network Detection (hard)
Total ads: 20 | Reviewed: 3 | Pending: 17 | Budget remaining: 40 actions | Step: 3
Current Ad: === Ad in Focus: ad_004 ===
Category: network_crypto
Ad copy: "Crypto tax software — auto-import from 50+ exchanges. CPA-approved reports. TaxChain Solutions."
Targeting: Adults 25-55, interests: crypto, tax, finance
Initial risk signals: None
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_003: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
Available ads: ad_004, ad_005, ad_006, ad_007, ad_008, ad_009, ad_010, ad_011, ad_012, ad_013, ad_014, ad_015, ad_016, ad_017, ad_018, ad_019, ad_020
Verdicts: ad_001: escalate (confidence: 0.30)
ad_002: escalate (confidence: 0.30)
ad_003: escalate (confidence: 0.30)
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_004",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_004: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
## Step 4
### Observation (sent to LLM)
```
Queue: Task: Coordinated Fraud Network Detection (hard)
Total ads: 20 | Reviewed: 4 | Pending: 16 | Budget remaining: 40 actions | Step: 4
Current Ad: === Ad in Focus: ad_005 ===
Category: fake_crypto
Ad copy: "Invest in DeFi with confidence. Our AI-powered trading platform delivers 12-15% monthly returns. Audited smart contracts. Join CryptoYield Pro."
Targeting: Men 25-45, interests: cryptocurrency, DeFi, investing
Initial risk signals: high guaranteed returns, complex financial product
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_004: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
Available ads: ad_005, ad_006, ad_007, ad_008, ad_009, ad_010, ad_011, ad_012, ad_013, ad_014, ad_015, ad_016, ad_017, ad_018, ad_019, ad_020
Verdicts: ad_001: escalate (confidence: 0.30)
ad_002: escalate (confidence: 0.30)
ad_003: escalate (confidence: 0.30)
ad_004: escalate (confidence: 0.30)
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_005",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_005: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
## Step 5
### Observation (sent to LLM)
```
Queue: Task: Coordinated Fraud Network Detection (hard)
Total ads: 20 | Reviewed: 5 | Pending: 15 | Budget remaining: 40 actions | Step: 5
Current Ad: === Ad in Focus: ad_006 ===
Category: ecommerce
Ad copy: "Spring Sale — Up to 30% off home essentials. Free shipping on orders over $50. Shop now at HomeNest."
Targeting: Women 25-54, interests: home decor, shopping
Initial risk signals: None
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_005: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
Available ads: ad_006, ad_007, ad_008, ad_009, ad_010, ad_011, ad_012, ad_013, ad_014, ad_015, ad_016, ad_017, ad_018, ad_019, ad_020
Verdicts: ad_001: escalate (confidence: 0.30)
ad_002: escalate (confidence: 0.30)
ad_003: escalate (confidence: 0.30)
ad_004: escalate (confidence: 0.30)
ad_005: escalate (confidence: 0.30)
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_006",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_006: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
## Step 6
### Observation (sent to LLM)
```
Queue: Task: Coordinated Fraud Network Detection (hard)
Total ads: 20 | Reviewed: 6 | Pending: 14 | Budget remaining: 40 actions | Step: 6
Current Ad: === Ad in Focus: ad_007 ===
Category: gray_area_supplements
Ad copy: "SlimBiome Pro — proprietary probiotic blend for healthy weight management. Featured in Health Magazine. GMP certified."
Targeting: Adults 30-60, interests: weight loss, probiotics, gut health
Initial risk signals: supplement with strong efficacy claims, medical-sounding language
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_006: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
Available ads: ad_007, ad_008, ad_009, ad_010, ad_011, ad_012, ad_013, ad_014, ad_015, ad_016, ad_017, ad_018, ad_019, ad_020
Verdicts: ad_001: escalate (confidence: 0.30)
ad_002: escalate (confidence: 0.30)
ad_003: escalate (confidence: 0.30)
ad_004: escalate (confidence: 0.30)
ad_005: escalate (confidence: 0.30)
ad_006: escalate (confidence: 0.30)
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_007",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_007: escalate (confidence: 0.30). Correct decision. Reward: +0.15
## Step 7
### Observation (sent to LLM)
```
Queue: Task: Coordinated Fraud Network Detection (hard)
Total ads: 20 | Reviewed: 7 | Pending: 13 | Budget remaining: 40 actions | Step: 7
Current Ad: === Ad in Focus: ad_008 ===
Category: celebrity_endorsement_fraud
Ad copy: "Oprah's favorite weight loss secret finally revealed. 'I lost 40 pounds without dieting.' Doctor-approved method."
Targeting: Women 25-60, interests: weight loss, Oprah, wellness
Initial risk signals: celebrity name used without verification, urgency/exclusivity language
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_007: escalate (confidence: 0.30). Correct decision. Reward: +0.15
Available ads: ad_008, ad_009, ad_010, ad_011, ad_012, ad_013, ad_014, ad_015, ad_016, ad_017, ad_018, ad_019, ad_020
Verdicts: ad_001: escalate (confidence: 0.30)
ad_002: escalate (confidence: 0.30)
ad_003: escalate (confidence: 0.30)
ad_004: escalate (confidence: 0.30)
ad_005: escalate (confidence: 0.30)
ad_006: escalate (confidence: 0.30)
ad_007: escalate (confidence: 0.30)
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_008",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_008: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
## Step 8
### Observation (sent to LLM)
```
Queue: Task: Coordinated Fraud Network Detection (hard)
Total ads: 20 | Reviewed: 8 | Pending: 12 | Budget remaining: 40 actions | Step: 8
Current Ad: === Ad in Focus: ad_009 ===
Category: education
Ad copy: "Learn Python programming in 12 weeks. Live instructor, project-based curriculum. CodeAcademy Pro."
Targeting: Adults 18-35, interests: programming, tech careers
Initial risk signals: None
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_008: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
Available ads: ad_009, ad_010, ad_011, ad_012, ad_013, ad_014, ad_015, ad_016, ad_017, ad_018, ad_019, ad_020
Verdicts: ad_001: escalate (confidence: 0.30)
ad_002: escalate (confidence: 0.30)
ad_003: escalate (confidence: 0.30)
ad_004: escalate (confidence: 0.30)
ad_005: escalate (confidence: 0.30)
ad_006: escalate (confidence: 0.30)
ad_007: escalate (confidence: 0.30)
ad_008: escalate (confidence: 0.30)
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_009",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_009: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
## Step 9
### Observation (sent to LLM)
```
Queue: Task: Coordinated Fraud Network Detection (hard)
Total ads: 20 | Reviewed: 9 | Pending: 11 | Budget remaining: 40 actions | Step: 9
Current Ad: === Ad in Focus: ad_010 ===
Category: fake_giveaway
Ad copy: "EXCLUSIVE: Win a Tesla Model 3! Enter your email NOW! Drawing ends tonight!!!"
Targeting: Adults 18-55, interests: cars, Tesla, electric vehicles
Initial risk signals: excessive urgency language, too-good-to-be-true offer, excessive punctuation/caps, no purchase necessary claims
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_009: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
Available ads: ad_010, ad_011, ad_012, ad_013, ad_014, ad_015, ad_016, ad_017, ad_018, ad_019, ad_020
Verdicts: ad_001: escalate (confidence: 0.30)
ad_002: escalate (confidence: 0.30)
ad_003: escalate (confidence: 0.30)
ad_004: escalate (confidence: 0.30)
ad_005: escalate (confidence: 0.30)
ad_006: escalate (confidence: 0.30)
ad_007: escalate (confidence: 0.30)
ad_008: escalate (confidence: 0.30)
ad_009: escalate (confidence: 0.30)
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_010",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_010: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
## Step 10
### Observation (sent to LLM)
```
Queue: Task: Coordinated Fraud Network Detection (hard)
Total ads: 20 | Reviewed: 10 | Pending: 10 | Budget remaining: 40 actions | Step: 10
Current Ad: === Ad in Focus: ad_011 ===
Category: ecommerce
Ad copy: "Handcrafted leather bags — designed to last. Each piece unique. ArtisanHide.com"
Targeting: Adults 25-55, interests: fashion, luxury goods
Initial risk signals: None
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_010: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
Available ads: ad_011, ad_012, ad_013, ad_014, ad_015, ad_016, ad_017, ad_018, ad_019, ad_020
Verdicts: ad_001: escalate (confidence: 0.30)
ad_002: escalate (confidence: 0.30)
ad_003: escalate (confidence: 0.30)
ad_004: escalate (confidence: 0.30)
ad_005: escalate (confidence: 0.30)
ad_006: escalate (confidence: 0.30)
ad_007: escalate (confidence: 0.30)
ad_008: escalate (confidence: 0.30)
ad_009: escalate (confidence: 0.30)
ad_010: escalate (confidence: 0.30)
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_011",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_011: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
## Step 11
### Observation (sent to LLM)
```
Queue: Task: Coordinated Fraud Network Detection (hard)
Total ads: 20 | Reviewed: 11 | Pending: 9 | Budget remaining: 40 actions | Step: 11
Current Ad: === Ad in Focus: ad_012 ===
Category: gray_area_supplements
Ad copy: "Joint Restore Plus — advanced collagen peptide formula. Thousands of 5-star reviews. Orthopedist recommended."
Targeting: Adults 45-75, interests: joint health, supplements, arthritis
Initial risk signals: supplement with strong efficacy claims, medical-sounding language
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_011: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
Available ads: ad_012, ad_013, ad_014, ad_015, ad_016, ad_017, ad_018, ad_019, ad_020
Verdicts: ad_001: escalate (confidence: 0.30)
ad_002: escalate (confidence: 0.30)
ad_003: escalate (confidence: 0.30)
ad_004: escalate (confidence: 0.30)
ad_005: escalate (confidence: 0.30)
ad_006: escalate (confidence: 0.30)
ad_007: escalate (confidence: 0.30)
ad_008: escalate (confidence: 0.30)
ad_009: escalate (confidence: 0.30)
ad_010: escalate (confidence: 0.30)
ad_011: escalate (... [truncated]
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_012",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_012: escalate (confidence: 0.30). Correct decision. Reward: +0.15
## Step 12
### Observation (sent to LLM)
```
Queue: Task: Coordinated Fraud Network Detection (hard)
Total ads: 20 | Reviewed: 12 | Pending: 8 | Budget remaining: 40 actions | Step: 12
Current Ad: === Ad in Focus: ad_013 ===
Category: gray_area_supplements
Ad copy: "NeuroPeak — clinically studied nootropic for enhanced focus and memory. 30-day money-back guarantee. FDA-registered facility."
Targeting: Adults 25-55, interests: nootropics, productivity, brain health
Initial risk signals: supplement with strong efficacy claims, medical-sounding language
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_012: escalate (confidence: 0.30). Correct decision. Reward: +0.15
Available ads: ad_013, ad_014, ad_015, ad_016, ad_017, ad_018, ad_019, ad_020
Verdicts: ad_001: escalate (confidence: 0.30)
ad_002: escalate (confidence: 0.30)
ad_003: escalate (confidence: 0.30)
ad_004: escalate (confidence: 0.30)
ad_005: escalate (confidence: 0.30)
ad_006: escalate (confidence: 0.30)
ad_007: escalate (confidence: 0.30)
ad_008: escalate (confidence: 0.30)
ad_009: escalate (confidence: 0.30)
ad_010: escalate (confidence: 0.30)
ad_011: escalate (... [truncated]
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_013",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_013: escalate (confidence: 0.30). Correct decision. Reward: +0.15
## Step 13
### Observation (sent to LLM)
```
Queue: Task: Coordinated Fraud Network Detection (hard)
Total ads: 20 | Reviewed: 13 | Pending: 7 | Budget remaining: 40 actions | Step: 13
Current Ad: === Ad in Focus: ad_014 ===
Category: fake_giveaway
Ad copy: "CONGRATULATIONS!! You've been selected to win a FREE iPhone 16 Pro!! Click NOW before offer expires!!!"
Targeting: All adults 18+, broad targeting, worldwide
Initial risk signals: excessive urgency language, too-good-to-be-true offer, excessive punctuation/caps, no purchase necessary claims
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_013: escalate (confidence: 0.30). Correct decision. Reward: +0.15
Available ads: ad_014, ad_015, ad_016, ad_017, ad_018, ad_019, ad_020
Verdicts: ad_001: escalate (confidence: 0.30)
ad_002: escalate (confidence: 0.30)
ad_003: escalate (confidence: 0.30)
ad_004: escalate (confidence: 0.30)
ad_005: escalate (confidence: 0.30)
ad_006: escalate (confidence: 0.30)
ad_007: escalate (confidence: 0.30)
ad_008: escalate (confidence: 0.30)
ad_009: escalate (confidence: 0.30)
ad_010: escalate (confidence: 0.30)
ad_011: escalate (... [truncated]
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_014",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_014: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
## Step 14
### Observation (sent to LLM)
```
Queue: Task: Coordinated Fraud Network Detection (hard)
Total ads: 20 | Reviewed: 14 | Pending: 6 | Budget remaining: 40 actions | Step: 14
Current Ad: === Ad in Focus: ad_015 ===
Category: gray_area_supplements
Ad copy: "TestoMax Elite — natural testosterone support for men over 40. Doctor-formulated. Published clinical trial results."
Targeting: Men 40-65, interests: men's health, testosterone, fitness
Initial risk signals: supplement with strong efficacy claims, medical-sounding language
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_014: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
Available ads: ad_015, ad_016, ad_017, ad_018, ad_019, ad_020
Verdicts: ad_001: escalate (confidence: 0.30)
ad_002: escalate (confidence: 0.30)
ad_003: escalate (confidence: 0.30)
ad_004: escalate (confidence: 0.30)
ad_005: escalate (confidence: 0.30)
ad_006: escalate (confidence: 0.30)
ad_007: escalate (confidence: 0.30)
ad_008: escalate (confidence: 0.30)
ad_009: escalate (confidence: 0.30)
ad_010: escalate (confidence: 0.30)
ad_011: escalate (... [truncated]
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_015",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_015: escalate (confidence: 0.30). Correct decision. Reward: +0.15
## Step 15
### Observation (sent to LLM)
```
Queue: Task: Coordinated Fraud Network Detection (hard)
Total ads: 20 | Reviewed: 15 | Pending: 5 | Budget remaining: 40 actions | Step: 15
Current Ad: === Ad in Focus: ad_016 ===
Category: ecommerce
Ad copy: "Handcrafted leather bags — designed to last. Each piece unique. ArtisanHide.com"
Targeting: Adults 25-55, interests: fashion, luxury goods
Initial risk signals: None
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_015: escalate (confidence: 0.30). Correct decision. Reward: +0.15
Available ads: ad_016, ad_017, ad_018, ad_019, ad_020
Verdicts: ad_001: escalate (confidence: 0.30)
ad_002: escalate (confidence: 0.30)
ad_003: escalate (confidence: 0.30)
ad_004: escalate (confidence: 0.30)
ad_005: escalate (confidence: 0.30)
ad_006: escalate (confidence: 0.30)
ad_007: escalate (confidence: 0.30)
ad_008: escalate (confidence: 0.30)
ad_009: escalate (confidence: 0.30)
ad_010: escalate (confidence: 0.30)
ad_011: escalate (... [truncated]
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_016",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_016: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
## Step 16
### Observation (sent to LLM)
```
Queue: Task: Coordinated Fraud Network Detection (hard)
Total ads: 20 | Reviewed: 16 | Pending: 4 | Budget remaining: 40 actions | Step: 16
Current Ad: === Ad in Focus: ad_017 ===
Category: miracle_cure
Ad copy: "Reverse aging in 14 days! Scientists discover fountain of youth pill! Limited supply!"
Targeting: Adults 35-65, interests: anti-aging, beauty, health
Initial risk signals: unsubstantiated medical claims, conspiracy language ('they don't want you to know'), impossible health promises, urgency/scarcity tactics
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_016: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
Available ads: ad_017, ad_018, ad_019, ad_020
Verdicts: ad_001: escalate (confidence: 0.30)
ad_002: escalate (confidence: 0.30)
ad_003: escalate (confidence: 0.30)
ad_004: escalate (confidence: 0.30)
ad_005: escalate (confidence: 0.30)
ad_006: escalate (confidence: 0.30)
ad_007: escalate (confidence: 0.30)
ad_008: escalate (confidence: 0.30)
ad_009: escalate (confidence: 0.30)
ad_010: escalate (confidence: 0.30)
ad_011: escalate (... [truncated]
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_017",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_017: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
## Step 17
### Observation (sent to LLM)
```
Queue: Task: Coordinated Fraud Network Detection (hard)
Total ads: 20 | Reviewed: 17 | Pending: 3 | Budget remaining: 40 actions | Step: 17
Current Ad: === Ad in Focus: ad_018 ===
Category: local_service
Ad copy: "Award-winning pizza delivery in Brooklyn. Family recipes since 1985. Order from Sal's Pizzeria."
Targeting: Adults 18-55, Brooklyn, interests: food delivery
Initial risk signals: None
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_017: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
Available ads: ad_018, ad_019, ad_020
Verdicts: ad_001: escalate (confidence: 0.30)
ad_002: escalate (confidence: 0.30)
ad_003: escalate (confidence: 0.30)
ad_004: escalate (confidence: 0.30)
ad_005: escalate (confidence: 0.30)
ad_006: escalate (confidence: 0.30)
ad_007: escalate (confidence: 0.30)
ad_008: escalate (confidence: 0.30)
ad_009: escalate (confidence: 0.30)
ad_010: escalate (confidence: 0.30)
ad_011: escalate (... [truncated]
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_018",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_018: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
## Step 18
### Observation (sent to LLM)
```
Queue: Task: Coordinated Fraud Network Detection (hard)
Total ads: 20 | Reviewed: 18 | Pending: 2 | Budget remaining: 40 actions | Step: 18
Current Ad: === Ad in Focus: ad_019 ===
Category: network_ecommerce
Ad copy: "Robot vacuum with LiDAR mapping. Self-emptying dock. Smart home compatible. CleanBot Pro."
Targeting: Adults 25-55, interests: smart home, cleaning
Initial risk signals: None
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_018: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
Available ads: ad_019, ad_020
Verdicts: ad_001: escalate (confidence: 0.30)
ad_002: escalate (confidence: 0.30)
ad_003: escalate (confidence: 0.30)
ad_004: escalate (confidence: 0.30)
ad_005: escalate (confidence: 0.30)
ad_006: escalate (confidence: 0.30)
ad_007: escalate (confidence: 0.30)
ad_008: escalate (confidence: 0.30)
ad_009: escalate (confidence: 0.30)
ad_010: escalate (confidence: 0.30)
ad_011: escalate (... [truncated]
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_019",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Verdict recorded for ad_019: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
## Step 19
### Observation (sent to LLM)
```
Queue: Task: Coordinated Fraud Network Detection (hard)
Total ads: 20 | Reviewed: 19 | Pending: 1 | Budget remaining: 40 actions | Step: 19
Current Ad: === Ad in Focus: ad_020 ===
Category: clone_brand
Ad copy: "PayPaI Security Alert: Your account needs verification. Update your information to avoid suspension. Secure portal."
Targeting: Adults 18-65, interests: online payments, PayPal
Initial risk signals: brand name misspelling, unofficial domain
Investigations completed: None yet
Available investigation targets: advertiser_history, landing_page, payment_method, targeting_overlap, creative_similarity
Feedback: Verdict recorded for ad_019: escalate (confidence: 0.30). Incorrect decision. Reward: -0.05
Available ads: ad_020
Verdicts: ad_001: escalate (confidence: 0.30)
ad_002: escalate (confidence: 0.30)
ad_003: escalate (confidence: 0.30)
ad_004: escalate (confidence: 0.30)
ad_005: escalate (confidence: 0.30)
ad_006: escalate (confidence: 0.30)
ad_007: escalate (confidence: 0.30)
ad_008: escalate (confidence: 0.30)
ad_009: escalate (confidence: 0.30)
ad_010: escalate (confidence: 0.30)
ad_011: escalate (... [truncated]
```
### LLM Response
```json
{}
```
### Parsed Action [FALLBACK]
```json
{
"action_type": "verdict",
"ad_id": "ad_020",
"verdict": "escalate",
"confidence": 0.3
}
```
### Environment Response
- **Reward:** `+0.00`
- **Done:** `False`
- **Feedback:** Episode complete. Grader score: 0.579/1.000
Verdicts rendered: 20/20
Auto-approved (unreviewed): 0 fraud ad(s) missed
Correct decisions: 4/20
## Step 20
### Observation (sent to LLM)
```
Queue: Task: Coordinated Fraud Network Detection (hard)
Total ads: 20 | Reviewed: 20 | Pending: 0 | Budget remaining: 40 actions | Step: 20
Current Ad:
Feedback: Episode complete. Grader score: 0.579/1.000
Verdicts rendered: 20/20
Auto-approved (unreviewed): 0 fraud ad(s) missed
Correct decisions: 4/20
Available ads:
Verdicts: ad_001: escalate (confidence: 0.30)
ad_002: escalate (confidence: 0.30)
ad_003: escalate (confidence: 0.30)
ad_004: escalate (confidence: 0.30)
ad_005: escalate (confidence: 0.30)
ad_006: escalate (confidence: 0.30)
ad_007: escalate (confidence: 0.30)
ad_008: escalate (confidence: 0.30)
ad_009: escalate (confidence: 0.30)
ad_010: escalate (confidence: 0.30)
ad_011: escalate (... [truncated]
```
### LLM Response
```json
{}
```
---
## Result
**Score: 0.579 | Steps: 20 | Verdicts: 20/20**1234567891011121314151617181920212223242526272829303132333435363738394041424344[build-system]
requires = ["setuptools>=45", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "openenv-ad-fraud-env"
version = "0.1.0"
description = "Ad Fraud Investigation Environment for OpenEnv — real-world ad fraud detection and investigation simulation"
requires-python = ">=3.11"
dependencies = [
"openenv-core[core]>=0.2.2",
"fastapi>=0.115.0",
"pydantic>=2.0.0",
"uvicorn[standard]>=0.24.0",
"requests>=2.31.0",
"faker==33.1.0",
"networkx>=3.2",
"openai>=1.0.0",
"python-dotenv>=1.0.0",
]
[project.optional-dependencies]
dev = [
"pytest>=8.0.0",
"pytest-cov>=4.0.0",
"pytest-asyncio>=0.23.0",
]
[project.scripts]
server = "ad_fraud_env.server.app:main"
[tool.setuptools]
packages = [
"ad_fraud_env",
"ad_fraud_env.server",
"ad_fraud_env.data",
"ad_fraud_env.graders",
]
[tool.setuptools.package-dir]
"ad_fraud_env" = "."
"ad_fraud_env.server" = "server"
"ad_fraud_env.data" = "data"
"ad_fraud_env.graders" = "graders"1"""Server package for the Ad Fraud Investigation Environment."""123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113"""
FastAPI application for the Ad Fraud Investigation Environment.
Creates the OpenEnv server via create_app() and registers custom HTTP
endpoints required by the hackathon: /tasks, /baseline, /grader.
"""
from __future__ import annotations
import json
import logging
import os
from pathlib import Path
from typing import Any, Dict
from openenv.core.env_server import create_app
try:
from ..models import AdReviewAction, AdReviewObservation
except ImportError:
from models import AdReviewAction, AdReviewObservation
from .environment import AdFraudEnvironment, get_last_grader_result
logger = logging.getLogger(__name__)
app = create_app(
AdFraudEnvironment,
AdReviewAction,
AdReviewObservation,
env_name="ad_fraud_env",
)
# ------------------------------------------------------------------
# Custom endpoints required by the competition
# ------------------------------------------------------------------
@app.get("/tasks", tags=["Competition"])
async def tasks() -> Dict[str, Any]:
"""Return the list of tasks and the action schema."""
try:
from ..data.ad_generator import TASK_CONFIGS
except ImportError:
from data.ad_generator import TASK_CONFIGS
task_list = []
for tid, cfg in TASK_CONFIGS.items():
task_list.append({
"id": cfg.task_id,
"name": cfg.name,
"difficulty": cfg.difficulty,
"queue_size": cfg.queue_size,
"action_budget": cfg.action_budget,
"description": cfg.description,
})
return {
"tasks": task_list,
"action_schema": AdReviewAction.model_json_schema(),
}
@app.get("/baseline", tags=["Competition"])
async def baseline() -> Dict[str, Any]:
"""Return baseline scores, running live inference if credentials are available."""
baseline_path = Path(__file__).resolve().parent.parent / "baseline_scores.json"
has_creds = all(os.getenv(v) for v in ("API_BASE_URL", "MODEL_NAME", "HF_TOKEN"))
if has_creds:
try:
try:
from ..inference import run_baseline
except ImportError:
from inference import run_baseline
scores = run_baseline()
with open(baseline_path, "w") as f:
json.dump(scores, f, indent=2)
return scores
except Exception as e:
logger.warning("Live baseline failed, falling back to cached: %s", e)
if baseline_path.exists():
with open(baseline_path) as f:
return json.load(f)
return {
"error": "No baseline scores available. Set API_BASE_URL, MODEL_NAME, and HF_TOKEN to run live inference.",
"tasks": {},
}
@app.get("/grader", tags=["Competition"])
async def grader() -> Dict[str, Any]:
"""Return grader score from the most recently completed episode."""
result = get_last_grader_result()
if not result:
return {
"error": "No completed episode. Run an episode via WebSocket first.",
"grader_score": None,
}
return result
def main() -> None:
"""Entry point for direct execution."""
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)
if __name__ == "__main__":
main()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559"""
Core Ad Fraud Investigation Environment.
Implements the OpenEnv Environment interface. The agent reviews a queue of ads,
investigates them, and renders verdicts under a budget constraint.
"""
from __future__ import annotations
import logging
from typing import Any, Dict, List, Optional, Set
from uuid import uuid4
from openenv.core.env_server.interfaces import Environment
from openenv.core.env_server.types import State
try:
from ..data.ad_generator import (
TASK_CONFIGS,
Ad,
GeneratedEpisode,
generate_episode,
)
from ..models import AdFraudState, AdReviewAction, AdReviewObservation
from ..graders.base_grader import EpisodeRecord, LinkResult, VerdictResult, grade_episode
except ImportError:
from data.ad_generator import (
TASK_CONFIGS,
Ad,
GeneratedEpisode,
generate_episode,
)
from models import AdFraudState, AdReviewAction, AdReviewObservation
from graders.base_grader import EpisodeRecord, LinkResult, VerdictResult, grade_episode
logger = logging.getLogger(__name__)
# Module-level store so the /grader endpoint can read the last score.
_last_grader_result: Dict[str, Any] = {}
def get_last_grader_result() -> Dict[str, Any]:
return dict(_last_grader_result)
class AdFraudEnvironment(
Environment[AdReviewAction, AdReviewObservation, AdFraudState]
):
"""
Ad fraud investigation environment.
Each episode is a review session: the agent processes a queue of N ads
within a limited action budget, choosing what to investigate and when
to render verdicts. Unreviewed ads auto-approve at episode end.
"""
SUPPORTS_CONCURRENT_SESSIONS = True
def __init__(self) -> None:
super().__init__()
self._state = AdFraudState(episode_id=str(uuid4()), step_count=0)
self._episode: Optional[GeneratedEpisode] = None
self._verdicts: Dict[str, Dict[str, Any]] = {}
self._links: List[Dict[str, Any]] = []
self._investigations: Dict[str, List[str]] = {}
self._cumulative_reward: float = 0.0
self._done = False
self._last_feedback = ""
self._focused_ad_id: Optional[str] = None
# ------------------------------------------------------------------
# OpenEnv interface
# ------------------------------------------------------------------
def reset(
self,
seed: int | None = None,
episode_id: str | None = None,
**kwargs: Any,
) -> AdReviewObservation:
task_id = kwargs.get("task_id", "task_1")
if task_id not in TASK_CONFIGS:
task_id = "task_1"
effective_seed = seed if seed is not None else hash(uuid4()) & 0xFFFFFFFF
self._episode = generate_episode(effective_seed, task_id)
config = self._episode.task_config
self._state = AdFraudState(
episode_id=episode_id or str(uuid4()),
step_count=0,
task_id=task_id,
total_ads=config.queue_size,
reviewed_count=0,
remaining_budget=config.action_budget,
verdicts={},
grader_score=None,
)
self._verdicts = {}
self._links = []
self._investigations = {}
self._cumulative_reward = 0.0
self._done = False
self._last_feedback = "Episode started. Review the ad queue and begin your investigation."
self._focused_ad_id = self._episode.ads[0].ad_id if self._episode.ads else None
return self._build_observation(reward=0.0, done=False)
def step(
self,
action: AdReviewAction,
timeout_s: float | None = None,
**kwargs: Any,
) -> AdReviewObservation:
if self._done:
return self._build_observation(
reward=0.0, done=True,
feedback_override="Episode is already complete. Call reset() to start a new episode.",
)
if self._episode is None:
return self._build_observation(
reward=0.0, done=False,
feedback_override="Environment not initialized. Call reset() first.",
)
self._state.step_count += 1
ad_ids = {a.ad_id for a in self._episode.ads}
if action.ad_id not in ad_ids:
self._last_feedback = f"Invalid ad_id '{action.ad_id}'. Valid IDs: {', '.join(sorted(ad_ids))}"
return self._build_observation(reward=-0.05, done=False)
if action.action_type == "investigate":
reward = self._handle_investigate(action)
elif action.action_type == "verdict":
reward = self._handle_verdict(action)
elif action.action_type == "link_accounts":
reward = self._handle_link(action)
else:
self._last_feedback = f"Unknown action_type '{action.action_type}'."
reward = -0.05
self._cumulative_reward += reward
done = self._check_done()
if done and not self._done:
end_reward = self._handle_episode_end()
reward += end_reward
self._cumulative_reward += end_reward
self._done = True
self._state.remaining_budget = max(0, self._state.remaining_budget)
self._state.reviewed_count = len(self._verdicts)
self._state.verdicts = {
ad_id: v.get("verdict", "") for ad_id, v in self._verdicts.items()
}
return self._build_observation(reward=reward, done=self._done)
@property
def state(self) -> AdFraudState:
return self._state
# ------------------------------------------------------------------
# Action handlers
# ------------------------------------------------------------------
def _handle_investigate(self, action: AdReviewAction) -> float:
if self._state.remaining_budget <= 0:
self._last_feedback = "No budget remaining. You must render verdicts on remaining ads or end the episode."
return -0.02
if action.investigation_target is None:
self._last_feedback = "investigation_target is required for action_type='investigate'."
return -0.05
ad_id = action.ad_id
target = action.investigation_target
prev = self._investigations.setdefault(ad_id, [])
if target in prev:
self._last_feedback = (
f"You already investigated '{target}' for {ad_id}. "
"Choose a different investigation target or render a verdict."
)
return -0.02
if ad_id in self._verdicts:
self._last_feedback = f"You already rendered a verdict on {ad_id}. Choose a different ad."
return -0.02
self._state.remaining_budget -= 1
prev.append(target)
self._focused_ad_id = ad_id
findings = self._episode.investigation_data.get(ad_id, {}).get(
target, "No data available for this investigation type."
)
self._last_feedback = (
f"Investigation complete: {target} for {ad_id}.\n"
f"--- Findings ---\n{findings}"
)
return -0.02
def _handle_verdict(self, action: AdReviewAction) -> float:
ad_id = action.ad_id
if ad_id in self._verdicts:
self._last_feedback = f"You already rendered a verdict on {ad_id}."
return -0.02
if action.verdict is None:
self._last_feedback = "verdict field is required for action_type='verdict'."
return -0.05
confidence = action.confidence if action.confidence is not None else 0.5
ad = self._get_ad(ad_id)
ground_truth = ad.ground_truth_label if ad else "legit"
severity = ad.severity if ad else 0.0
self._verdicts[ad_id] = {
"verdict": action.verdict,
"confidence": confidence,
"ground_truth": ground_truth,
}
reward = self._compute_verdict_reward(action.verdict, ground_truth, severity, confidence)
pending = [a.ad_id for a in self._episode.ads if a.ad_id not in self._verdicts]
self._last_feedback = (
f"Verdict recorded for {ad_id}: {action.verdict} "
f"(confidence: {confidence:.2f}). "
f"{len(pending)} ad(s) remaining in queue."
)
if pending:
self._focused_ad_id = pending[0]
return reward
def _handle_link(self, action: AdReviewAction) -> float:
if action.linked_ad_id is None:
self._last_feedback = "linked_ad_id is required for action_type='link_accounts'."
return -0.05
ad_ids = {a.ad_id for a in self._episode.ads}
if action.linked_ad_id not in ad_ids:
self._last_feedback = f"Invalid linked_ad_id '{action.linked_ad_id}'."
return -0.05
if action.ad_id == action.linked_ad_id:
self._last_feedback = "Cannot link an ad to itself."
return -0.05
link_key = tuple(sorted([action.ad_id, action.linked_ad_id]))
existing = {tuple(sorted([l["ad_id_1"], l["ad_id_2"]])) for l in self._links}
if link_key in existing:
self._last_feedback = f"Link between {action.ad_id} and {action.linked_ad_id} already recorded."
return -0.02
is_correct = self._check_link_correct(action.ad_id, action.linked_ad_id)
self._links.append({
"ad_id_1": action.ad_id,
"ad_id_2": action.linked_ad_id,
"reason": action.link_reason or "",
"correct": is_correct,
})
self._last_feedback = (
f"Network link recorded: {action.ad_id} <-> {action.linked_ad_id}. "
f"Reason: {action.link_reason or 'not specified'}."
)
return 0.4 if is_correct else -0.25
# ------------------------------------------------------------------
# Reward computation
# ------------------------------------------------------------------
def _compute_verdict_reward(
self, verdict: str, ground_truth: str, severity: float, confidence: float
) -> float:
if verdict == "reject" and ground_truth == "fraud":
return 0.3 + 0.1 * severity
elif verdict == "approve" and ground_truth == "legit":
return 0.1
elif verdict == "escalate" and ground_truth == "escalate":
return 0.15
elif verdict == "reject" and ground_truth == "legit":
return -0.35
elif verdict == "approve" and ground_truth == "fraud":
return -0.5
elif verdict == "escalate":
return -0.05
elif verdict == "approve" and ground_truth == "escalate":
return -0.15
elif verdict == "reject" and ground_truth == "escalate":
return -0.1
else:
return -0.05
def _handle_episode_end(self) -> float:
"""Apply end-of-episode adjustments for unreviewed ads, then delegate to graders."""
unreviewed_fraud = 0
for ad in self._episode.ads:
if ad.ad_id not in self._verdicts:
self._verdicts[ad.ad_id] = {
"verdict": "approve",
"confidence": 0.0,
"ground_truth": ad.ground_truth_label,
"auto_approved": True,
}
if ad.ground_truth_label == "fraud":
unreviewed_fraud += 1
record = self._build_episode_record()
grader_score = grade_episode(record)
self._state.grader_score = grader_score
reviewed_count = len([v for v in self._verdicts.values() if not v.get("auto_approved")])
total_ads = len(self._episode.ads)
total_correct = sum(
1 for v in self._verdicts.values()
if not v.get("auto_approved")
and (
(v["verdict"] == "reject" and v["ground_truth"] == "fraud")
or (v["verdict"] == "approve" and v["ground_truth"] == "legit")
or (v["verdict"] == "escalate" and v["ground_truth"] == "escalate")
)
)
false_positives = sum(
1 for v in self._verdicts.values()
if not v.get("auto_approved")
and v["verdict"] == "reject" and v["ground_truth"] == "legit"
)
false_negatives = sum(
1 for v in self._verdicts.values()
if not v.get("auto_approved")
and v["verdict"] == "approve" and v["ground_truth"] == "fraud"
)
correct_links = sum(1 for l in self._links if l.get("correct"))
incorrect_links = sum(1 for l in self._links if not l.get("correct"))
global _last_grader_result
_last_grader_result = {
"task_id": self._state.task_id,
"grader_score": grader_score,
"episode_id": self._state.episode_id,
"total_steps": self._state.step_count,
"verdicts_rendered": reviewed_count,
"correct_decisions": total_correct,
"false_positives": false_positives,
"false_negatives": false_negatives,
"auto_approved": total_ads - reviewed_count,
"unreviewed_fraud": unreviewed_fraud,
"network_links_correct": correct_links,
"network_links_incorrect": incorrect_links,
}
feedback_lines = [
f"Episode complete. Grader score: {grader_score:.3f}/1.000",
f"Verdicts rendered: {reviewed_count}/{total_ads}",
f"Correct decisions: {total_correct}/{reviewed_count}",
f"False positives (legit rejected): {false_positives}",
f"False negatives (fraud approved): {false_negatives}",
f"Unreviewed ads auto-approved: {unreviewed_fraud}",
]
if self._links:
feedback_lines.append(
f"Network links: {correct_links} correct, {incorrect_links} incorrect"
)
self._last_feedback = "\n".join(feedback_lines)
return 0.0
def _build_episode_record(self) -> EpisodeRecord:
"""Convert internal state into an EpisodeRecord for the grader."""
verdict_results = []
for ad in self._episode.ads:
v = self._verdicts.get(ad.ad_id)
if v:
verdict_results.append(VerdictResult(
ad_id=ad.ad_id,
verdict=v["verdict"],
confidence=v.get("confidence", 0.5),
ground_truth=v["ground_truth"],
auto_approved=v.get("auto_approved", False),
))
link_results = [
LinkResult(ad_id_1=l["ad_id_1"], ad_id_2=l["ad_id_2"], correct=l["correct"])
for l in self._links
]
ads_metadata = [
{"ad_id": ad.ad_id, "ground_truth": ad.ground_truth_label, "severity": ad.severity}
for ad in self._episode.ads
]
return EpisodeRecord(
task_id=self._state.task_id,
total_steps=self._state.step_count,
action_budget=self._episode.task_config.action_budget,
verdicts=verdict_results,
links=link_results,
ads_metadata=ads_metadata,
n_fraud_rings=len(self._episode.fraud_rings),
ring_sizes=[len(r.member_ad_ids) for r in self._episode.fraud_rings],
)
# ------------------------------------------------------------------
# Helpers
# ------------------------------------------------------------------
def _check_done(self) -> bool:
if self._episode is None:
return True
all_reviewed = all(
ad.ad_id in self._verdicts for ad in self._episode.ads
)
steps_exhausted = self._state.step_count >= self._episode.task_config.action_budget
return all_reviewed or steps_exhausted
def _check_link_correct(self, ad_id_1: str, ad_id_2: str) -> bool:
"""Check if two ads share a fraud ring."""
for ring in self._episode.fraud_rings:
if ad_id_1 in ring.member_ad_ids and ad_id_2 in ring.member_ad_ids:
return True
return False
def _get_ad(self, ad_id: str) -> Optional[Ad]:
if self._episode is None:
return None
for ad in self._episode.ads:
if ad.ad_id == ad_id:
return ad
return None
def _build_observation(
self,
reward: float,
done: bool,
feedback_override: str | None = None,
) -> AdReviewObservation:
feedback = feedback_override or self._last_feedback
if self._episode is None:
return AdReviewObservation(
done=done,
reward=reward,
queue_summary="No episode loaded.",
current_ad_info="",
investigation_findings="",
verdict_history_summary="",
feedback=feedback,
available_ads=[],
queue_status={},
)
config = self._episode.task_config
pending = [a for a in self._episode.ads if a.ad_id not in self._verdicts]
reviewed = [a for a in self._episode.ads if a.ad_id in self._verdicts]
steps_remaining = max(0, config.action_budget - self._state.step_count)
queue_summary = (
f"Task: {config.name} ({config.difficulty})\n"
f"Total ads: {config.queue_size} | "
f"Reviewed: {len(reviewed)} | "
f"Pending: {len(pending)} | "
f"Steps remaining: {steps_remaining}/{config.action_budget} | "
f"Investigation budget: {self._state.remaining_budget} | "
f"Step: {self._state.step_count}"
)
current_ad_info = ""
if self._focused_ad_id and not done:
ad = self._get_ad(self._focused_ad_id)
if ad and ad.ad_id not in self._verdicts:
signals = ", ".join(ad.initial_risk_signals) if ad.initial_risk_signals else "None"
investigated = self._investigations.get(ad.ad_id, [])
inv_status = ", ".join(investigated) if investigated else "None yet"
# Contextual metadata visible before investigation
profile = self._episode.advertiser_profiles.get(ad.ad_id)
meta_lines = []
if profile:
meta_lines.append(f"Advertiser country: {profile.country}")
meta_lines.append(f"Account age: {profile.account_age_days} days")
if profile.account_age_days < 30:
meta_lines.append("Flag: New account (< 30 days)")
context_meta = "\n".join(meta_lines)
current_ad_info = (
f"=== Ad in Focus: {ad.ad_id} ===\n"
f"Category: {ad.category}\n"
f"Ad copy: \"{ad.ad_copy}\"\n"
f"Targeting: {ad.targeting_summary}\n"
f"Initial risk signals: {signals}\n"
f"{context_meta}\n"
f"Investigations completed: {inv_status}\n"
f"Available investigation targets: advertiser_history, landing_page, "
f"payment_method, targeting_overlap, creative_similarity, campaign_structure"
)
investigation_findings = ""
for ad_id, targets in self._investigations.items():
for target in targets:
finding = self._episode.investigation_data.get(ad_id, {}).get(target, "")
if finding:
investigation_findings += f"\n[{ad_id} / {target}]\n{finding}\n"
manual_verdicts = {
ad_id: v for ad_id, v in self._verdicts.items()
if not v.get("auto_approved")
}
if manual_verdicts:
counts = {"approve": 0, "reject": 0, "escalate": 0}
by_decision = {"approve": [], "reject": [], "escalate": []}
for ad_id, v in manual_verdicts.items():
counts[v["verdict"]] = counts.get(v["verdict"], 0) + 1
by_decision[v["verdict"]].append(ad_id)
summary_parts = [f"{c} {k}" for k, c in counts.items() if c > 0]
verdict_lines = [
f"Reviewed {len(manual_verdicts)} ad(s): {', '.join(summary_parts)}."
]
for decision in ("reject", "approve", "escalate"):
if by_decision[decision]:
verdict_lines.append(
f" {decision}: {', '.join(by_decision[decision])}"
)
verdict_history_summary = "\n".join(verdict_lines)
else:
verdict_history_summary = "No verdicts yet."
available_ads = [a.ad_id for a in pending]
queue_status = {
"total_ads": config.queue_size,
"reviewed": len(reviewed),
"pending": len(pending),
"investigation_budget": self._state.remaining_budget,
"steps_remaining": steps_remaining,
"step": self._state.step_count,
"task_id": config.task_id,
}
return AdReviewObservation(
done=done,
reward=reward,
queue_summary=queue_summary,
current_ad_info=current_ad_info,
investigation_findings=investigation_findings.strip(),
verdict_history_summary=verdict_history_summary,
feedback=feedback,
available_ads=available_ads,
queue_status=queue_status,
)123456789openenv-core[core]>=0.2.2
fastapi>=0.115.0
pydantic>=2.0.0
uvicorn[standard]>=0.24.0
requests>=2.31.0
faker==33.1.0
networkx>=3.2
openai>=1.0.0
python-dotenv>=1.0.0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141"""Tests for deterministic data generation."""
import json
from ad_fraud_env.data.ad_generator import generate_episode
class TestDeterminism:
def test_same_seed_produces_identical_output(self):
"""Generate with seed=42 twice — output must be byte-identical."""
ep1 = generate_episode(seed=42, task_id="task_1")
ep2 = generate_episode(seed=42, task_id="task_1")
assert len(ep1.ads) == len(ep2.ads)
for a1, a2 in zip(ep1.ads, ep2.ads):
assert a1.ad_id == a2.ad_id
assert a1.ad_copy == a2.ad_copy
assert a1.ground_truth_label == a2.ground_truth_label
for ad_id in ep1.investigation_data:
for target in ep1.investigation_data[ad_id]:
assert (
ep1.investigation_data[ad_id][target]
== ep2.investigation_data[ad_id][target]
)
def test_different_seeds_produce_different_output(self):
ep1 = generate_episode(seed=42, task_id="task_1")
ep2 = generate_episode(seed=99, task_id="task_1")
copies_1 = {a.ad_copy for a in ep1.ads}
copies_2 = {a.ad_copy for a in ep2.ads}
assert copies_1 != copies_2
def test_task_configs_produce_correct_queue_sizes(self):
for task_id, expected_size in [("task_1", 5), ("task_2", 12), ("task_3", 20)]:
ep = generate_episode(seed=42, task_id=task_id)
assert len(ep.ads) == expected_size, f"{task_id}: expected {expected_size}, got {len(ep.ads)}"
def test_task3_has_fraud_rings(self):
ep = generate_episode(seed=42, task_id="task_3")
assert len(ep.fraud_rings) > 0, "Task 3 should have fraud rings"
for ring in ep.fraud_rings:
assert len(ring.member_ad_ids) >= 3
assert len(ring.shared_signals) >= 2
assert ring.topology in ("clique", "chain", "hub_spoke")
def test_investigation_data_exists_for_all_ads(self):
ep = generate_episode(seed=42, task_id="task_2")
expected_targets = [
"advertiser_history", "landing_page", "payment_method",
"targeting_overlap", "creative_similarity", "campaign_structure",
]
for ad in ep.ads:
assert ad.ad_id in ep.investigation_data
for target in expected_targets:
assert target in ep.investigation_data[ad.ad_id], (
f"Missing {target} for {ad.ad_id}"
)
assert len(ep.investigation_data[ad.ad_id][target]) > 0
def test_ground_truth_distribution(self):
ep = generate_episode(seed=42, task_id="task_2")
labels = [a.ground_truth_label for a in ep.ads]
assert "fraud" in labels
assert "legit" in labels
class TestNoExplicitCrossAdReferences:
"""Investigation text must not explicitly name other ad IDs."""
def test_payment_investigation_no_cross_refs(self):
ep = generate_episode(seed=42, task_id="task_3")
for ad_id, inv in ep.investigation_data.items():
text = inv["payment_method"]
for other_ad in ep.investigation_data:
if other_ad == ad_id:
continue
assert other_ad not in text, (
f"Payment investigation for {ad_id} references {other_ad}"
)
def test_targeting_investigation_no_cross_refs(self):
ep = generate_episode(seed=42, task_id="task_3")
for ad_id, inv in ep.investigation_data.items():
text = inv["targeting_overlap"]
assert "HIGH OVERLAP detected with:" not in text
def test_creative_investigation_no_cross_refs(self):
ep = generate_episode(seed=42, task_id="task_3")
for ad_id, inv in ep.investigation_data.items():
text = inv["creative_similarity"]
assert "STRONG SIMILARITY detected with:" not in text
def test_campaign_investigation_no_cross_refs(self):
ep = generate_episode(seed=42, task_id="task_3")
for ad_id, inv in ep.investigation_data.items():
text = inv["campaign_structure"]
assert "MATCH:" not in text
class TestDecoysAndRealism:
def test_advertiser_profiles_have_temporal_signals(self):
ep = generate_episode(seed=42, task_id="task_2")
for ad_id, profile in ep.advertiser_profiles.items():
assert profile.account_created_date, f"Missing created date for {ad_id}"
assert profile.spend_velocity, f"Missing spend velocity for {ad_id}"
assert profile.ad_submission_pattern, f"Missing submission pattern for {ad_id}"
def test_temporal_signals_appear_in_investigation(self):
ep = generate_episode(seed=42, task_id="task_2")
for ad_id, inv in ep.investigation_data.items():
text = inv["advertiser_history"]
assert "Account created:" in text or "Account age:" in text
assert "Spend velocity:" in text or "spend" in text.lower()
def test_ring_members_share_creation_week(self):
"""Ring members should have account creation dates within 7 days of each other."""
from datetime import date
ep = generate_episode(seed=42, task_id="task_3")
for ring in ep.fraud_rings:
dates = []
for ad_id in ring.member_ad_ids:
profile = ep.advertiser_profiles[ad_id]
d = date.fromisoformat(profile.account_created_date)
dates.append(d)
if len(dates) >= 2:
spread = (max(dates) - min(dates)).days
assert spread <= 7, (
f"Ring {ring.ring_id} creation dates spread: {spread} days"
)
def test_investigation_has_whois_privacy_info(self):
ep = generate_episode(seed=42, task_id="task_2")
found_whois = False
for ad_id, inv in ep.investigation_data.items():
text = inv["landing_page"]
if "WHOIS privacy:" in text:
found_whois = True
break
assert found_whois, "At least one landing page should mention WHOIS privacy"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178"""Tests for the core AdFraudEnvironment."""
from ad_fraud_env.models import AdReviewAction, AdReviewObservation, AdFraudState
from ad_fraud_env.server.environment import AdFraudEnvironment
class TestReset:
def test_reset_returns_observation(self):
env = AdFraudEnvironment()
obs = env.reset(seed=42, task_id="task_1")
assert isinstance(obs, AdReviewObservation)
assert obs.done is False
assert obs.reward == 0.0
assert len(obs.available_ads) == 5
def test_reset_clears_state(self):
env = AdFraudEnvironment()
env.reset(seed=42, task_id="task_1")
env.step(AdReviewAction(
action_type="verdict", ad_id="ad_001",
verdict="approve", confidence=0.9,
))
obs = env.reset(seed=42, task_id="task_1")
state = env.state
assert state.step_count == 0
assert state.reviewed_count == 0
assert len(obs.available_ads) == 5
def test_reset_different_tasks(self):
env = AdFraudEnvironment()
for task_id, expected in [("task_1", 5), ("task_2", 12), ("task_3", 20)]:
obs = env.reset(seed=42, task_id=task_id)
assert len(obs.available_ads) == expected
class TestStep:
def test_investigate_returns_findings(self):
env = AdFraudEnvironment()
env.reset(seed=42, task_id="task_1")
obs = env.step(AdReviewAction(
action_type="investigate",
ad_id="ad_001",
investigation_target="advertiser_history",
))
assert obs.done is False
assert obs.reward == -0.02
assert "Advertiser" in obs.feedback or "Investigation complete" in obs.feedback
def test_verdict_correct_rejection(self):
env = AdFraudEnvironment()
env.reset(seed=42, task_id="task_1")
fraud_ads = [
a for a in env._episode.ads if a.ground_truth_label == "fraud"
]
assert len(fraud_ads) > 0
ad = fraud_ads[0]
obs = env.step(AdReviewAction(
action_type="verdict", ad_id=ad.ad_id,
verdict="reject", confidence=0.9,
))
assert obs.reward > 0
def test_verdict_false_negative_penalty(self):
env = AdFraudEnvironment()
env.reset(seed=42, task_id="task_1")
fraud_ads = [
a for a in env._episode.ads if a.ground_truth_label == "fraud"
]
ad = fraud_ads[0]
obs = env.step(AdReviewAction(
action_type="verdict", ad_id=ad.ad_id,
verdict="approve", confidence=0.9,
))
assert obs.reward < 0
def test_duplicate_verdict_rejected(self):
env = AdFraudEnvironment()
env.reset(seed=42, task_id="task_1")
env.step(AdReviewAction(
action_type="verdict", ad_id="ad_001",
verdict="approve", confidence=0.5,
))
obs = env.step(AdReviewAction(
action_type="verdict", ad_id="ad_001",
verdict="reject", confidence=0.9,
))
assert obs.reward == -0.02
def test_invalid_ad_id(self):
env = AdFraudEnvironment()
env.reset(seed=42, task_id="task_1")
obs = env.step(AdReviewAction(
action_type="investigate", ad_id="ad_999",
investigation_target="landing_page",
))
assert obs.reward == -0.05
assert "Invalid" in obs.feedback
def test_episode_ends_when_all_reviewed(self):
env = AdFraudEnvironment()
obs = env.reset(seed=42, task_id="task_1")
for ad_id in list(obs.available_ads):
obs = env.step(AdReviewAction(
action_type="verdict", ad_id=ad_id,
verdict="reject", confidence=0.5,
))
assert obs.done is True
def test_step_after_done_returns_done(self):
env = AdFraudEnvironment()
obs = env.reset(seed=42, task_id="task_1")
for ad_id in list(obs.available_ads):
obs = env.step(AdReviewAction(
action_type="verdict", ad_id=ad_id,
verdict="reject", confidence=0.5,
))
obs = env.step(AdReviewAction(
action_type="investigate", ad_id="ad_001",
investigation_target="landing_page",
))
assert obs.done is True
assert "already complete" in obs.feedback.lower()
class TestState:
def test_state_tracks_progress(self):
env = AdFraudEnvironment()
env.reset(seed=42, task_id="task_1")
state = env.state
assert state.task_id == "task_1"
assert state.total_ads == 5
assert state.remaining_budget == 25
assert state.step_count == 0
env.step(AdReviewAction(
action_type="investigate", ad_id="ad_001",
investigation_target="landing_page",
))
state = env.state
assert state.step_count == 1
assert state.remaining_budget == 24
def test_grader_score_set_on_completion(self):
env = AdFraudEnvironment()
obs = env.reset(seed=42, task_id="task_1")
for ad_id in list(obs.available_ads):
env.step(AdReviewAction(
action_type="verdict", ad_id=ad_id,
verdict="reject", confidence=0.5,
))
state = env.state
assert state.grader_score is not None
assert 0.0 <= state.grader_score <= 1.0
class TestAntiExploit:
def test_always_reject_scores_poorly(self):
"""Always-reject on task_2 (5 legit / 5 fraud / 2 escalate) should be punished."""
env = AdFraudEnvironment()
obs = env.reset(seed=42, task_id="task_2")
for ad_id in list(obs.available_ads):
env.step(AdReviewAction(
action_type="verdict", ad_id=ad_id,
verdict="reject", confidence=0.9,
))
score = env.state.grader_score
assert score < 0.7, f"Always-reject should score poorly, got {score}"
def test_always_escalate_scores_poorly(self):
env = AdFraudEnvironment()
obs = env.reset(seed=42, task_id="task_1")
for ad_id in list(obs.available_ads):
env.step(AdReviewAction(
action_type="verdict", ad_id=ad_id,
verdict="escalate", confidence=0.5,
))
score = env.state.grader_score
assert score < 0.7, f"Always-escalate should score poorly, got {score}"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203"""Tests for the grading system."""
from ad_fraud_env.graders.base_grader import (
BaseGrader,
EpisodeRecord,
LinkResult,
VerdictResult,
grade_episode,
)
def _make_record(
task_id: str = "task_1",
verdicts: list | None = None,
links: list | None = None,
total_steps: int = 5,
action_budget: int = 25,
ads_metadata: list | None = None,
n_fraud_rings: int = 0,
ring_sizes: list | None = None,
) -> EpisodeRecord:
if verdicts is None:
verdicts = []
if links is None:
links = []
if ads_metadata is None:
ads_metadata = [
{"ad_id": v.ad_id, "severity": 0.8, "ground_truth": v.ground_truth}
for v in verdicts
]
return EpisodeRecord(
task_id=task_id,
total_steps=total_steps,
action_budget=action_budget,
verdicts=verdicts,
links=links,
ads_metadata=ads_metadata,
n_fraud_rings=n_fraud_rings,
ring_sizes=ring_sizes,
)
class TestGraderScoreRange:
def test_scores_in_valid_range(self):
verdicts = [
VerdictResult("ad_001", "reject", 0.9, "fraud"),
VerdictResult("ad_002", "approve", 0.9, "legit"),
VerdictResult("ad_003", "reject", 0.8, "fraud"),
]
record = _make_record(verdicts=verdicts, total_steps=3)
score = grade_episode(record)
assert 0.0 <= score <= 1.0
def test_perfect_score_is_high(self):
verdicts = [
VerdictResult("ad_001", "reject", 0.95, "fraud"),
VerdictResult("ad_002", "approve", 0.95, "legit"),
VerdictResult("ad_003", "reject", 0.95, "fraud"),
VerdictResult("ad_004", "approve", 0.95, "legit"),
VerdictResult("ad_005", "reject", 0.95, "fraud"),
]
record = _make_record(verdicts=verdicts, total_steps=5)
score = grade_episode(record)
assert score > 0.7, f"Perfect verdicts should score high, got {score}"
def test_all_wrong_scores_low(self):
verdicts = [
VerdictResult("ad_001", "approve", 0.9, "fraud"),
VerdictResult("ad_002", "reject", 0.9, "legit"),
VerdictResult("ad_003", "approve", 0.9, "fraud"),
]
record = _make_record(verdicts=verdicts, total_steps=3)
score = grade_episode(record)
assert score < 0.3, f"All wrong verdicts should score low, got {score}"
class TestTask2Grader:
def test_calibration_bonus(self):
well_calibrated = [
VerdictResult("ad_001", "reject", 0.9, "fraud"),
VerdictResult("ad_002", "approve", 0.9, "legit"),
VerdictResult("ad_003", "reject", 0.8, "fraud"),
VerdictResult("ad_004", "approve", 0.85, "legit"),
]
poorly_calibrated = [
VerdictResult("ad_001", "reject", 0.2, "fraud"),
VerdictResult("ad_002", "approve", 0.2, "legit"),
VerdictResult("ad_003", "reject", 0.2, "fraud"),
VerdictResult("ad_004", "approve", 0.2, "legit"),
]
r1 = _make_record(task_id="task_2", verdicts=well_calibrated, total_steps=4, action_budget=30)
r2 = _make_record(task_id="task_2", verdicts=poorly_calibrated, total_steps=4, action_budget=30)
s1 = grade_episode(r1)
s2 = grade_episode(r2)
assert s1 >= s2, f"Well calibrated ({s1}) should score >= poorly calibrated ({s2})"
class TestTask3Grader:
def test_network_link_bonus(self):
verdicts = [
VerdictResult("ad_001", "reject", 0.9, "fraud"),
VerdictResult("ad_002", "reject", 0.9, "fraud"),
VerdictResult("ad_003", "reject", 0.9, "fraud"),
]
links_correct = [
LinkResult("ad_001", "ad_002", True),
LinkResult("ad_002", "ad_003", True),
]
links_wrong = [
LinkResult("ad_001", "ad_002", False),
]
r1 = _make_record(
task_id="task_3", verdicts=verdicts, links=links_correct,
total_steps=5, action_budget=35, n_fraud_rings=1,
ring_sizes=[3],
)
r2 = _make_record(
task_id="task_3", verdicts=verdicts, links=links_wrong,
total_steps=4, action_budget=35, n_fraud_rings=1,
ring_sizes=[3],
)
s1 = grade_episode(r1)
s2 = grade_episode(r2)
assert s1 > s2, f"Correct links ({s1}) should score > wrong links ({s2})"
def test_graph_based_scoring(self):
"""Task 3 grader should use edge coverage from ground truth graph."""
verdicts = [
VerdictResult("ad_001", "reject", 0.9, "fraud"),
VerdictResult("ad_002", "reject", 0.9, "fraud"),
VerdictResult("ad_003", "reject", 0.9, "fraud"),
VerdictResult("ad_004", "reject", 0.9, "fraud"),
]
# 4 ads in a ring of 4 -> 6 ground truth edges
# Discover 3 of them
links = [
LinkResult("ad_001", "ad_002", True),
LinkResult("ad_002", "ad_003", True),
LinkResult("ad_003", "ad_004", True),
]
r = _make_record(
task_id="task_3", verdicts=verdicts, links=links,
total_steps=7, action_budget=35, n_fraud_rings=1,
ring_sizes=[4],
)
score = grade_episode(r)
assert 0.0 <= score <= 1.0
def test_false_links_penalized(self):
"""False link_accounts should reduce score."""
verdicts = [
VerdictResult("ad_001", "reject", 0.9, "fraud"),
VerdictResult("ad_002", "approve", 0.9, "legit"),
]
no_links = _make_record(
task_id="task_3", verdicts=verdicts, links=[],
total_steps=2, action_budget=35, n_fraud_rings=1,
ring_sizes=[3],
)
false_links = _make_record(
task_id="task_3", verdicts=verdicts,
links=[LinkResult("ad_001", "ad_002", False)],
total_steps=3, action_budget=35, n_fraud_rings=1,
ring_sizes=[3],
)
s_none = grade_episode(no_links)
s_false = grade_episode(false_links)
assert s_none >= s_false, (
f"No links ({s_none}) should score >= false links ({s_false})"
)
def test_coverage_bonus(self):
"""Agents that review more ads should get a coverage bonus."""
few_verdicts = [
VerdictResult("ad_001", "reject", 0.9, "fraud"),
]
many_verdicts = [
VerdictResult("ad_001", "reject", 0.9, "fraud"),
VerdictResult("ad_002", "approve", 0.9, "legit"),
VerdictResult("ad_003", "reject", 0.9, "fraud"),
VerdictResult("ad_004", "approve", 0.9, "legit"),
]
ads_meta = [
{"ad_id": "ad_001", "severity": 0.8, "ground_truth": "fraud"},
{"ad_id": "ad_002", "severity": 0.5, "ground_truth": "legit"},
{"ad_id": "ad_003", "severity": 0.8, "ground_truth": "fraud"},
{"ad_id": "ad_004", "severity": 0.5, "ground_truth": "legit"},
{"ad_id": "ad_005", "severity": 0.5, "ground_truth": "legit"},
]
r_few = _make_record(
task_id="task_3", verdicts=few_verdicts, total_steps=1,
action_budget=35, ads_metadata=ads_meta, ring_sizes=[3],
)
r_many = _make_record(
task_id="task_3", verdicts=many_verdicts, total_steps=4,
action_budget=35, ads_metadata=ads_meta, ring_sizes=[3],
)
s_few = grade_episode(r_few)
s_many = grade_episode(r_many)
assert s_many > s_few, (
f"More coverage ({s_many}) should score > less coverage ({s_few})"
)DockerfileAdded+50
README.md+273-12
__init__.pyAdded+29
baseline_scores.jsonAdded+27
client.pyAdded+84
convo_logging/task_1_conversation.mdAdded+666
convo_logging/task_2_conversation.mdAdded
convo_logging/task_3_conversation.mdAdded
data/__init__.pyAdded+18
data/ad_generator.pyAdded+561
data/advertiser_profiles.pyAdded+160
data/fraud_patterns.pyAdded+432
data/landing_pages.pyAdded+187
data/network_generator.pyAdded+194
graders/__init__.pyAdded+14
graders/base_grader.pyAdded+113
graders/task1_grader.pyAdded+49
graders/task2_grader.pyAdded+89
graders/task3_grader.pyAdded+133
inference.pyAdded+451
models.pyAdded+100
openenv.yamlAdded+7
openenv_ad_fraud_env.egg-info/PKG-INFOAdded+18
openenv_ad_fraud_env.egg-info/SOURCES.txtAdded+33
openenv_ad_fraud_env.egg-info/dependency_links.txtAdded+1
openenv_ad_fraud_env.egg-info/entry_points.txtAdded+2
openenv_ad_fraud_env.egg-info/requires.txtAdded+14
openenv_ad_fraud_env.egg-info/top_level.txtAdded+1
outputs/task_1_conversation.mdAdded+840
outputs/task_2_conversation.mdAdded+1251
outputs/task_3_conversation.mdAdded+1057
pyproject.tomlAdded+44
server/__init__.pyAdded+1
server/app.pyAdded+113
server/environment.pyAdded+559
server/requirements.txtAdded+9
tests/__init__.pyAdded
tests/test_data_generation.pyAdded+141
tests/test_environment.pyAdded+178
tests/test_graders.pyAdded+203
uv.lockAdded