Commit 9dd447e
[tool] fix: handle empty image inputs in ToolAgentLoop (#5420)
### What does this PR do?
> Fixes a compatibility issue in `ToolAgentLoop`, downstream
image-processing pipelines require passing passing `images=None`
(instead of an empty list) when a tool call returns no new images.
### Checklist Before Starting
- [x] Search for similar PRs. Paste at least one query link here:
https://github.com/verl-project/verl/pulls?q=is%3Apr+ToolAgentLoop+images+None
- [x] 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`
- 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
> Not covered by an existing upstream test in this PR. Change is a
narrow input-normalization to `apply_chat_template(images=...)` when no
images are produced.
### API and Usage Example
> No API change.
```python
# No API changes. Behavior change: images passed to chat template is None when empty.
```
### Design & Code Changes
> - In `verl/experimental/agent_loop/tool_agent_loop.py`, normalize
`images` to `None` when `new_images_this_turn` is empty.
### Checklist Before Submitting
> [!IMPORTANT]
> Please check all the following items before requesting a review,
otherwise the reviewer might deprioritize this PR for review.
- [x] Read the [Contribute
Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md).
- [x] Apply [pre-commit
checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting):
`pre-commit install && pre-commit run --all-files --show-diff-on-failure
--color=always`
- [x] (not required) Add / Update [the
documentation](https://github.com/volcengine/verl/tree/main/docs).
- [x] (not required) Add unit or end-to-end test(s) to [the CI
workflow](https://github.com/volcengine/verl/tree/main/.github/workflows)
to cover all the code. If not feasible, explain why: not feasible
quickly here because current agent-loop tests stub the tokenizer and
don't assert image/video kwargs flow; can be added if maintainers want
it.
- [ ] Once your PR is ready for CI, send a message in [the `ci-request`
channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the
`verl` Slack
workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ).
(If not accessible, please try [the Feishu group
(飞书群)](https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=772jd4f1-cd91-441e-a820-498c6614126a).)
- [x] (not related) If your PR is related to the `recipe` submodule,
please also update the reference to the submodule commit via `git
submodule update --remote` or `cd recipe && git pull origin main`.
Co-authored-by: Denis Megerle <denis.megerle@deepl.com>1 parent 32705dc commit 9dd447e
1 file changed
+6
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
356 | 360 | | |
357 | 361 | | |
358 | | - | |
359 | | - | |
| 362 | + | |
| 363 | + | |
360 | 364 | | |
361 | 365 | | |
362 | 366 | | |
| |||
0 commit comments