Skip to content

fix(science-world): preserve action delimiters in stopped replies - #686

Open
Zhengyang Liu (liuzhengyang699) wants to merge 1 commit into
microsoft:mainfrom
liuzhengyang699:fix/scienceworld-action-stop
Open

Zhengyang Liu (liuzhengyang699) wants to merge 1 commit into
microsoft:mainfrom
liuzhengyang699:fix/scienceworld-action-stop

Conversation

@liuzhengyang699

Copy link
Copy Markdown

Fixes #685.

A valid ScienceWorld reply such as ### ACTION: 2 ###\n loses its closing ### when vLLM applies the configured stop string. The strict parser then falls back to action zero, so the environment executes a different action from the one the model selected.

Request include_stop_str_in_output=True so the returned reply retains the delimiter. The stop strings, strict action format, and invalid-action fallback remain the same. The regression test runs two agent turns through the actual OpenAI SDK and an HTTP mock that models stop-string filtering, then checks the executed actions, conversation history, and reported reward.

Before the fix, both newline variants fail while the EOS control passes. With the fix, the full CPU suite passes.

Validation

  • uv run --locked --no-sync pytest -v --durations=20 tests — 248 passed, 4 skipped.
  • uv run --locked --no-sync pyright — 0 errors, 0 warnings.
  • uv run --locked --no-sync pre-commit run --all-files --show-diff-on-failure — passed.
  • uv run --locked --no-sync ruff check ., uv run --locked --no-sync ruff format --check ., and uv run --locked --no-sync python scripts/check_headers.py — passed.
  • UV_PROJECT_ENVIRONMENT=/tmp/agent-lightning-scienceworld-docs uv run --locked --no-sync mkdocs build --strict, uv build --no-sources, and git diff --cached --check — passed.

This was found during a follow-up audit of the examples with AI assistance. I used AI assistance for the fix and regression tests as well. The tests use a fake ScienceWorld environment; no live Java environment, model inference, or GPU training was run.

@liuzhengyang699
Zhengyang Liu (liuzhengyang699) marked this pull request as ready for review November 7, 2026 06:30
Copilot AI balanced review requested due to automatic review settings November 7, 2026 06:30

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.

🟢 Approval recommended

No active review issues are identified for the change to preserve ScienceWorld action delimiters in vLLM replies.

No open issues 🎉

What changed in this PR

Fixes #685 by preserving ScienceWorld action delimiters in vLLM replies, preventing valid model-selected actions from incorrectly falling back to action zero.

Changes:

  • Requests include_stop_str_in_output=True while retaining the existing stop strings and strict parser.
  • Adds regression tests for newline-terminated and EOS replies, two-turn action execution, conversation history, reward reporting, and invalid-action fallback.
  • Documents delimiter preservation and fallback behavior.
File Description
tests/​examples/​test_science_world_agent.py Adds OpenAI SDK and HTTP-mock regression tests for action selection.
examples/​science_world/​agents/​sw_agent.py Requests retention of matched stop strings.
docs/​60-example-science-world.md Explains action formatting, delimiter retention, and fallback behavior.

Review effort: Balanced

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.

ScienceWorld stop strings strip the action delimiter and select action zero

2 participants