File size: 4,152 Bytes
3115ff3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
---
license: apache-2.0
task_categories:
  - text2text-generation
language:
  - en
tags:
  - json-repair
  - schema-validation
  - structured-output
  - tool-calling
  - agent-workflows
  - constraint-dsl
size_categories:
  - 100K<n<1M
---

# StructFix-Bench

A benchmark for **schema-aware structured output recovery** — repairing broken outputs from agents, tool calls, and LLM workflows.

## What it tests

Unlike JSON syntax repair benchmarks, StructFix-Bench focuses on **semantic and schema-level recovery**:

- Replacing invalid enum values with valid ones
- Adding missing required fields
- Correcting type mismatches
- Recovering tool call arguments from Python syntax
- Reconstructing outputs from truncated agent chains
- Extracting JSON from markdown/text wrappers

## Dataset splits

| Split | Examples | Field names | Enums |
|-------|---------|-------------|-------|
| `train` | 200,000 | Mixed (semantic + shuffled) | Mixed (realistic + synthetic) |
| `validation` | 20,000 | Semantic | Realistic |
| `test_seen` | 10,000 | Semantic | Realistic |
| `test_unseen` | 10,000 | Semantic | Realistic |
| `test_random_fields` | 10,000 | **Random hex** (`f_8f31a7`) | Synthetic |

## Corruption types (28 total)

### Syntactic (10)
`single_quotes`, `unquoted_keys`, `trailing_comma`, `markdown_fences`, `extra_text_before`, `extra_text_after`, `truncated_object`, `truncated_array`, `missing_bracket`, `missing_brace`

### Semantic (9)
`wrong_type`, `invalid_enum`, `missing_required`, `null_required`, `extra_field`, `boolean_as_string`, `number_with_unit`, `synonym_enum`, `date_format_error`

### LLM-like (3)
`markdown_explanation`, `partial_structure`, `thought_process`

### Tool/Agent (6)
`tool_call_bad_format`, `tool_call_text_mix`, `tool_call_python_syntax`, `tool_call_partial_args`, `tool_call_wrong_param`, `agent_chain`

## Input format

Each example uses **ConstraintDSL** to represent the schema:

```
TASK repair_structured_output

SPEC
FIELD priority TYPE string VALUES low|medium|high REQUIRED yes
FIELD description TYPE string REQUIRED yes

BROKEN_OUTPUT
{"priority":"urgent"}
```

Target: `{"priority":"high","description":""}`

## Key results

| Method | Schema Success (unseen) | Schema Success (random fields) |
|--------|:----------------------:|:----------------------------:|
| json-repair | 65.2% | 64.0% |
| CodeT5+ + JSON Schema | 55.0% | — |
| **CodeT5+ + ConstraintDSL** | **96.3%** | **91.9%** |

## Schema ablation study

Full ablation results are included in `results/all_results.json`:

| DSL variant | Schema Success |
|------------|:--------------:|
| Full ConstraintDSL | 96.3% |
| No DSL at all | 78.4% |
| Dummy DSL | 75.0% |
| Conflicting DSL | 88.3% |
| Shuffled field names | 73.4% |
| Shuffled enum values | 89.8% |
| Shuffled required flags | 93.2% |
| Minimal DSL | 82.5% |
| Field names only | 72.2% |

## Known limitations

The benchmark uses synthetically generated schemas and corruptions. A showcase validation with 25 hand-crafted real-world examples revealed that model performance degrades when field names overlap with training vocabulary — the model may substitute field names (e.g., `action``active`, `contract_id``consign_id`). See the model card for details.

## Files

- `train.jsonl` / `validation.jsonl` / `test_seen.jsonl` / `test_unseen.jsonl` / `test_random_fields.jsonl`
- `results/all_results.json` — all experiment results including ablations

## Each example contains

```json
{
  "input": "TASK repair_structured_output\n\nSPEC\n...",
  "target": "{\"priority\":\"high\",\"description\":\"\"}",
  "corruption_type": "invalid_enum",
  "schema": {"type": "object", "properties": {...}, "required": [...]},
  "invalid_json": "{\"priority\":\"urgent\"}",
  "error": "Field 'priority' has invalid enum value 'urgent'",
  "target_json": "{\"priority\":\"high\",\"description\":\"\"}"
}
```

## Citation

```bibtex
@software{structfix_bench,
  title = {StructFix-Bench: A Benchmark for Schema-Aware Structured Output Recovery},
  author = {Ottema},
  year = {2026},
  url = {https://huggingface.co/datasets/ottema/structfix-bench}
}
```

## License

Apache-2.0