Skip to content

fix(alfworld): execute the action the rollout records - #451

Open
Yiming Niu (neumyor) wants to merge 1 commit into
microsoft:mainfrom
neumyor:fix/alfworld-action-parsing
Open

Yiming Niu (neumyor) wants to merge 1 commit into
microsoft:mainfrom
neumyor:fix/alfworld-action-parsing

Conversation

@neumyor

@neumyor Yiming Niu (neumyor) commented Nov 23, 2026 •

Copy link
Copy Markdown

Summary

The ALFWorld projection took the first <action> and the first </action> separately, while _extract_action in the rollout used a case-sensitive regex. A </action> mentioned in the reasoning made the environment execute an empty action marked valid while the trajectory recorded the real one. A format example such as <action>look</action> in the reasoning was executed instead of the final action, and upper-case tags were replaced with look.

Changes

  • skillopt/envs/alfworld/actions.py: new extract_action() returns the last complete, case-insensitive <action>...</action> body (the body may not contain another <action>, as in the SearchQA evaluator), or None. It has no alfworld import.
  • skillopt/envs/alfworld/vendor/alfworld_projection.py: uses extract_action(). Responses without an action and the existing <think> and Chinese-character validity rules are unchanged.
  • skillopt/envs/alfworld/rollout.py: _extract_action() uses the same helper, so the recorded action is the executed one.
  • CHANGELOG.md: entry under Fixed.

Tests

  • tests/test_alfworld_action_parsing.py: the helper and _extract_action on plain, closing-tag-in-reasoning, format-example, upper-case, multi-line and missing-tag responses; the projection executes the recorded action for the three cases from the issue and keeps its existing validity rules. The projection module is loaded from its file because the vendor package imports the alfworld simulator, which CI does not install.

The new tests fail on main (5 of 13) and pass with the fix. Full suite on macOS, Python 3.11: 2440 passed, 3 failed, 11 skipped, 4 xfailed. The 3 failures also fail on main on this machine and are unrelated: test_backend_pi.py::test_default_model_from_env finds pi on PATH, and two test_sleep_adopt_skill_subset.py tests hit the macOS /tmp symlink. ruff check passes on the changed files.

Fixes #449

Copilot AI balanced review requested due to automatic review settings November 23, 2026 11:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

The projection found the first "<action>" and the first "</action>"
separately. A "</action>" mentioned in the reasoning came before the real
opening tag, so the environment got an empty action marked valid, while
_extract_action recorded the real action in the trajectory. A format
example such as "<action>look</action>" in the reasoning was executed
instead of the final action, and upper-case tags were replaced with
"look".

Add extract_action(), which returns the last complete, case-insensitive
<action>...</action> pair, and use it in both the projection and the
rollout record.
@neumyor
Yiming Niu (neumyor) force-pushed the fix/alfworld-action-parsing branch from 9c73224 to 3c3b2d1 Compare November 23, 2026 11:34
@neumyor

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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.

ALFWorld executes a different action from the one the rollout records when the reasoning mentions an action tag

2 participants