Spaces:
Running
Running
sync ui + env files
Browse files- oversight_environment.py +3 -21
oversight_environment.py
CHANGED
|
@@ -1,22 +1,7 @@
|
|
| 1 |
"""
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
An Oversight Agent receives a batch of completed AP Clerk episodes and must:
|
| 6 |
-
1. Review each episode summary (invoice, decision, amount, explanation)
|
| 7 |
-
2. Identify which episodes contain suspicious/incorrect decisions
|
| 8 |
-
3. Recommend: CLEAR | FLAG_FOR_REVIEW | ESCALATE_TO_AUDIT
|
| 9 |
-
4. Provide a specific signal (numeric citation) explaining why
|
| 10 |
-
|
| 11 |
-
The ground-truth fraud labels are hidden from the agent during inference
|
| 12 |
-
but used to compute rewards.
|
| 13 |
-
|
| 14 |
-
Episode flow:
|
| 15 |
-
obs = env.reset(seed=None, num_episodes=5)
|
| 16 |
-
for each episode in obs.episode_summaries:
|
| 17 |
-
action = OversightAction(episode_id=..., verdict=..., signal=..., confidence=...)
|
| 18 |
-
obs, reward, done, info = env.step(action)
|
| 19 |
-
# done=True after all episodes reviewed OR if agent submits FINISH
|
| 20 |
"""
|
| 21 |
|
| 22 |
from __future__ import annotations
|
|
@@ -230,7 +215,6 @@ class OversightEnvironment(_OpenEnvBase):
|
|
| 230 |
self._episode_scores = []
|
| 231 |
self._done = False
|
| 232 |
|
| 233 |
-
# Decide how many fraudulent episodes to inject (1-2 out of num_episodes)
|
| 234 |
num_fraud = rng.randint(1, min(2, num_episodes - 1))
|
| 235 |
fraud_indices = rng.sample(range(num_episodes), num_fraud)
|
| 236 |
|
|
@@ -256,7 +240,6 @@ class OversightEnvironment(_OpenEnvBase):
|
|
| 256 |
ep.is_fraudulent = False
|
| 257 |
ep.fraud_type = None
|
| 258 |
|
| 259 |
-
# Select 2 hint patterns from pool
|
| 260 |
hint_count = min(2, len(_FRAUD_PATTERNS))
|
| 261 |
hints = rng.sample(_FRAUD_PATTERNS, hint_count)
|
| 262 |
|
|
@@ -292,7 +275,6 @@ class OversightEnvironment(_OpenEnvBase):
|
|
| 292 |
score, breakdown, fb = self._grade_verdict(action, is_fraud, flagged, fraud_type)
|
| 293 |
self._episode_scores.append(score)
|
| 294 |
|
| 295 |
-
# Update observation
|
| 296 |
self._observation.step_count += 1
|
| 297 |
self._observation.action_history.append({
|
| 298 |
"step": self._observation.step_count,
|
|
|
|
| 1 |
"""
|
| 2 |
+
Fleet AI Oversight Environment — agent reviews a batch of AP Clerk episodes and
|
| 3 |
+
identifies fraud (CLEAR | FLAG_FOR_REVIEW | ESCALATE_TO_AUDIT). Ground-truth fraud
|
| 4 |
+
labels are hidden during inference; false positives carry a real −0.25 penalty.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
"""
|
| 6 |
|
| 7 |
from __future__ import annotations
|
|
|
|
| 215 |
self._episode_scores = []
|
| 216 |
self._done = False
|
| 217 |
|
|
|
|
| 218 |
num_fraud = rng.randint(1, min(2, num_episodes - 1))
|
| 219 |
fraud_indices = rng.sample(range(num_episodes), num_fraud)
|
| 220 |
|
|
|
|
| 240 |
ep.is_fraudulent = False
|
| 241 |
ep.fraud_type = None
|
| 242 |
|
|
|
|
| 243 |
hint_count = min(2, len(_FRAUD_PATTERNS))
|
| 244 |
hints = rng.sample(_FRAUD_PATTERNS, hint_count)
|
| 245 |
|
|
|
|
| 275 |
score, breakdown, fb = self._grade_verdict(action, is_fraud, flagged, fraud_type)
|
| 276 |
self._episode_scores.append(score)
|
| 277 |
|
|
|
|
| 278 |
self._observation.step_count += 1
|
| 279 |
self._observation.action_history.append({
|
| 280 |
"step": self._observation.step_count,
|