File size: 2,312 Bytes
26bf1c9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
"""

CounterFeint — Multi-Agent Ad Fraud Investigation Environment for OpenEnv.



Round 2 introduces a three-agent FraudArena:



    Fraudster     proposes / mutates ads to sneak past review

    Investigator  investigates ads and renders verdicts

    Auditor       audits the trace post-hoc for miscalibration or gibberish



All three agents share one environment instance per match and interact via

WebSockets on role-specific routes (/ws/fraudster, /ws/investigator, /ws/auditor).



Example (three-agent):



    >>> from counterfeint import MatchClient, FraudsterAction

    >>> import asyncio

    >>> async def demo():

    ...     async with MatchClient("http://localhost:8000") as match:

    ...         await match.reset(seed=42, task_id="task_1")

    ...         await match.fraudster.step(FraudsterAction(

    ...             action_type="propose_ad",

    ...             ad_copy="Free iPhone - tap here!",

    ...             category="fake_giveaway",

    ...         ))

    ...         state = await match.state()

    ...         print(state.phase, state.grader_score)

    >>> asyncio.run(demo())



Example (single-agent legacy):



    >>> from counterfeint import AdFraudEnv, AdReviewAction

    >>> with AdFraudEnv(base_url="http://localhost:8000").sync() as env:

    ...     env.reset(seed=42, task_id="task_1")

"""

from .client import (
    AdFraudEnv,
    AuditorClient,
    FraudsterClient,
    InvestigatorClient,
    MatchClient,
    MultiAgentProtocolError,
)
from .models import (
    AdFraudState,
    AdReviewAction,
    AdReviewObservation,
    AuditFlag,
    AuditorAction,
    AuditorObservation,
    AuditReport,
    FraudsterAction,
    FraudsterObservation,
    InvestigatorAction,
    InvestigatorObservation,
    InvestigatorState,
    RefereeState,
)

__all__ = [
    "AdFraudEnv",
    "AdFraudState",
    "AdReviewAction",
    "AdReviewObservation",
    "AuditFlag",
    "AuditorAction",
    "AuditorClient",
    "AuditorObservation",
    "AuditReport",
    "FraudsterAction",
    "FraudsterClient",
    "FraudsterObservation",
    "InvestigatorAction",
    "InvestigatorClient",
    "InvestigatorObservation",
    "InvestigatorState",
    "MatchClient",
    "MultiAgentProtocolError",
    "RefereeState",
]