AgentOps gives you full observability into your AI agent sessions. Pair it with Purple Flea and every financial operation — every trade opened, every coin flipped, every swap executed — is traced, recorded, and dashboarded in real time.
AgentOps is an open-source observability and analytics platform built specifically for autonomous AI agents. It records every LLM call, tool invocation, and session event into a structured timeline you can replay, filter, and alert on.
Every agent run is recorded as a structured session. Step through each tool call, LLM response, and state change in chronological order.
See exactly how long each API call takes. Identify slow Purple Flea operations, model latency spikes, and retry storms before they compound.
Aggregate data across sessions into P&L charts, win-rate trends, position exposure, and referral earnings — all in the AgentOps UI.
Generic agent monitoring was designed for chatbots. When your agent is managing real money — opening leveraged positions, placing casino bets, executing swaps — you need domain-specific visibility into outcomes, not just latency.
Know exactly how much each agent session made or lost across trading, casino, and swaps. Correlate profitability with model choice, prompt version, and strategy.
Set AgentOps alerts to fire when your agent's open position exposure crosses a threshold or when margin falls below a safe level. Get notified before the liquidation hits.
Review every bet in a session: amount wagered, outcome, running bankroll, Kelly sizing adherence. Identify when agents deviate from strategy.
See how much referral income each session generated across all six Purple Flea products. Understand which agent workloads are most profitable to run.
Install both packages, initialize AgentOps before any Purple Flea calls, and all API operations are automatically captured in your AgentOps session timeline.
pip install agentops purpleflea
import agentops import requests # Initialize AgentOps — must happen before any Purple Flea calls agentops.init("YOUR_AGENTOPS_KEY") PURPLEFLEA_KEY = "sk_live_..." BASE = "https://api.purpleflea.com" # Purple Flea operations are automatically traced as tool events from purpleflea import Casino, Trading casino = Casino("sk_live_...") result = casino.flip(amount=10.0, side="heads") # agentops records: tool_call=casino_flip, result=won, payout=19.60 trading = Trading("sk_live_...") position = trading.open(market="ETH-PERP", side="long", size=100.0, leverage=3) # agentops records: tool_call=trading_open, market=ETH-PERP, size=100, leverage=3x # End session — uploads all traces and finalises the session timeline agentops.end_session("Success")
Or use with any framework — AgentOps wraps at the HTTP level:
import agentops import requests agentops.init("YOUR_AGENTOPS_KEY") # Wrap each Purple Flea call in an ActionEvent for full tracing with agentops.record_action("casino_flip"): result = requests.post( "https://api.purpleflea.com/api/v1/flip", headers={"Authorization": "Bearer sk_live_..."}, json={"amount": 25.0, "side": "heads"}, ).json() # result is automatically attached to the trace span # visible in AgentOps dashboard under this session
AgentOps captures all of the following from Purple Flea API calls with zero manual instrumentation. Every event is timestamped, queryable, and visible in the session replay timeline.
Each Purple Flea HTTP request is traced as a tool span: endpoint, HTTP method, status code, response time in ms. Identify slow calls and retry patterns at a glance.
Casino flips, dice rolls, and crash games are recorded with wager amount, outcome (won/lost), payout multiplier, and running session bankroll.
Every perpetual futures position records the open price, close price, size, leverage, and realized P&L. Full trade lifecycle is visible in one span.
DEX swaps log the token pair, input amount, output amount, slippage incurred, and the DEX route selected. Identify high-slippage conditions your agent should avoid.
Commissions earned during the session are captured as a custom metric: product breakdown (casino/trading/swaps/domains) and cumulative total for the run.
Use agentops.record() to emit structured events for higher-level concepts
like casino sessions, trading strategies, and referral summaries.
These become filterable dimensions in your AgentOps dashboard.
Casino session summary
agentops.record(agentops.ActionEvent(
action_type="casino_session",
params={
"starting_bankroll": 100.0,
"session_bets": 50,
"strategy": "kelly_criterion",
"game": "coin_flip",
},
returns={
"ending_bankroll": 112.5,
"roi": "12.5%",
"win_rate": "54%",
"max_drawdown": "8.2%",
}
))
Trading strategy summary
agentops.record(agentops.ActionEvent(
action_type="trading_session",
params={
"strategy": "momentum",
"markets": ["ETH-PERP", "BTC-PERP"],
"max_leverage": 5,
"risk_per_trade": "2%",
},
returns={
"realized_pnl": "+42.30 USDC",
"positions_opened": 8,
"win_rate": "62.5%",
"sharpe_ratio": "1.87",
}
))
Referral income event
# Record referral earnings at the end of every agent session agentops.record(agentops.ActionEvent( action_type="referral_earnings", params={ "referral_code": "REF_MYAGENT", "session_id": agentops.get_session_id(), }, returns={ "casino_commission": "0.84 USDC", # 10% of house edge "trading_commission": "3.20 USDC", # 20% of trading fees "swap_commission": "0.17 USDC", # 10% of swap fees "domain_commission": "0.00 USDC", # 15% of domain fees "total_earned": "4.21 USDC", } ))
AgentOps surfaces these key metrics automatically once Purple Flea events start flowing. Use them to compare agent strategies, model choices, and prompt versions against real financial outcomes.
Chart cumulative realized P&L across all trading sessions. Break down by market (ETH-PERP, BTC-PERP) and strategy tag. Identify which agent configurations are profitable.
Track win rate per game type over rolling windows. Spot variance-driven streaks vs. genuine edge. Compare Kelly-sized sessions against flat-bet sessions.
See referral earnings grow as your agent's activity scales. Break down by product (casino vs. trading vs. swaps vs. domains) to understand your income composition.
Real-time view of total notional value across all open perpetual positions, leverage levels, and unrealized P&L. Feed this into AgentOps alerts for liquidation risk monitoring.
Set up AgentOps event-based alerts that fire on Purple Flea conditions. Know before your agent hits a liquidation, exhausts a bankroll, or misses a referral income target.
Fires when open position notional exceeds a configurable multiple of available margin. Gives your agent or operator time to reduce exposure before forced liquidation.
Fires when wallet balance on any chain drops below a set floor. Prevents your agent from attempting trades or bets it cannot fund, avoiding failed transaction fees.
Fires when session P&L drawdown from peak exceeds a percentage threshold. Useful for halting casino sessions or trading loops that are underperforming their expected edge.
import agentops import requests agentops.init("YOUR_AGENTOPS_KEY") PURPLEFLEA_KEY = "sk_live_..." BASE = "https://api.purpleflea.com" BALANCE_FLOOR = 50.0 # USDC DRAWDOWN_LIMIT = 0.20 # 20% starting_balance = None def check_and_alert(): global starting_balance bal = requests.get(f"{BASE}/api/v1/wallet/balance", headers={"Authorization": f"Bearer {PURPLEFLEA_KEY}"}).json() usdc = bal.get("USDC", 0) if starting_balance is None: starting_balance = usdc # Alert: balance below floor if usdc < BALANCE_FLOOR: agentops.record(agentops.ErrorEvent( error_type="balance_below_floor", details={"balance": usdc, "floor": BALANCE_FLOOR}, )) return False # caller should halt agent # Alert: drawdown limit breached drawdown = (starting_balance - usdc) / starting_balance if drawdown > DRAWDOWN_LIMIT: agentops.record(agentops.ErrorEvent( error_type="drawdown_limit_breached", details={"drawdown_pct": f"{drawdown*100:.1f}%"}, )) return False return True # safe to continue # Call check_and_alert() before every bet or position if check_and_alert(): # place bet / open position ...
Free tier on both AgentOps and Purple Flea. No KYC. Full observability from day one.