[tool, rollout] fix: handle optional interaction kwargs#5360
[tool, rollout] fix: handle optional interaction kwargs#5360denismegerle wants to merge 4 commits intoverl-project:mainfrom
Conversation
…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>
|
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. |
There was a problem hiding this comment.
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.
| interaction_kwargs = kwargs["extra_info"].get("interaction_kwargs", None) or {} | ||
| interaction_name = interaction_kwargs.get("name", None) |
There was a problem hiding this comment.
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.
| 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") |
| interaction_kwargs = kwargs["extra_info"].get("interaction_kwargs", None) or {} | ||
| interaction_name = interaction_kwargs.get("name", None) |
There was a problem hiding this comment.
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.
| 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") |
What does this PR do?
Checklist Before Starting
[{modules}] {type}: {description}(This will be checked by the CI){modules}includefsdp,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,like[megatron, fsdp, doc]{type}is infeat,fix,refactor,chore,test[BREAKING]to the beginning of the title.[BREAKING][fsdp, megatron] feat: dynamic batchingTest
pre-commit run --all-files --show-diff-on-failure --color=alwaystests/experimental/agent_loop/test_tool_agent_loop_interaction_kwargs_on_cpu.pyAPI and Usage Example
Design & Code Changes
interaction_kwargsoptional when an interaction config is present.INTERACTING/ process assistant messages when an interaction is actually initialized.interaction_kwargs.nameto 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.
pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=alwaysci-requestchannel in theverlSlack workspace. (If not accessible, please try the Feishu group (飞书群).)recipesubmodule, please also update the reference to the submodule commit viagit submodule update --remoteorcd recipe && git pull origin main.