Spaces:
Sleeping
Sleeping
Commit ·
22262fe
0
Parent(s):
hackathon finalist submission
Browse files- .gitignore +1 -0
- Dockerfile +14 -0
- README.md +60 -0
- app.py +179 -0
- inference.py +120 -0
- openenv.yaml +17 -0
- requirements.txt +6 -0
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
__pycache__/
|
Dockerfile
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
| 2 |
+
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
|
| 5 |
+
COPY requirements.txt .
|
| 6 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 7 |
+
|
| 8 |
+
COPY . .
|
| 9 |
+
|
| 10 |
+
# Expose port for FastAPI
|
| 11 |
+
EXPOSE 8000
|
| 12 |
+
|
| 13 |
+
# Run the OpenEnv server
|
| 14 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
|
README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# OpenEnv SRE Bug Triage Benchmark
|
| 2 |
+
|
| 3 |
+
## Motivation
|
| 4 |
+
This environment models a **production-grade engineering and support workflow**. Teams spend countless hours reading vague bug reports, matching them to stack traces, assessing priority, and routing them to the correct group. This interactive environment evaluates whether LLM agents can act like real Site Reliability Engineers (SREs), using **tools** to deduce root causes before making final resolutions.
|
| 5 |
+
|
| 6 |
+
## Environment Design (The "WOW" Factor)
|
| 7 |
+
Unlike simple text classification environments, the **SRE Bug Triage Benchmark** forces the agent into an iterative ReAct pattern where they must actively query pseudo-systems to uncover full state context.
|
| 8 |
+
|
| 9 |
+
### The Observation Space
|
| 10 |
+
Agents receive strongly-typed JSON representing the current state:
|
| 11 |
+
```json
|
| 12 |
+
{
|
| 13 |
+
"ticket_description": "User reported slow performance during checkout.",
|
| 14 |
+
"command_result": "Logs for database: OutOfMemory errors detected in pgsql pool",
|
| 15 |
+
"step_count": 2
|
| 16 |
+
}
|
| 17 |
+
```
|
| 18 |
+
|
| 19 |
+
### The Action Space
|
| 20 |
+
Agents must output strict JSON commanding the environment:
|
| 21 |
+
```json
|
| 22 |
+
{
|
| 23 |
+
"command": "search_logs",
|
| 24 |
+
"command_args": {"service": "database"}
|
| 25 |
+
}
|
| 26 |
+
```
|
| 27 |
+
Supported commands:
|
| 28 |
+
- `search_logs`
|
| 29 |
+
- `query_metrics`
|
| 30 |
+
- `resolve_ticket`
|
| 31 |
+
|
| 32 |
+
## Progressive Task Breakdown
|
| 33 |
+
There are 3 tasks designed to test varying difficulties and tool horizons:
|
| 34 |
+
- **Task 1 (Easy)**: Severity assessment directly from the ticket description.
|
| 35 |
+
- **Task 2 (Medium - Log Investigation)**: The agent receives a vague ticket. It must invoke `search_logs` to uncover hidden errors, then `resolve_ticket`. Partial rewards are awarded for searching the right log!
|
| 36 |
+
- **Task 3 (Hard - Escalation & Metrics)**: The agent must correlate metrics and logs across different services to find hidden latency sources and map it to the right on-call team.
|
| 37 |
+
|
| 38 |
+
## Baseline Results
|
| 39 |
+
| Task | Difficulty | Expected Baseline Score |
|
| 40 |
+
| ---- | ---------- | ----------------------------- |
|
| 41 |
+
| 1 | Easy | 1.0 |
|
| 42 |
+
| 2 | Medium | 0.8 |
|
| 43 |
+
| 3 | Hard | 0.6 |
|
| 44 |
+
|
| 45 |
+
## Execution Instructions
|
| 46 |
+
|
| 47 |
+
Run the OpenEnv server:
|
| 48 |
+
```bash
|
| 49 |
+
docker build -t openenv-triage .
|
| 50 |
+
docker run -p 8000:8000 openenv-triage
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
Run the baseline agent:
|
| 54 |
+
```bash
|
| 55 |
+
pip install -r requirements.txt
|
| 56 |
+
export API_BASE_URL="https://api.openai.com/v1"
|
| 57 |
+
export MODEL_NAME="gpt-4o-mini"
|
| 58 |
+
export HF_TOKEN="your_token_here"
|
| 59 |
+
python inference.py
|
| 60 |
+
```
|
app.py
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI, HTTPException
|
| 2 |
+
from pydantic import BaseModel, Field
|
| 3 |
+
from typing import Any, Dict, Optional, Literal
|
| 4 |
+
import random
|
| 5 |
+
|
| 6 |
+
app = FastAPI(title="Bug Triage SRE Environment")
|
| 7 |
+
|
| 8 |
+
class BugTriageAction(BaseModel):
|
| 9 |
+
command: str = Field(
|
| 10 |
+
description="The action to perform in the environment."
|
| 11 |
+
)
|
| 12 |
+
command_args: Dict[str, Any] = Field(
|
| 13 |
+
description="Arguments for the chosen command. "
|
| 14 |
+
"For 'search_logs': {'service': str}, "
|
| 15 |
+
"For 'query_metrics': {'metric': str}, "
|
| 16 |
+
"For 'resolve_ticket': {'severity': str, 'root_cause': str, 'escalation': str}"
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
class BugTriageObservation(BaseModel):
|
| 20 |
+
ticket_description: str
|
| 21 |
+
command_result: Optional[str] = None
|
| 22 |
+
step_count: int
|
| 23 |
+
|
| 24 |
+
class ResetRequest(BaseModel):
|
| 25 |
+
task_id: int
|
| 26 |
+
|
| 27 |
+
class StepRequest(BaseModel):
|
| 28 |
+
action: BugTriageAction
|
| 29 |
+
|
| 30 |
+
class ActionResponse(BaseModel):
|
| 31 |
+
observation: BugTriageObservation
|
| 32 |
+
reward: float
|
| 33 |
+
done: bool
|
| 34 |
+
info: Dict[str, Any]
|
| 35 |
+
|
| 36 |
+
session_state = {
|
| 37 |
+
"task_id": 1,
|
| 38 |
+
"step_count": 0,
|
| 39 |
+
"ground_truth": {},
|
| 40 |
+
"logs_queried": False,
|
| 41 |
+
"metrics_queried": False
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
EASY_TICKETS = [
|
| 45 |
+
{"desc": "The login button is completely broken and nobody can access the app.", "gt": {"severity": "critical"}}
|
| 46 |
+
]
|
| 47 |
+
MEDIUM_TICKETS = [
|
| 48 |
+
{
|
| 49 |
+
"desc": "User reported slow performance during checkout.",
|
| 50 |
+
"logs": {"database": "OutOfMemory errors detected in pgsql pool", "frontend": "No errors"},
|
| 51 |
+
"gt": {"severity": "high", "root_cause": "database"}
|
| 52 |
+
}
|
| 53 |
+
]
|
| 54 |
+
HARD_TICKETS = [
|
| 55 |
+
{
|
| 56 |
+
"desc": "Intermittent failure when payment gateway is used.",
|
| 57 |
+
"logs": {"payment": "Timeout connecting to Stripe API 504", "database": "All queries successful"},
|
| 58 |
+
"metrics": {"payment_latency": "p99 10000ms", "cpu": "30%"},
|
| 59 |
+
"gt": {"severity": "high", "root_cause": "payment", "escalation": "billing_team"}
|
| 60 |
+
}
|
| 61 |
+
]
|
| 62 |
+
|
| 63 |
+
@app.get("/")
|
| 64 |
+
def health_check():
|
| 65 |
+
return {"status": "ok"}
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
@app.post("/reset", response_model=ActionResponse)
|
| 69 |
+
def reset(req: ResetRequest):
|
| 70 |
+
session_state["task_id"] = req.task_id
|
| 71 |
+
session_state["step_count"] = 0
|
| 72 |
+
session_state["logs_queried"] = False
|
| 73 |
+
session_state["metrics_queried"] = False
|
| 74 |
+
|
| 75 |
+
if req.task_id == 1:
|
| 76 |
+
ticket = random.choice(EASY_TICKETS)
|
| 77 |
+
elif req.task_id == 2:
|
| 78 |
+
ticket = random.choice(MEDIUM_TICKETS)
|
| 79 |
+
elif req.task_id == 3:
|
| 80 |
+
ticket = random.choice(HARD_TICKETS)
|
| 81 |
+
else:
|
| 82 |
+
raise HTTPException(status_code=400, detail="Invalid task ID")
|
| 83 |
+
|
| 84 |
+
session_state["ground_truth"] = ticket
|
| 85 |
+
|
| 86 |
+
obs = BugTriageObservation(
|
| 87 |
+
ticket_description=ticket["desc"],
|
| 88 |
+
command_result="Environment initialized. Type a command to proceed.",
|
| 89 |
+
step_count=0
|
| 90 |
+
)
|
| 91 |
+
|
| 92 |
+
return ActionResponse(
|
| 93 |
+
observation=obs,
|
| 94 |
+
reward=0.0,
|
| 95 |
+
done=False,
|
| 96 |
+
info={"message": "Environment reset successfully"}
|
| 97 |
+
)
|
| 98 |
+
|
| 99 |
+
@app.post("/step", response_model=ActionResponse)
|
| 100 |
+
def step(req: StepRequest):
|
| 101 |
+
session_state["step_count"] += 1
|
| 102 |
+
action = req.action
|
| 103 |
+
|
| 104 |
+
reward = 0.0
|
| 105 |
+
done = False
|
| 106 |
+
cmd_result = ""
|
| 107 |
+
|
| 108 |
+
task_id = session_state["task_id"]
|
| 109 |
+
gt_full = session_state["ground_truth"]
|
| 110 |
+
gt = gt_full.get("gt", {})
|
| 111 |
+
|
| 112 |
+
if action.command == "search_logs":
|
| 113 |
+
service = action.command_args.get("service")
|
| 114 |
+
if "logs" in gt_full and service in gt_full["logs"]:
|
| 115 |
+
cmd_result = f"Logs for {service}: {gt_full['logs'][service]}"
|
| 116 |
+
if not session_state["logs_queried"]:
|
| 117 |
+
reward += 0.2
|
| 118 |
+
session_state["logs_queried"] = True
|
| 119 |
+
else:
|
| 120 |
+
cmd_result = f"No logs found for service '{service}'."
|
| 121 |
+
|
| 122 |
+
elif action.command == "query_metrics":
|
| 123 |
+
metric = action.command_args.get("metric")
|
| 124 |
+
if "metrics" in gt_full and metric in gt_full["metrics"]:
|
| 125 |
+
cmd_result = f"Metrics for {metric}: {gt_full['metrics'][metric]}"
|
| 126 |
+
if not session_state["metrics_queried"]:
|
| 127 |
+
reward += 0.2
|
| 128 |
+
session_state["metrics_queried"] = True
|
| 129 |
+
else:
|
| 130 |
+
cmd_result = f"Metric '{metric}' not found."
|
| 131 |
+
|
| 132 |
+
elif action.command == "resolve_ticket":
|
| 133 |
+
sev = action.command_args.get("severity", "")
|
| 134 |
+
root = action.command_args.get("root_cause", "")
|
| 135 |
+
esc = action.command_args.get("escalation", "")
|
| 136 |
+
|
| 137 |
+
if task_id == 1:
|
| 138 |
+
if sev.lower() == gt.get("severity", ""):
|
| 139 |
+
reward += 1.0
|
| 140 |
+
elif task_id == 2:
|
| 141 |
+
if sev.lower() == gt.get("severity", ""):
|
| 142 |
+
reward += 0.4
|
| 143 |
+
if root and gt.get("root_cause", "") in root.lower():
|
| 144 |
+
reward += 0.4
|
| 145 |
+
elif task_id == 3:
|
| 146 |
+
if sev.lower() == gt.get("severity", ""):
|
| 147 |
+
reward += 0.2
|
| 148 |
+
if root and gt.get("root_cause", "") in root.lower():
|
| 149 |
+
reward += 0.2
|
| 150 |
+
if esc.lower() == gt.get("escalation", ""):
|
| 151 |
+
reward += 0.2
|
| 152 |
+
|
| 153 |
+
cmd_result = "Ticket resolved. Investigation closed."
|
| 154 |
+
done = True
|
| 155 |
+
|
| 156 |
+
else:
|
| 157 |
+
cmd_result = f"Error: Invalid command '{action.command}'. Use search_logs, query_metrics, or resolve_ticket."
|
| 158 |
+
reward -= 0.1 # Small penalty for invalid command
|
| 159 |
+
|
| 160 |
+
if session_state["step_count"] >= 8:
|
| 161 |
+
cmd_result = "Step limit reached. Forced termination."
|
| 162 |
+
done = True
|
| 163 |
+
|
| 164 |
+
obs = BugTriageObservation(
|
| 165 |
+
ticket_description=gt_full.get("desc", ""),
|
| 166 |
+
command_result=cmd_result,
|
| 167 |
+
step_count=session_state["step_count"]
|
| 168 |
+
)
|
| 169 |
+
|
| 170 |
+
return ActionResponse(
|
| 171 |
+
observation=obs,
|
| 172 |
+
reward=reward,
|
| 173 |
+
done=done,
|
| 174 |
+
info={"step": session_state["step_count"]}
|
| 175 |
+
)
|
| 176 |
+
|
| 177 |
+
@app.get("/state")
|
| 178 |
+
def state():
|
| 179 |
+
return session_state
|
inference.py
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import json
|
| 3 |
+
import re
|
| 4 |
+
import requests
|
| 5 |
+
from openai import OpenAI
|
| 6 |
+
from typing import Dict, Any, List
|
| 7 |
+
|
| 8 |
+
API_BASE_URL = os.environ.get("API_BASE_URL", "https://api.openai.com/v1")
|
| 9 |
+
MODEL_NAME = os.environ.get("MODEL_NAME", "gpt-4o-mini")
|
| 10 |
+
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 11 |
+
|
| 12 |
+
ENV_URL = "http://localhost:8000"
|
| 13 |
+
|
| 14 |
+
client = OpenAI(
|
| 15 |
+
api_key=os.environ.get("HF_TOKEN"),
|
| 16 |
+
base_url=os.environ.get("API_BASE_URL", "https://api.openai.com/v1")
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
def log_start(task: int, env: str, model: str):
|
| 20 |
+
print(f"[START] {json.dumps({'task': task, 'env': env, 'model': model})}", flush=True)
|
| 21 |
+
|
| 22 |
+
def log_step(step: int, action: Dict[str, Any], reward: float, done: bool, error: Any = None):
|
| 23 |
+
log_data = {'step': step, 'action': action, 'reward': reward, 'done': done, 'error': str(error) if error else None}
|
| 24 |
+
print(f"[STEP] {json.dumps(log_data)}", flush=True)
|
| 25 |
+
|
| 26 |
+
def log_end(success: bool, steps: int, score: float, rewards: List[float]):
|
| 27 |
+
print(f"[END] {json.dumps({'success': success, 'steps': steps, 'score': score, 'rewards': rewards})}", flush=True)
|
| 28 |
+
|
| 29 |
+
def extract_json(text: str) -> str:
|
| 30 |
+
"""Safely extract JSON from Markdown code blocks if they exist."""
|
| 31 |
+
match = re.search(r"```(?:json)?\s*(.*?)\s*```", text, re.DOTALL)
|
| 32 |
+
if match:
|
| 33 |
+
return match.group(1)
|
| 34 |
+
return text.strip()
|
| 35 |
+
|
| 36 |
+
def run_agent_loop(task_id: int):
|
| 37 |
+
log_start(task=task_id, env="bug-triage-env", model=MODEL_NAME)
|
| 38 |
+
|
| 39 |
+
try:
|
| 40 |
+
resp = requests.post(f"{ENV_URL}/reset", json={"task_id": task_id})
|
| 41 |
+
resp.raise_for_status()
|
| 42 |
+
state = resp.json()
|
| 43 |
+
except Exception as e:
|
| 44 |
+
print(f"Error connecting to env: {e}")
|
| 45 |
+
return
|
| 46 |
+
|
| 47 |
+
done = state.get("done", False)
|
| 48 |
+
step = 0
|
| 49 |
+
rewards = []
|
| 50 |
+
|
| 51 |
+
while not done and step < 8:
|
| 52 |
+
step += 1
|
| 53 |
+
observation = state.get("observation", {})
|
| 54 |
+
|
| 55 |
+
prompt = f"""
|
| 56 |
+
You are an expert Site Reliability Engineer (SRE).
|
| 57 |
+
Your goal is to investigate and resolve an incoming ticket.
|
| 58 |
+
|
| 59 |
+
Current Observation:
|
| 60 |
+
ticket_description: {observation.get('ticket_description')}
|
| 61 |
+
command_result: {observation.get('command_result')}
|
| 62 |
+
step_count: {observation.get('step_count')}
|
| 63 |
+
|
| 64 |
+
You must output your action strictly as JSON matching this format exactly:
|
| 65 |
+
{{
|
| 66 |
+
"command": "search_logs" | "query_metrics" | "resolve_ticket",
|
| 67 |
+
"command_args": {{
|
| 68 |
+
// for search_logs -> "service": "database" | "payment" | etc
|
| 69 |
+
// for query_metrics -> "metric": "cpu" | "payment_latency" | etc
|
| 70 |
+
// for resolve_ticket -> "severity": "low"|"medium"|"high"|"critical", "root_cause": "...", "escalation": "..."
|
| 71 |
+
}}
|
| 72 |
+
}}
|
| 73 |
+
|
| 74 |
+
Analyze the command_result. If you need more information, use search_logs or query_metrics first.
|
| 75 |
+
Once you have enough info, use resolve_ticket.
|
| 76 |
+
"""
|
| 77 |
+
try:
|
| 78 |
+
completion = client.chat.completions.create(
|
| 79 |
+
model=MODEL_NAME,
|
| 80 |
+
messages=[{"role": "user", "content": prompt}],
|
| 81 |
+
response_format={"type": "json_object"}
|
| 82 |
+
)
|
| 83 |
+
|
| 84 |
+
action_text = completion.choices[0].message.content or ""
|
| 85 |
+
clean_json = extract_json(action_text)
|
| 86 |
+
action_payload = json.loads(clean_json)
|
| 87 |
+
except Exception as e:
|
| 88 |
+
action_payload = {
|
| 89 |
+
"command": "resolve_ticket",
|
| 90 |
+
"command_args": {"severity": "medium", "root_cause": "unknown", "escalation": "none"}
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
try:
|
| 94 |
+
step_resp = requests.post(f"{ENV_URL}/step", json={"action": action_payload})
|
| 95 |
+
step_resp.raise_for_status()
|
| 96 |
+
step_result = step_resp.json()
|
| 97 |
+
|
| 98 |
+
state = {"observation": step_result["observation"]}
|
| 99 |
+
done = step_result["done"]
|
| 100 |
+
reward = step_result["reward"]
|
| 101 |
+
rewards.append(reward)
|
| 102 |
+
|
| 103 |
+
log_step(step=step, action=action_payload, reward=reward, done=done)
|
| 104 |
+
except Exception as e:
|
| 105 |
+
print(f"Error stepping environment: {e}")
|
| 106 |
+
break
|
| 107 |
+
|
| 108 |
+
total_reward = sum(rewards)
|
| 109 |
+
# clamp to 0-1
|
| 110 |
+
score = min(max(total_reward, 0.0), 1.0)
|
| 111 |
+
success = score >= 0.5
|
| 112 |
+
|
| 113 |
+
log_end(success=success, steps=step, score=score, rewards=rewards)
|
| 114 |
+
|
| 115 |
+
def main():
|
| 116 |
+
for task in [1, 2, 3]:
|
| 117 |
+
run_agent_loop(task)
|
| 118 |
+
|
| 119 |
+
if __name__ == "__main__":
|
| 120 |
+
main()
|
openenv.yaml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: bug-triage-assistant
|
| 2 |
+
version: "1.0.0"
|
| 3 |
+
description: "An Interactive SRE Environment simulating bug triage, incident response, and root cause analysis with pseudo-tools."
|
| 4 |
+
tasks:
|
| 5 |
+
- id: 1
|
| 6 |
+
name: "Severity Classification"
|
| 7 |
+
description: "Classify the severity of an incoming bug report directly from the description."
|
| 8 |
+
difficulty: "easy"
|
| 9 |
+
- id: 2
|
| 10 |
+
name: "Log Investigation"
|
| 11 |
+
description: "Agent must use 'search_logs' action to investigate before deriving the root cause."
|
| 12 |
+
difficulty: "medium"
|
| 13 |
+
- id: 3
|
| 14 |
+
name: "Deep Triangulation"
|
| 15 |
+
description: "Agent must investigate logs and metrics using tools to find latency sources and escalate."
|
| 16 |
+
difficulty: "hard"
|
| 17 |
+
license: MIT
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastapi
|
| 2 |
+
pydantic
|
| 3 |
+
uvicorn
|
| 4 |
+
openai
|
| 5 |
+
requests
|
| 6 |
+
aiohttp
|