CoolFace
Apppublic

ThrishanthHS/incident-triage-env

sourceHugging Faceapache-2.0updated 6mo agoView on Hugging Face
0likes
App README

<<<<<<< HEAD

๐Ÿšจ Incident Log Triage Environment

=======

Baseline Scores

Produced by running inference.py with llama-3.1-8b-instant via Groq:

TaskScoreSteps
Easy1.00/1.005
Medium1.00/1.005
Hard0.75/1.007
Average0.92/1.00โ€”

Incident Log Triage Environment

>>>>>> 18395bb (Update README.md)

An RL environment where an agent plays the role of an on-call SRE engineer. It reads server logs, figures out what broke, and proposes a fix โ€” across three tasks of increasing difficulty.

Built for the OpenEnv spec: the environment exposes /reset, /step, and /state endpoints so any agent can interact with it over HTTP.


What the agent has to do

A production system is down. Multiple services are logging output, but not all of it is useful. The agent has to read through the noise, find the actual root cause, and submit a diagnosis โ€” ideally with a fix.

Three scenarios are included:

Easy โ€” Single Service Crash One service has crashed with a clear ERROR in its logs. The agent just needs to find it and name it. Straightforward, good for sanity-checking a new agent.

Medium โ€” Cascading Failure Three services are connected. One fails first, which causes the others to fail too. The agent needs to trace back to the original broken service, not just report the ones that are loudly complaining.

Hard โ€” Silent Timeout with Red Herrings Five services. Two of them are logging loud, dramatic errors โ€” but they're not the real problem. The actual failure is a quiet upstream timeout that barely shows up in the logs. The agent needs to ignore the noise and find the real cause.


Observation space

At each step the agent receives:

FieldTypeWhat it means
available_serviceslist[str]Which services the agent can read logs from
log_contentstrThe log lines returned by the last read/search action
action_feedbackstrA plain-English message about what just happened
current_stepintHow many steps have been taken so far
task_idstrWhich task is running โ€” easy, medium, or hard
task_descriptionstrA short description of the incident scenario

Action space

The agent can take four types of actions each step:

`read_log` โ€” Read recent log lines from one specific service.

json
{"action_type": "read_log", "service_name": "auth-service", "num_lines": 20}

`search_logs` โ€” Search across all services for a keyword.

json
{"action_type": "search_logs", "keyword": "timeout"}

`diagnose` โ€” Submit a diagnosis when the agent thinks it knows the root cause.

json
{"action_type": "diagnose", "root_cause_service": "db-service", "error_type": "connection_timeout", "explanation": "The database stopped accepting connections at 03:42, causing auth and api to fail downstream."}

`suggest_fix` โ€” Propose a fix after diagnosing.

json
{"action_type": "suggest_fix", "fix_action": "Restart db-service and check connection pool limits."}

Reward structure

Rewards are in the range 0.0โ€“1.0. The agent gets partial credit for meaningful progress, not just the final answer.

  • โ€”Reading relevant logs โ†’ small positive reward
  • โ€”Submitting a correct diagnosis โ†’ large reward
  • โ€”Correct fix after correct diagnosis โ†’ bonus reward
  • โ€”Wrong diagnosis or running out of steps โ†’ penalty / zero

Each step returns step_reward, running total_reward, and a final task_score when the episode ends.


API endpoints

The environment runs as a FastAPI server. Endpoints:

MethodEndpointWhat it does
POST/resetStart a new episode. Pass {"task_id": "easy"}
POST/stepSubmit an action. Returns observation + reward + done flag
GET/stateGet the current state without advancing the episode
GET/docsAuto-generated Swagger UI

Running locally

bash
git clone https://huggingface.co/spaces/ThrishanthHS/incident-triage-env
cd incident-triage-env
pip install -r requirements.txt
uvicorn server:app --host 0.0.0.0 --port 7860

Then test it:

bash
curl -X POST http://localhost:7860/reset -H "Content-Type: application/json" -d '{"task_id": "easy"}'

Running the baseline agent

Copy .env.example to .env and fill in your keys:

API_BASE_URL=https://api.groq.com/openai/v1
MODEL_NAME=llama-3.1-8b-instant
HF_TOKEN=your_hf_token_here
OPENAI_API_KEY=your_groq_key_here
ENV_BASE_URL=http://localhost:7860

Then run:

bash
python inference.py

Docker

bash
docker build -t incident-triage-env .
docker run -p 7860:7860 incident-triage-env

Baseline scores

Tested with llama-3.1-8b-instant via Groq:

TaskScoreSteps taken
Easy1.00 / 1.005
Medium1.00 / 1.005
Hard0.75 / 1.007
Average0.92 / 1.00โ€”

The hard task is the interesting one โ€” the agent gets tripped up by the red herring errors about 25% of the time. There's room to improve with better prompting or a smarter search strategy.


File structure

โ”œโ”€โ”€ server.py          # FastAPI app โ€” exposes the HTTP endpoints
โ”œโ”€โ”€ environment.py     # Core environment logic (reset, step, state)
โ”œโ”€โ”€ tasks.py           # The three incident scenarios
โ”œโ”€โ”€ graders.py         # Scoring logic for each task
โ”œโ”€โ”€ models.py          # Pydantic models for requests/responses
โ”œโ”€โ”€ openenv.yaml       # OpenEnv spec file
โ”œโ”€โ”€ inference.py       # Baseline agent script
โ”œโ”€โ”€ Dockerfile
โ””โ”€โ”€ requirements.txt