DataBoySu commited on
Commit Β·
acfb96b
1
Parent(s): dfd1faa
readme
Browse files1234567891011121314151617181920212223242526272829BSD 3-Clause License
Copyright (c) 2024-present, OpenEnv ContributorsAll rights reserved.
Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THEIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AREDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLEFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIALDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ORSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVERCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USEOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.10 unmodified lines1112131415161763 unmodified lines81828384858687888990914 unmodified lines969798991001011029 unmodified lines11211311411511611711828 unmodified lines1471481491501511521533 unmodified lines15715815916016116216311 unmodified lines17517617717817918018118218318418518618718818913 unmodified lines20320420520620720820921021121221321421521621721821922022122222322422522622722822923046 unmodified lines27727827928028128210 unmodified lines<div align="center"># π΅οΈ AML Investigator OpenEnv RL Environment**A financial crime investigation environment for training and evaluating LLM agents**63 unmodified lines```mermaidsequenceDiagramparticipant A as Agentparticipant E as Environmentparticipant D as Data LayerE-->>A: reset() -> AmlObservation<br/>(alert_details, budget=N)loop Until submit_decision or budget=0A->>E: step(AmlAction)4 unmodified linesA->>E: step(submit_decision, evidence=[...])E->>E: Run GraderE-->>A: AmlObservation<br/>(done=True, reward=0.0-1.0)```---9 unmodified lines| `get_kyc_record` | `entity_id` | Retrieve address, entity type, and corporate directors. || `submit_decision` | `decision: FRAUD\|CLEAR`, `evidence_links: List[str]` | Terminal action. Ends the episode and triggers the grader. |> **Why Pydantic?** The LLM is the router. Strict schemas with `Field(description="...")` mean the model reads the tool contract, not a prompt full of prose instructions. Malformed output is caught at validation, not execution, preventing silent failures and hallucinated account IDs from crashing the environment.---28 unmodified lines```mermaidflowchart LRA([Alert:<br/>ACC-101 to ACC-909<br/>$50,000]) --> Bsubgraph InvestigationB[query_transactions<br/>ACC-101] --> C{Memo:<br/>'Heavy Machinery<br/>Purchase - Unit 4'}3 unmodified linesF --> G{50 inbound payments<br/>from global firms}endG --> H([submit_decision<br/>CLEAR])style A fill:#ef4444,color:#fffstyle H fill:#22c55e,color:#fff11 unmodified lines```mermaidflowchart TDA([Alert:<br/>ACC-200 deposit velocity spike]) --> Bsubgraph Investigation["Paginate -> Spot -> Cross-Reference"]B[query_transactions<br/>ACC-200<br/>offset 0, 10, 20...] --> C{14 deposits<br/>$9,900 and $9,500<br/>below $10k threshold}C --> D[get_kyc_record<br/>ACC-301, ACC-302, ACC-303]D --> E{All 3 accounts:<br/>Opened same day<br/>Occupation: Student}endE --> F([submit_decision<br/>FRAUD<br/>evidence: ACC-301, ACC-302, ACC-303])style A fill:#f97316,color:#fffstyle F fill:#dc2626,color:#fff13 unmodified lines```mermaidflowchart TDA([Alert:<br/>ACC-500 to ACC-700<br/>$2.5M]) --> Bsubgraph Trap["The Bait - Do Not Take It"]X["$100 transfer<br/>to Watchlist Target"]endsubgraph Investigation["The Real Loop"]B --> C["search_transactions<br/>ACC-700<br/>keyword: 'consulting'"]C --> D{48hrs later:<br/>ACC-700 to ACC-888<br/>$2.4M offshore}D --> E[get_kyc_record<br/>ACC-888]E --> F{Director:<br/>Robert House}F --> G[get_kyc_record<br/>ACC-500]G --> H{Director:<br/>Apex Management Corp}H --> I[get_kyc_record<br/>Apex Management Corp]I --> J{CEO:<br/>Robert House same person}endA -.->|naive agent wastes budget| XJ --> K([submit_decision<br/>FRAUD<br/>evidence: ACC-500, ACC-700, ACC-888])style A fill:#ef4444,color:#fffstyle X fill:#6b7280,color:#fff,stroke-dasharray: 5 5style K fill:#dc2626,color:#fffstyle J fill:#fbbf24,color:#000```46 unmodified lines---## Core Engineering PrinciplesThese principles govern how the environment is designed and why each decision was made.10 unmodified lines1112131415161763 unmodified lines81828384858687888990914 unmodified lines969798991001011029 unmodified lines11211311411511611711828 unmodified lines1471481491501511521533 unmodified lines15715815916016116216311 unmodified lines17517617717817918018118218318418518618718818913 unmodified lines20320420520620720820921021121221321421521621721821922022122222322422522622722822923023146 unmodified lines27827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436510 unmodified lines<div align="center"># π΅οΈ AML Investigator β OpenEnv RL Environment**A financial crime investigation environment for training and evaluating LLM agents**63 unmodified lines```mermaidsequenceDiagramparticipant A as π€ Agentparticipant E as βοΈ Environmentparticipant D as ποΈ Data LayerE-->>A: reset() β AmlObservation<br/>(alert_details, budget=N)loop Until submit_decision or budget=0A->>E: step(AmlAction)4 unmodified linesA->>E: step(submit_decision, evidence=[...])E->>E: Run GraderE-->>A: AmlObservation<br/>(done=True, reward=0.0β1.0)```---9 unmodified lines| `get_kyc_record` | `entity_id` | Retrieve address, entity type, and corporate directors. || `submit_decision` | `decision: FRAUD\|CLEAR`, `evidence_links: List[str]` | Terminal action. Ends the episode and triggers the grader. |> **Why Pydantic?** The LLM is the router. Strict schemas with `Field(description="...")` mean the model reads the tool contract, not a prompt full of prose instructions. Malformed output is caught at validation, not execution β preventing silent failures and hallucinated account IDs from crashing the environment.---28 unmodified lines```mermaidflowchart LRA([π¨ Alert:<br/>ACC-101 β ACC-909<br/>$50,000]) --> Bsubgraph InvestigationB[query_transactions<br/>ACC-101] --> C{Memo:<br/>'Heavy Machinery<br/>Purchase - Unit 4'}3 unmodified linesF --> G{50 inbound payments<br/>from global firms}endG --> H([β submit_decision<br/>CLEAR])style A fill:#ef4444,color:#fffstyle H fill:#22c55e,color:#fff11 unmodified lines```mermaidflowchart TDA([π¨ Alert:<br/>ACC-200 deposit velocity spike]) --> Bsubgraph Investigation["Paginate β Spot β Cross-Reference"]B[query_transactions<br/>ACC-200<br/>offset 0, 10, 20...] --> C{14 deposits<br/>$9,900 and $9,500<br/>below $10k threshold}C --> D[get_kyc_record<br/>ACC-301, ACC-302, ACC-303]D --> E{All 3 accounts:<br/>Opened same day<br/>Occupation: Student}endE --> F([π¨ submit_decision<br/>FRAUD<br/>evidence: ACC-301, ACC-302, ACC-303])style A fill:#f97316,color:#fffstyle F fill:#dc2626,color:#fff13 unmodified lines```mermaidflowchart TDA([π¨ Alert:<br/>ACC-500 β ACC-700<br/>$2.5M]) --> Bsubgraph Trap["β The Bait β Don't Take It"]X["$100 transfer<br/>to 'Watchlist Target'"]endsubgraph Investigation["The Real Loop"]B --> C["search_transactions<br/>ACC-700<br/>keyword: 'consulting'"]C --> D{48hrs later:<br/>ACC-700 β ACC-888<br/>$2.4M offshore}D --> E[get_kyc_record<br/>ACC-888]E --> F{Director:<br/>Robert House}F --> G[get_kyc_record<br/>ACC-500]G --> H{Director:<br/>Apex Management Corp}H --> I[get_kyc_record<br/>Apex Management Corp]I --> J{CEO:<br/>Robert House β same person}endA -.->|naive agent wastes budget| XJ --> K([π¨ submit_decision<br/>FRAUD<br/>evidence: ACC-500, ACC-700, ACC-888])style A fill:#ef4444,color:#fffstyle X fill:#6b7280,color:#fff,stroke-dasharray: 5 5style Trap fill:#1f2937,color:#9ca3afstyle K fill:#dc2626,color:#fffstyle J fill:#fbbf24,color:#000```46 unmodified lines---## Baseline Results> **Model:** `openai/gpt-oss-20b` Β· **CoT:** enabled Β· **Run:** single pass, no fine-tuning| Task | Steps Used | Budget | Grader Score | Net Reward | Verdict | Result ||---|---|---|---|---|---|---|| `aml_easy` | 3 / 5 | 2 remaining | 0.75 | **+0.69** | `CLEAR` β | β Pass || `aml_medium` | 6 / 12 | 6 remaining | 0.75 | **+0.63** | `FRAUD` β | β Pass || `aml_hard` | 16 / 20 | 0 remaining | 0.00 | **β0.32** | none | β Fail |Net reward = grader score β (steps Γ 0.02)### Per-Task Analysis**`aml_easy` β Pass (0.75 / 1.0)**The agent navigated the task in the minimum viable number of steps: one transaction query, one KYC lookup, then `CLEAR`. It correctly ignored the high-risk jurisdiction flag after reading the memo. The score stopped at `0.75` rather than `1.0` because `evidence_links` was submitted empty β the grader expects at least the cleared account ID as documented evidence of the reasoning chain.```[STEP] query_transactions ACC-9001[STEP] get_kyc_record ENT-9001[STEP] submit_decision CLEAR evidence=[] β missing evidence β capped at 0.75```**`aml_medium` β Pass (0.75 / 1.0)**The agent identified structuring activity and correctly returned a `FRAUD` verdict, but submitted only one of the three smurf accounts (`ACC-9010`) in evidence. The grader applies partial credit proportional to smurf accounts found β `1/3` identified yields `0.75`. The agent also issued a `search_transactions` call with keyword `"Invoice"` which was not relevant to the structuring pattern, suggesting mild reasoning noise before it converged on the correct account.```[STEP] query_transactions ACC-9010 (offset 0)[STEP] query_transactions ACC-9011 (offset 0)[STEP] get_kyc_record ENT-9010[STEP] search_transactions ACC-9010 keyword="Invoice" β off-path call[STEP] get_kyc_record ENT-0159[STEP] submit_decision FRAUD evidence=["ACC-9010"] β found 1/3 smurfs β 0.75```**`aml_hard` β Fail (0.00)**The model completed two valid steps (paginating `ACC-9021` at offset 0 and 10), then entered a catastrophic failure loop. From step 3 onward, the model produced empty or non-JSON output on every turn, triggering the recovery action, which defaulted to `query_transactions(ACC-9021, offset=0)` β the same call, 14 times in a row. The budget was exhausted without a `submit_decision` ever being issued.```[STEP] query_transactions ACC-9021 offset=0 β valid[STEP] query_transactions ACC-9021 offset=10 β valid[DEBUG] Non-JSON/invalid model action Γ 14 β context collapse[END] score=0.00 budget exhausted```The root cause is context window pressure. By step 2, the sliding window already contained two large paginated transaction payloads.### Failure Mode Summary```mermaidflowchart LRA[Step 2: Two large<br/>transaction payloads<br/>in context] --> B[Model outputs<br/>prose instead of JSON]B --> C[Recovery action:<br/>query_transactions<br/>offset=0]C --> D[Same large payload<br/>re-injected into context]D --> BD --> E{Budget = 0}E --> F([score = 0.00])style B fill:#ef4444,color:#fffstyle F fill:#7f1d1d,color:#fff```### What This Tells UsThe tasks are correctly difficulty-stratified.The easy and medium tasks are solvable by an instruction-following model with chain-of-thought, but not perfectly β both runs left score on the table due to incomplete evidence submission.The hard task exposes a genuine capability gap: multi-hop KYC cross-referencing under token pressure requires either a larger model, a tighter context compaction strategy, or both.The `[DEBUG] Non-JSON/invalid model action` recovery path is functioning as designed β the environment did not crash, and each recovery action was logged and penalized correctly.| Failure Mode | Observed In | Environment Response ||---|---|---|| Empty `evidence_links` on correct verdict | Easy, Medium | Grader caps score; no crash || Off-path tool calls | Medium | Step penalty applied; agent self-corrects || Context collapse β non-JSON output | Hard | Recovery action fired; logged as `[DEBUG]` || Recovery loop exhausts budget | Hard | Episode terminates cleanly; score `0.00` |---## Core Engineering PrinciplesThese principles govern how the environment is designed and why each decision was made.
LICENSEAdded+29
README.md+101-18