Skip to content

[tool] feat: add image zoom in tool#2372

Closed
xieck13 wants to merge 1 commit intoverl-project:mainfrom
nanjiangwill:feat/add-image-zoom-in-tool
Closed

[tool] feat: add image zoom in tool#2372
xieck13 wants to merge 1 commit intoverl-project:mainfrom
nanjiangwill:feat/add-image-zoom-in-tool

Conversation

@xieck13
Copy link
Contributor

@xieck13 xieck13 commented Jul 5, 2025

What does this PR do?

This PR builds upon #2146 to implement an image zoom in tool that can be called during multi-turn VLM interactions. Based on DeepEyes (https://github.com/Visual-Agent/DeepEyes, https://arxiv.org/abs/2505.14362), this tool enables verification of image-related responses through dynamic zooming capabilities.

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, sglang, vllm, rollout, trainer, ci, training_utils, recipe, hardware, deployment, ray, worker, single_controller, misc, perf, model, algo, env, tool, ckpt, doc, data
    • 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

High-Level Design

Demonstrate the high-level design if this PR is complex.

Specific Changes

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
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 PR adds a new ImageZoomInTool for zooming into images, along with its configuration. The implementation of the tool in verl/tools/image_zoom_in_tool.py has a few critical and high-severity issues. These include a path traversal vulnerability and incorrect method return types that will cause TypeErrors. I've provided specific suggestions to address these issues to improve the correctness and security of the new tool.

"response": "",
"reward": 0.0,
}
return instance_id, None
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The method's type hint is -> str, but it returns a tuple (instance_id, None). This will lead to a TypeError where the function is called. The base class BaseTool.create also specifies a str return type. The method should only return the instance_id to match the declared type hint and the base class implementation.

Suggested change
return instance_id, None
return instance_id

try:
left, top, right, bottom = bbox_2d
cropped_image = image.crop((left, top, right, bottom))
cropped_image.save(f"cropped_image_{instance_id}.png")
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

This line is vulnerable to path traversal. The create method allows instance_id to be passed as an argument. If a malicious instance_id such as ../../tmp/pwned is provided, this could allow writing files outside of the intended directory.

You should sanitize instance_id before using it in a file path, for example with os.path.basename(instance_id).

Additionally, writing files to the current working directory is a side effect that can be problematic (e.g., filling up disk space, permissions issues). It would be safer to use a temporary directory via the tempfile module.

}
return instance_id, None

async def execute(self, instance_id: str, parameters: dict[str, Any], **kwargs) -> Tuple[str, float, dict]:
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The method signature indicates a return type of Tuple[str, float, dict], but the implementation can return a dict as the first element of the tuple (on lines 97 and 102). This violates the type hint and can lead to unexpected behavior in code that relies on this type hint. Please update the type hint to Tuple[Union[str, dict], float, dict] to reflect the actual return types. You will need to add Union to the typing import.

Suggested change
async def execute(self, instance_id: str, parameters: dict[str, Any], **kwargs) -> Tuple[str, float, dict]:
async def execute(self, instance_id: str, parameters: dict[str, Any], **kwargs) -> Tuple[Union[str, dict], float, dict]:

@xieck13 xieck13 closed this Jul 7, 2025
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