Skip to content

[tool, rollout] fix: handle optional interaction kwargs#5360

Open
denismegerle wants to merge 4 commits intoverl-project:mainfrom
denismegerle:public/allow-mix-interaction-loop
Open

[tool, rollout] fix: handle optional interaction kwargs#5360
denismegerle wants to merge 4 commits intoverl-project:mainfrom
denismegerle:public/allow-mix-interaction-loop

Conversation

@denismegerle
Copy link
Contributor

@denismegerle denismegerle commented Feb 20, 2026

What does this PR do?

Improves robustness of multi-turn tool agent loops when using an interaction config: samples without extra_info.interaction_kwargs are treated as having no interaction, while misconfigured interaction_kwargs.name values fail fast.

Checklist Before Starting

  • Search for similar PRs. Paste at least one query link here: https://github.com/verl-project/verl/pulls?q=is%3Apr+ToolAgentLoop+interaction_kwargs
  • 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

  • pre-commit run --all-files --show-diff-on-failure --color=always
  • Added CPU unit test: tests/experimental/agent_loop/test_tool_agent_loop_interaction_kwargs_on_cpu.py

API and Usage Example

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

# When interaction_config_path is set, rows can omit interaction configuration:
extra_info = {}

# Rows that want interaction should provide a valid name:
extra_info = {"interaction_kwargs": {"name": "weather"}}

# If a name is provided but not configured, the loop now raises ValueError.

Design & Code Changes

  • Make interaction_kwargs optional when an interaction config is present.
  • Only enter INTERACTING / process assistant messages when an interaction is actually initialized.
  • Raise on unknown interaction_kwargs.name to avoid silently skipping misconfigurations.

Checklist Before Submitting

Important

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

Denis Megerle and others added 4 commits February 20, 2026 15:07
…ialToolAgentLoop

- Updated interaction_kwargs initialization to allow for missing interaction configurations.
- Simplified interaction name retrieval and validation.
- Adjusted state determination logic to ensure proper handling of interactions.

These changes enhance flexibility in handling datasets with varying interaction configurations.
- Updated condition to check for non-null interaction data before processing assistant messages.
- This change ensures that interactions are only handled when valid interaction data is present, improving robustness in the agent loop.

These modifications build on previous refactoring efforts to improve interaction handling.
Restore strict validation when interaction name is provided but not present in the configured interaction map.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add a lightweight async unit test to ensure missing interaction kwargs are tolerated while unknown interaction names raise.

Co-authored-by: Cursor <cursoragent@cursor.com>
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Denis Megerle seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@denismegerle denismegerle marked this pull request as ready for review February 20, 2026 14:11
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

The pull request correctly addresses the handling of optional interaction configurations in the tool agent loops. By guarding the interaction initialization and state transitions, it allows for datasets with mixed interaction requirements. The addition of a fail-fast check for unknown interaction names improves error reporting. I have suggested a minor refinement to ensure the code is robust against missing or null extra_info fields.

Comment on lines +151 to +152
interaction_kwargs = kwargs["extra_info"].get("interaction_kwargs", None) or {}
interaction_name = interaction_kwargs.get("name", None)
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Accessing kwargs["extra_info"] directly can raise a KeyError if the key is missing, or an AttributeError if extra_info is None. Since this PR aims to improve robustness for optional configurations, it is safer to handle these cases explicitly to avoid crashes on minimal or null input data.

Suggested change
interaction_kwargs = kwargs["extra_info"].get("interaction_kwargs", None) or {}
interaction_name = interaction_kwargs.get("name", None)
extra_info = kwargs.get("extra_info") or {}
interaction_kwargs = extra_info.get("interaction_kwargs") or {}
interaction_name = interaction_kwargs.get("name")

Comment on lines +97 to +98
interaction_kwargs = kwargs["extra_info"].get("interaction_kwargs", None) or {}
interaction_name = interaction_kwargs.get("name", None)
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Accessing kwargs["extra_info"] directly can raise a KeyError if the key is missing, or an AttributeError if extra_info is None. It is recommended to use a safer extraction method to ensure the loop handles samples without any extra info gracefully.

Suggested change
interaction_kwargs = kwargs["extra_info"].get("interaction_kwargs", None) or {}
interaction_name = interaction_kwargs.get("name", None)
extra_info = kwargs.get("extra_info") or {}
interaction_kwargs = extra_info.get("interaction_kwargs") or {}
interaction_name = interaction_kwargs.get("name")

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.

2 participants