"""Put the missing "## Solution Originality" section back into the task message (messages[1]) of the pinned Qwen3.8-27B mini-swe-agent traces of nvidia/Open-SWE-Traces (revision f967cba3). Source of the section: NVIDIA NeMo-Skills, commit 592ebaec5a80e17a3535623d0f5704d29e13a64f, nemo_skills/prompt/config/eval/swe-bench/mini-swe-agent/swebench.yaml (lines 113-127, Apache-2.0). In that template the section sits between and . In the released traces messages[1] ends with "\\n", so the section was cut out. After restore_messages() the tail reads exactly as the template renders: "\\n\\n## Solution Originality\\n\\n...correctness!\\n". Usage: python3 -I restore_solution_originality.py Prints how many resolved == 1 rows of the shard can be restored, and the restored tail of the first one. """ import os import sys SECTION_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "pinned_f967cba3", "solution_originality_section.txt") SECTION = open(SECTION_PATH).read().strip("\n") ANCHOR = "\n" HEAD = "## Solution Originality" def restore_messages(messages): """Return a copy of messages with the section inserted into messages[1]; raise if the anchor is not the tail.""" task = messages[1]["content"] if HEAD in task: raise ValueError("already_present") if task.count(ANCHOR) != 1: raise ValueError("anchor_count_%d" % task.count(ANCHOR)) if not task.endswith(ANCHOR): raise ValueError("anchor_not_at_end") out = list(messages) out[1] = {**messages[1], "content": task[: -len(ANCHOR)] + "\n\n" + SECTION + "\n"} return out def main(): import pyarrow.parquet as pq t = pq.read_table(sys.argv[1], columns=["trajectory_id", "resolved", "messages"]) ok, bad, first = 0, 0, None for tid, res, msgs in zip(*(t.column(c).to_pylist() for c in ("trajectory_id", "resolved", "messages"))): if res != 1: continue try: new = restore_messages(msgs) ok += 1 first = first or (tid, new[1]["content"][-1600:]) except ValueError: bad += 1 print("restored", ok, "failed", bad) if first: print("\n--- tail of messages[1] after restore,", first[0], "---\n" + first[1]) if __name__ == "__main__": main()