One function

parse_frontmatter in wshobson/agents

The author described this change as fix(adapters): parse nested frontmatter mappings (#618). It counts as a record because the check below fails on the code as it stood at d7cf7dca8 and passes on 2de74ac1c, with nothing else changed between the two runs.

Fix saved2026-07-11
Sharing licenceMIT · LICENSE
Change size+16 0

What the code was meant to do, written into the code itself as a docstring

Return (fields, body). Tolerant YAML-ish parser; no external dep. Supports: - scalar fields (`name: foo`) - inline lists (`tools: [a, b]`) and block lists (key: \n - a\n - b) - YAML block scalar indicators `>` and `|` (folded/literal multi-line strings) - 2-space continuation of scalar values

The change

44 Supports:
55 - scalar fields (`name: foo`)
66 - inline lists (`tools: [a, b]`) and block lists (key: \\n - a\\n - b)
7+ - one-level mappings (`metadata: \\n version: 1.0.0`)
78 - YAML block scalar indicators `>` and `|` (folded/literal multi-line strings)
89 - 2-space continuation of scalar values
910 """
6566 if text:
6667 existing = fields.get(current_key) or ""
6768 fields[current_key] = (existing + " " + text).strip() if existing else text
69+ elif (
70+ current_key
71+ and isinstance(fields.get(current_key), dict)
72+ and _is_one_level_mapping_entry(line)
73+ ):
74+ nested = re.match(r"^(\w[\w-]*):\s*(.*)", line.strip())
75+ if nested:
76+ fields[current_key][nested.group(1)] = nested.group(2).strip().strip('"').strip("'")
6877 elif in_list and (
6978 isinstance(fields.get(current_key), list)
7079 or (isinstance(fields.get(current_key), str) and fields[current_key] == "")
8897 item = stripped.strip('",[] ')
8998 if item and item != "]":
9099 fields[current_key].append(item)
100+ elif _is_one_level_mapping_entry(line):
101+ nested = re.match(r"^(\w[\w-]*):\s*(.*)", stripped)
102+ if nested:
103+ fields[current_key] = {
104+ nested.group(1): nested.group(2).strip().strip('"').strip("'")
105+ }
106+ in_list = False
91107 elif current_key and isinstance(fields.get(current_key), str) and line.startswith(" "):
92108 fields[current_key] += " " + line.strip().strip('"')
93109

The check that tells the two apart

failpass·tools/tests/test_adapters.py::TestFrontmatterParser::test_nested_mapping

Check file tools/tests/test_adapters.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before itd7cf7dca8c4c7d0635e284f77204daa85552bfa4
Broken version dated2026-07-08
Moduletools.adapters.base
Units changedparse_frontmatter
Fingerprint8fb47a9f168ce29d
Checked2026-08-17 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.