Skip to content

Apply filter_overlong_prompts in multiturn rollout setting#5965

Open
HwCARI wants to merge 2 commits intoverl-project:mainfrom
HwCARI:tool-agent-loop
Open

Apply filter_overlong_prompts in multiturn rollout setting#5965
HwCARI wants to merge 2 commits intoverl-project:mainfrom
HwCARI:tool-agent-loop

Conversation

@HwCARI
Copy link
Copy Markdown

@HwCARI HwCARI commented Apr 11, 2026

What does this PR do?

Fixes #2069.

filter_overlong_prompts was silently skipped in the multiturn setting in verl/verl/experimental/agent_loop/tool_agent_loop.py, causing prompts exceeding data.max_prompt_length to pass through unfiltered. This resulted in tensor size mismatches downstream when batching sequences:

RuntimeError: Sizes of tensors must match except in dimension 0.
Expected size 2048 but got size 2106 for tensor number 2 in the list.

This PR ensures the overlong prompt filter is applied consistently regardless of whether multiturn tool use is enabled.

Fix

Apply filter_overlong_prompts in verl/verl/experimental/agent_loop/tool_agent_loop.py.

Checklist Before Starting

  • Search for similar PRs. Paste at least one query link here: ...
  • Format the PR title as [{modules}] {type}: {description} (This will be checked by the CI)
    • {modules} include fsdp, megatron, veomni, sglang, vllm, rollout, trainer, ci, training_utils, recipe, hardware, deployment, ray, worker, single_controller, misc, perf, model, algo, env, tool, ckpt, doc, data, cfg, reward, fully_async, one_step_off
    • If this PR involves multiple modules, separate them with , like [megatron, fsdp, doc]
    • {type} is in feat, fix, refactor, chore, test
    • If this PR breaks any API (CLI arguments, config, function signature, etc.), add [BREAKING] to the beginning of the title.
    • Example: [BREAKING][fsdp, megatron] feat: dynamic batching

Test

For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc.

API and Usage Example

Demonstrate how the API changes if any, and provide usage example(s) if possible.

# Add code snippet or script demonstrating how to use this

Design & Code Changes

Demonstrate the high-level design if this PR is complex, and list the specific changes.

Checklist Before Submitting

Important

Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review.

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 introduces prompt truncation logic to the ToolAgentLoop to handle long prompts and prevent crashes. Feedback highlights that self.rollout_config.prompt_length should be used as the truncation limit for consistency with the rollout pipeline. A bug was also identified where an undefined variable self.max_prompt_length would cause an AttributeError. Furthermore, the truncation logic should be extended to cover multi-turn conversation history to ensure the prompt remains within bounds throughout the interaction.

@HwCARI
Copy link
Copy Markdown
Author

HwCARI commented Apr 14, 2026

@wuxibin89 and @ArronHZG, Could you please review this PR? Thanks

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.

filter_overlong_prompts not working in multiturn setting — leads to tensor size mismatch

2 participants