File size: 2,534 Bytes
92f22c6
d416acc
 
 
 
92f22c6
 
 
 
d416acc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
title: API Triage Agent
emoji: πŸ€–
colorFrom: blue
colorTo: purple
sdk: docker
pinned: false
---

# API Triage Agent

## Environment Description :
An AI agent that diagnoses and resolves API integration failures by inspecting logs, identifying error types, and taking corrective actions. Simulates real-world API debugging scenarios.

## Motivation
API failures are common in production. This environment teaches an agent to handle authentication errors, missing fields, rate limits, wrong endpoints, and server errors – just like a real support engineer.

## Action Space (8 actions)
| Action | Description |
|--------|-------------|
| `inspect_logs` | Examine error logs for clues |
| `inspect_request` | Check the failed API request |
| `refresh_token` | Fix authentication errors (401) |
| `add_field` | Add missing required fields (400) |
| `wait_retry` | Handle rate limits (429) and timeouts (408) |
| `change_endpoint` | Fix wrong API endpoint (404) |
| `escalate` | Report server errors (500) to human |
| `resolve` | End episode after successful fix |

## Observation Space
| Field | Type | Description |
|-------|------|-------------|
| `step` | int | Current step number |
| `max_steps` | int | Maximum steps allowed (10) |
| `incident_summary` | str | Short problem description |
| `logs` | list | Error messages from API |
| `response_code` | int | HTTP status code |
| `fix_applied` | bool | Whether fix has been applied |
| `is_resolved` | bool | Whether episode ended |

## Tasks (Easy β†’ Medium β†’ Hard)

### Easy Task: Authentication Error
- **Incident:** `auth_error`
- **Correct fix:** `refresh_token` β†’ `resolve`
- **Score achieved:** 1.0

### Medium Task: Missing Field Error
- **Incident:** `missing_fields`
- **Correct fix:** `add_field` β†’ `resolve`
- **Score achieved:** 1.0

### Hard Task: Server Error
- **Incident:** `server_error`
- **Correct fix:** `escalate` β†’ `resolve`
- **Score achieved:** 1.0

## Reward System (5 factors)
| Factor | Reward |
|--------|--------|
| Correct fix action | +5 |
| Wrong action | -2 |
| Diagnostic action | +0.5 |
| Resolve with fix (success) | +15 |
| Resolve without fix | -10 |
| Max steps reached | -5 |

## Setup Instructions

### 1. Create virtual environment
```bash
python -m venv venv
source venv/bin/activate  # Linux/Mac
venv\Scripts\activate     # Windows
 
# 2. must do (install dependencies) - pip install -r requirements.txt 
# also run these : python demo.py , pytest tests/test_env.py -v , python tests/test_graders.py , openenv validate