Skip to content

Bug: Iron Rule 1 causes intermediate Python blocks to overwrite correct answers #5

Description

@Augustas11

Problem

Iron Rule 1 mandates that every Python block ends with open("/app/answer.txt","w").write(str(result)). In multi-step questions (retrieve year 1 → retrieve year 2 → compute), intermediate blocks overwrite each other. If the agent errors in a later block, answer.txt contains a wrong intermediate value that gets scored as the final answer.

The "stop after writing final answer" rule partially mitigates this, but it is a race condition in practice.

Fix

Use a staging pattern for intermediate blocks:

# Intermediate blocks — write to staging file
open("/app/answer_tmp.txt","w").write(str(partial_result))

# Final block only — promote to answer.txt
open("/app/answer.txt","w").write(str(final_result))

Or add an explicit instruction: "Only write to answer.txt in the final computation block. Use answer_tmp.txt for intermediate results."

Impact

Medium — affects multi-step numerical questions where partial results are meaningful numbers that would pass tolerance checks.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions