Skip to content

fix: (1) strip whitespace when parsing action_stop_tokens (2) avoid truncation could split multimodal placeholder token sequences #147

Open
zengxingchen wants to merge 2 commits intoTIGER-AI-Lab:mainfrom
zengxingchen:main
Open

fix: (1) strip whitespace when parsing action_stop_tokens (2) avoid truncation could split multimodal placeholder token sequences #147
zengxingchen wants to merge 2 commits intoTIGER-AI-Lab:mainfrom
zengxingchen:main

Conversation

@zengxingchen
Copy link

@zengxingchen zengxingchen commented Jan 31, 2026

Problem1

When configuring action_stop_tokens with comma-separated values like:action_stop_tokens='</code>, </search>'
The parser was not stripping whitespace, resulting in:
Token 1: </code>
Token 2: </search> ❌ (with leading space)
This caused the model to fail to stop at , leading to incorrect behavior.

Solution1

Modified the token parsing logic in verltool_agent_loop.py (line 173) to strip whitespace:

# Before
cls.action_stop_tokens = [x for x in f.read().split(',') if x]

# After  
cls.action_stop_tokens = [x.strip() for x in f.read().split(',') if x.strip()]

Problem1

Similar to bugs identified in verl-project/verl#4050.
When truncating agent responses to fit within response_length limits, the truncation could split multimodal placeholder token sequences (e.g., <|vision_start|><|image_pad|><|vision_end|>) in the middle. This causes lots of issues.

Solution2

When truncating responses by response_length, walk backwards to avoid cutting multimodal placeholder tokens (e.g., <|vision_start|>, <|image_pad|>, <|vision_end|>, <|audio_bos|>, etc.) in half.

This ensures that multimodal token sequences are either kept completely or discarded as complete blocks, preventing token corruption that could cause model errors during training.

@zengxingchen zengxingchen changed the title fix: strip whitespace when parsing action_stop_tokens fix: (1) strip whitespace when parsing action_stop_tokens (2) avoid truncation could split multimodal placeholder token sequences Jan 31, 2026
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.

1 participant