Skip to content

Commit 03f32da

Browse files
committed
fix(qed_math_env): address second round of burtenshaw review blockers
- step_async: propagate reward/done from submit_proof payload — was returning CallToolObservation with reward=None/done=False; extracted enrichment logic into _enrich_submit_proof_obs and call it from both step() and step_async() - reset: raise ValueError on unknown problem_id instead of silently falling back to problems[0] - Strip trailing whitespace from v1.md, v2.md, .dockerignore, openenv.yaml - ruff format examples/qed_math_inference.py
1 parent 3d38287 commit 03f32da

6 files changed

Lines changed: 67 additions & 56 deletions

File tree

envs/qed_math_env/.dockerignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,3 @@ __pycache__/
1111
*.pywz
1212
*.pyzw
1313
*.pyzwz
14-
15-

envs/qed_math_env/openenv.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,3 @@ metrics:
8686
- episode/is_correct
8787
- episode/problem_type
8888
- episode/dataset_source
89-
Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
1-
You are an **expert math proof grader**. You are judging the correctness of an LLM-generated proof for a math problem.
1+
You are an **expert math proof grader**. You are judging the correctness of an LLM-generated proof for a math problem.
22

33
### Input
44
Your input will consist of:
55
**Problem Statement**: A mathematical problem that the proof is attempting to solve.
66
**Marking Scheme**: A problem-specific grading rubric (0-7 scale) with checkpoints, zero-credit items, and deductions. You must follow this scheme when assigning points.
7-
**Proof Solution**: The proof that you need to evaluate. This proof may contain errors, omissions, or unclear steps. The proof was generated by another language model.
7+
**Proof Solution**: The proof that you need to evaluate. This proof may contain errors, omissions, or unclear steps. The proof was generated by another language model.
88

9-
### Task
10-
Analyze the proof carefully.
9+
### Task
10+
Analyze the proof carefully.
1111
**Core principles (in order of precedence):**
12-
1) **Mathematical validity** of the proof's reasoning and conclusion.
13-
2) **Problem constraints** (e.g., unique required final value; forbidden tools if stated).
14-
3) **Advisory mapping to the marking scheme** (checkpoints/deductions), allowing different orders and techniques.
15-
4) **Reference solution** as an anchor for sufficiency, not exclusivity.
16-
17-
**Alternative-approach policy:**
18-
- If the proof uses a different but valid method, **map its steps to equivalent rubric checkpoints** (same logical role) and award points accordingly.
19-
- Apply zero-credit items/deductions **only when the underlying issue actually occurs** in the given proof's approach; **auto-penalize** for omitting a rubric step.
20-
- Avoid double-counting mutually exclusive items; if two items solve the same logical gap, **award the larger only**.
21-
- If the final numeric/algebraic answer is wrong where uniqueness is required, award only partial credit justified by correct intermediate reasoning.
22-
23-
**Rigor and evidence:**
24-
- Award credit for intermediate claims **only if adequately justified** within the proof (not merely asserted).
25-
- If a step is plausible but under-justified, award **conservative partial credit** and note what is missing.
26-
27-
**What to produce:**
28-
- Identify logical errors, incorrect steps, or unclear reasoning.
29-
- Give a **score between 0 and 7** with a **detailed assessment**.
30-
- **Within the assessment text**, show clearly how the score was derived:
31-
- Which rubric checkpoints were earned and the points you awarded.
32-
- Any zero-credit items or deductions you applied (and why).
33-
- How these add up to the final integer score in [0-7].
34-
12+
1) **Mathematical validity** of the proof's reasoning and conclusion.
13+
2) **Problem constraints** (e.g., unique required final value; forbidden tools if stated).
14+
3) **Advisory mapping to the marking scheme** (checkpoints/deductions), allowing different orders and techniques.
15+
4) **Reference solution** as an anchor for sufficiency, not exclusivity.
16+
17+
**Alternative-approach policy:**
18+
- If the proof uses a different but valid method, **map its steps to equivalent rubric checkpoints** (same logical role) and award points accordingly.
19+
- Apply zero-credit items/deductions **only when the underlying issue actually occurs** in the given proof's approach; **auto-penalize** for omitting a rubric step.
20+
- Avoid double-counting mutually exclusive items; if two items solve the same logical gap, **award the larger only**.
21+
- If the final numeric/algebraic answer is wrong where uniqueness is required, award only partial credit justified by correct intermediate reasoning.
22+
23+
**Rigor and evidence:**
24+
- Award credit for intermediate claims **only if adequately justified** within the proof (not merely asserted).
25+
- If a step is plausible but under-justified, award **conservative partial credit** and note what is missing.
26+
27+
**What to produce:**
28+
- Identify logical errors, incorrect steps, or unclear reasoning.
29+
- Give a **score between 0 and 7** with a **detailed assessment**.
30+
- **Within the assessment text**, show clearly how the score was derived:
31+
- Which rubric checkpoints were earned and the points you awarded.
32+
- Any zero-credit items or deductions you applied (and why).
33+
- How these add up to the final integer score in [0-7].
34+
3535
### Output Format
36-
Respond with **only** well-formed XML using the structure below. Do not include any extra text or Markdown.
37-
**Requirements:**
38-
- '<score>' must be an integer in [0, 7].
39-
- '<assessment>' must be a **detailed analysis** that explains your reasoning step-by-step and provides a clear **rationale for the score**. Reference specific claims/lines if present. Include the scoring breakdown **in prose** here (earned checkpoints or mapped equivalents, deductions, and subtotal -> final score).
40-
- '<errors>' must be a list of specific issues (empty if score = 7).
36+
Respond with **only** well-formed XML using the structure below. Do not include any extra text or Markdown.
37+
**Requirements:**
38+
- '<score>' must be an integer in [0, 7].
39+
- '<assessment>' must be a **detailed analysis** that explains your reasoning step-by-step and provides a clear **rationale for the score**. Reference specific claims/lines if present. Include the scoring breakdown **in prose** here (earned checkpoints or mapped equivalents, deductions, and subtotal -> final score).
40+
- '<errors>' must be a list of specific issues (empty if score = 7).
4141

42-
Example output:
42+
Example output:
4343
<score>0</score>
44-
<assessment>The proof shows a good understanding of the main idea, but has some unclear reasoning and minor mistakes...</assessment>
45-
<errors>
44+
<assessment>The proof shows a good understanding of the main idea, but has some unclear reasoning and minor mistakes...</assessment>
45+
<errors>
4646
1. specific error 1,
4747
2. specific error 2,
48-
...
48+
...
4949
</errors>
5050

5151
### INPUT DATA
@@ -57,4 +57,4 @@ Example output:
5757
{marking_scheme}
5858

5959
**Proof Solution**
60-
{solution}
60+
{solution}

envs/qed_math_env/prompts/evaluator_prompts/v2.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ You must follow this structured process:
2222
4. **Score Determination:** Compare the findings against the Specific Grading Guidelines and the General Rubric to determine the final score.
2323

2424
### Output Format
25-
Respond with **only** well-formed XML using the structure below. Do not include any extra text or Markdown.
26-
**Requirements:**
27-
- '<score>' must be an integer in (0, 1, 6, 7).
28-
- '<assessment>' must be a **detailed analysis** that explains your reasoning step-by-step and provides a clear **rationale for the score**. Reference specific claims/lines if present. Include the scoring breakdown **in prose** here (earned checkpoints or mapped equivalents, deductions, and subtotal -> final score).
29-
- '<errors>' must be a list of specific issues (empty if score = 7).
25+
Respond with **only** well-formed XML using the structure below. Do not include any extra text or Markdown.
26+
**Requirements:**
27+
- '<score>' must be an integer in (0, 1, 6, 7).
28+
- '<assessment>' must be a **detailed analysis** that explains your reasoning step-by-step and provides a clear **rationale for the score**. Reference specific claims/lines if present. Include the scoring breakdown **in prose** here (earned checkpoints or mapped equivalents, deductions, and subtotal -> final score).
29+
- '<errors>' must be a list of specific issues (empty if score = 7).
3030

31-
Example output:
31+
Example output:
3232
<score>0</score>
33-
<assessment>The proof shows a good understanding of the main idea, but has some unclear reasoning and minor mistakes...</assessment>
34-
<errors>
33+
<assessment>The proof shows a good understanding of the main idea, but has some unclear reasoning and minor mistakes...</assessment>
34+
<errors>
3535
1. specific error 1,
3636
2. specific error 2,
37-
...
37+
...
3838
</errors>
3939

4040
### INPUT DATA

envs/qed_math_env/server/qed_math_environment.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,8 @@ async def step_async(
823823
self._async_call_tool(action.tool_name, action.arguments),
824824
timeout=timeout,
825825
)
826-
return CallToolObservation(tool_name=action.tool_name, result=result)
826+
obs = CallToolObservation(tool_name=action.tool_name, result=result)
827+
return self._enrich_submit_proof_obs(action, obs)
827828
except asyncio.TimeoutError:
828829
return CallToolObservation(
829830
tool_name=action.tool_name,
@@ -894,7 +895,11 @@ def reset(
894895
),
895896
None,
896897
)
897-
self._current_problem = selected or self._problems[0]
898+
if selected is None:
899+
raise ValueError(
900+
f"problem_id {selected_problem_id!r} not found in the loaded dataset."
901+
)
902+
self._current_problem = selected
898903
elif seed is not None:
899904
rng = random.Random(seed)
900905
self._current_problem = rng.choice(self._problems)
@@ -988,8 +993,12 @@ def step(
988993
self._state.step_count += 1
989994
obs = super().step(action, timeout_s=timeout_s, **kwargs)
990995

991-
# For proof submissions, surface proof-grading semantics
992-
# on the returned observation while preserving MCP compatibility.
996+
return self._enrich_submit_proof_obs(action, obs)
997+
998+
def _enrich_submit_proof_obs(
999+
self, action: Any, obs: Any
1000+
) -> Any:
1001+
"""Attach reward/done from submit_proof payload onto the CallToolObservation."""
9931002
if (
9941003
isinstance(action, CallToolAction)
9951004
and action.tool_name == "submit_proof"
@@ -1020,7 +1029,6 @@ def step(
10201029
reward=proof_obs.reward,
10211030
metadata=metadata,
10221031
)
1023-
10241032
return obs
10251033

10261034
@staticmethod

examples/qed_math_inference.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,11 @@ def _tools_to_openai_format(tools: list) -> list[dict[str, Any]]:
9494
for tool in tools:
9595
properties: dict[str, Any] = {}
9696
required: list[str] = []
97-
input_schema = getattr(tool, "input_schema", None) or getattr(tool, "inputSchema", None) or {}
97+
input_schema = (
98+
getattr(tool, "input_schema", None)
99+
or getattr(tool, "inputSchema", None)
100+
or {}
101+
)
98102
if input_schema and "properties" in input_schema:
99103
for name, schema in input_schema["properties"].items():
100104
properties[name] = {
@@ -269,7 +273,9 @@ async def run_episode(
269273
done = bool(result_dict.get("done", True))
270274
if VERBOSE:
271275
if done:
272-
outcome = "CORRECT" if result_dict.get("is_correct") else "INCORRECT"
276+
outcome = (
277+
"CORRECT" if result_dict.get("is_correct") else "INCORRECT"
278+
)
273279
print(
274280
f"\nOutcome: {outcome} score={final_score}/7 reward={final_reward:.3f}"
275281
)

0 commit comments

Comments
 (0)