Skip to content

[fix] fix truncate function return routed expert#1069

Open
zyzshishui wants to merge 1 commit intoradixark:mainfrom
zyzshishui:fix-truncate-overshoot
Open

[fix] fix truncate function return routed expert#1069
zyzshishui wants to merge 1 commit intoradixark:mainfrom
zyzshishui:fix-truncate-overshoot

Conversation

@zyzshishui
Copy link
Copy Markdown
Contributor

@zyzshishui zyzshishui commented May 5, 2026

Replace the inline _truncate_sample_output helper with Sample.strip_last_output_tokens. The helper takes the count to strip from the end, so pass overshoot (= response_length - allowed_output), not allowed_output itself.

Fix #861

…_tokens

Replace the inline _truncate_sample_output helper with
Sample.strip_last_output_tokens. The helper takes the count to strip
from the end, so pass overshoot (= response_length - allowed_output),
not allowed_output itself.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@guapisolo guapisolo added the enhancement New feature or request label May 5, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the sample truncation logic in openai_endpoint_utils.py by replacing the internal _truncate_sample_output function with the Sample.strip_last_output_tokens method. Feedback suggests moving the assignment of the TRUNCATED status into the strip_last_output_tokens method itself to prevent logic duplication and ensure consistency across the codebase.

Comment thread miles/rollout/generate_utils/openai_endpoint_utils.py
@zyzshishui zyzshishui changed the title [fix] fix truncate utils [fix] fix truncate function return routed expert May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

_truncate_sample_output does not truncate rollout_routed_experts

2 participants