File size: 2,964 Bytes
b6b4d3b
 
 
6d2ec98
 
 
 
bc16a95
 
b6b4d3b
 
bc16a95
b6b4d3b
 
6d2ec98
 
 
e0a6d43
b6b4d3b
e0a6d43
b6b4d3b
 
 
6d2ec98
 
 
b6b4d3b
 
 
bc16a95
b6b4d3b
 
6d2ec98
 
 
b6b4d3b
 
e0a6d43
b6b4d3b
 
 
6d2ec98
 
 
b6b4d3b
 
 
bc16a95
b6b4d3b
 
6d2ec98
 
 
b6b4d3b
 
e0a6d43
b6b4d3b
 
 
6d2ec98
 
 
b6b4d3b
 
 
e0a6d43
 
 
 
6d2ec98
e0a6d43
 
6d2ec98
e0a6d43
 
6d2ec98
b6b4d3b
 
 
e0a6d43
6d2ec98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b6b4d3b
e0a6d43
b6b4d3b
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: sql-debugger-env
version: "1.0.0"
description: >
  An RL environment for training AI agents to write, debug, and optimize
  SQL queries against a real SQLite database. Three task types cover
  real data analyst work: writing queries from specs, fixing broken SQL,
  and optimizing slow correlated subqueries.

tasks:
  - id: easy_01
    name: Filter high earners
    difficulty: easy
    type: write_query
    grader: true
    description: >
      Find all employees in the Engineering department with salary above 
      90000. Return name and salary ordered by salary descending.

  - id: easy_02
    name: Count by department
    difficulty: easy
    type: write_query
    grader: true
    description: >
      Count how many employees are in each department. Return department 
      name and count ordered by count descending.

  - id: medium_01
    name: Fix broken JOIN
    difficulty: medium
    type: fix_query
    grader: true
    description: >
      Fix the broken query that returns employees on active projects. 
      Bugs: missing ON keyword in JOIN, wrong table alias in WHERE clause.

  - id: medium_02
    name: Fix wrong GROUP BY
    difficulty: medium
    type: fix_query
    grader: true
    description: >
      Fix the query that computes average salary per department but 
      incorrectly groups by id instead of department.

  - id: hard_01
    name: Optimize correlated subquery
    difficulty: hard
    type: optimize_query
    grader: true
    description: >
      Replace correlated subqueries with window functions or CTEs to 
      find the top earner per department with total hours worked.

  - id: hard_02
    name: Eliminate N+1 problem
    difficulty: hard
    type: optimize_query
    grader: true
    description: >
      Rewrite the N+1 correlated subquery using LEFT JOIN and GROUP BY 
      to get department stats in a single efficient query.

action_space:
  type: object
  properties:
    action_type:
      type: string
      enum: [write_query, fix_query, optimize_query]
      description: The type of SQL action being taken
    sql:
      type: string
      description: A valid SQLite SELECT statement
    explanation:
      type: string
      description: Optional explanation of reasoning

observation_space:
  type: object
  properties:
    task_id:
      type: string
    task_type:
      type: string
    task_description:
      type: string
    schema_info:
      type: string
      description: DDL schema of all tables
    sample_data:
      type: string
      description: First 3 rows of each table
    last_sql:
      type: string
    last_result:
      type: string
    last_error:
      type: string
    step_count:
      type: integer
    done:
      type: boolean
    reward:
      type: number
      minimum: 0.05
      maximum: 0.95
      description: Strictly between 0 and 1, never exactly 0.0 or 1.0
    feedback:
      type: string

reward_range: [0.05, 0.95]
max_steps_per_episode: 8