Repository navigation
fix(science-world): preserve action delimiters in stopped replies - #686
Open
Zhengyang Liu (liuzhengyang699) wants to merge 1 commit into
Open
Zhengyang Liu (liuzhengyang699) wants to merge 1 commit into
Zhengyang Liu (liuzhengyang699) wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟢 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=Truewhile 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #685.
A valid ScienceWorld reply such as
### ACTION: 2 ###\nloses 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=Trueso 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 ., anduv 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, andgit 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.