Skip to content

fix(officeqa): keep the tool loop going on malformed tool arguments - #511

Open
Lanre Shittu (Shizoqua) wants to merge 1 commit into
microsoft:mainfrom
Shizoqua:fix/officeqa-tool-arguments-object
Open

Lanre Shittu (Shizoqua) wants to merge 1 commit into
microsoft:mainfrom
Shizoqua:fix/officeqa-tool-arguments-object

Conversation

@Shizoqua

Copy link
Copy Markdown
Contributor

Summary

process_one in skillopt/envs/officeqa/rollout.py parsed each tool call's arguments with json.loads and had no local error handling. Two kinds of model output ended the attempt:

  • Malformed JSON raised JSONDecodeError, which left the tool loop and was recorded as the attempt's error.
  • Valid JSON that is not an object (an array, a string or null) reached run_tool, where .get raised AttributeError.

In both cases the model's next reply was never read, so an attempt could score 0 even when that reply had the right answer.

This change uses an empty dict for unparsable arguments and for any parsed value that is not an object. Object arguments are passed to the tool unchanged. This matches _react_loop in skillopt/envs/spreadsheetbench/react_agent.py.

Changes

  • skillopt/envs/officeqa/rollout.py: the argument parse catches JSONDecodeError and checks for a dict. Object arguments are unchanged.
  • tests/test_officeqa_tool_arguments.py: new tests (see below).
  • CHANGELOG.md: entry under Fixed.

Tests

  • Malformed JSON arguments: the attempt continues, the tool runs with {}, and the answer 42 is scored correct. Fails on upstream main.
  • Four non-object cases (["*.txt"], "*.txt", null, 42): each one fails on upstream main with AttributeError from the tool and passes with this change.
  • Object arguments are passed to the tool unchanged. This passes on main and with this change.
  • The tests replace the model client and the document tools, so nothing is run on the host.
  • Full suite: 2623 passed, 24 skipped, 4 xfailed.
  • ruff check passes on rollout.py and on the new test file. The new test file passes ruff format --check.

Fixes #510

process_one parsed each tool call's arguments with json.loads and had no
local error handling. Malformed JSON raised JSONDecodeError. Valid JSON that
is not an object reached run_tool, where .get raised AttributeError. Either
exception left the loop and was recorded as the attempt's error, so the
model's next reply, which could contain the right answer, was never read.

Use an empty dict for unparsable arguments and for any parsed value that is
not an object. Object arguments are passed to the tool 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.

OfficeQA tool loop ends the attempt when a tool call has malformed JSON arguments

1 participant