Skip to content

fix(spreadsheetbench): return the code of an unclosed fenced block - #489

Open
Lanre Shittu (Shizoqua) wants to merge 1 commit into
microsoft:mainfrom
Shizoqua:fix/spreadsheetbench-unclosed-code-fence
Open

Lanre Shittu (Shizoqua) wants to merge 1 commit into
microsoft:mainfrom
Shizoqua:fix/spreadsheetbench-unclosed-code-fence

Conversation

@Shizoqua

Copy link
Copy Markdown
Contributor

Summary

extract_code in skillopt/envs/spreadsheetbench/codegen_agent.py returned the whole reply when the opening code fence had no closing fence. A reply cut off at the token limit is the usual case. The python fence line and any prose before it were then passed on as code, the extracted text did not compile, and the attempt failed with a SyntaxError instead of feedback on the model's logic.

This change returns the text after the opening fence line when there is no closing fence.

Changes

  • skillopt/envs/spreadsheetbench/codegen_agent.py: extract_code returns the text after the opening fence line when no closing fence follows. Closed blocks and replies without a fence keep their current output.
  • tests/test_spreadsheetbench_extract_code.py: new tests (see below).
  • CHANGELOG.md: entry under Fixed.

Tests

  • Two unclosed-block cases (prose before the fence, and a fence at the start of the reply). These fail on upstream main and pass with this change.
  • Four guard cases that pass on main and with this change: three closed blocks (with prose before and after, with a python fence, and with a language-less fence) and a reply without a fence.
  • Full suite: 2623 passed, 24 skipped, 4 xfailed.
  • ruff check and ruff format --check pass on the new test file. codegen_agent.py has the same ruff findings as on main (5 fixable lint items and 43 format differences, the same counts as on main), so this change adds none.

Fixes #488

extract_code returned the whole reply when the opening code fence had no
closing fence, which happens when a reply is cut off at the token limit.
The fence line and any prose before it were then run as Python and the
attempt failed with a SyntaxError.

Return the text after the opening fence line in that case. Closed blocks
and replies without a fence are unchanged.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SpreadsheetBench code extraction keeps the fence line when a code block is never closed

1 participant