Skip to content

[example] Alfworld with General Multi-Step Workflow#169

Merged
hiyuchang merged 9 commits intoagentscope-ai:mainfrom
hiyuchang:feat/alfworldv2
Aug 13, 2025
Merged

[example] Alfworld with General Multi-Step Workflow#169
hiyuchang merged 9 commits intoagentscope-ai:mainfrom
hiyuchang:feat/alfworldv2

Conversation

@hiyuchang
Copy link
Collaborator

@hiyuchang hiyuchang commented Aug 7, 2025

Description

[Please describe the background, purpose, changes made, and how to test this PR]

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has passed all tests
  • Docstrings have been added/updated in Google Style
  • Documentation has been updated
  • Code is ready 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.

Summary of Changes

Hello @hiyuchang, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant update to the Alfworld example, migrating it to a more generalized multi-step workflow architecture. This involves creating a new workflow class that leverages a common reward propagation mechanism, alongside new configuration files to support this setup. Additionally, it includes temporary, explicit modifications to batch size calculations to accommodate current framework limitations, with a clear intent for future refinement.

Highlights

  • New Alfworld Workflow Implementation: Introduced AlfworldWorkflowV2, a new version of the Alfworld workflow that inherits from RewardPropagationWorkflow. This refactors the environment interaction to a more general, step-wise multi-turn approach, managing environment state, model responses, and reward calculation within the workflow.
  • Dedicated Example and Configuration: Added a new example directory (examples/grpo_alfworld_general_multi_step) complete with a README.md and new configuration files (alfworld.yaml, train_alfworld.yaml). These files are set up to use the new alfworld_workflow_v2 and demonstrate its integration into the training pipeline.
  • Temporary Batch Size Adjustments: Implemented temporary, hardcoded adjustments to several batch sizes (read_batch_size, train_batch_size, ppo_mini_batch_size) by multiplying them by 30 in trinity/common/config.py and trinity/common/verl_config.py. These changes are accompanied by warning messages, indicating they are invasive and will be addressed in a future framework update.
  • Enhanced Workflow Metrics: Modified the RewardPropagationWorkflow to record actual_env_steps within the experience metrics. This provides more granular data on the number of steps taken in the environment during each episode.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

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 pull request introduces a new example for Alfworld using a general multi-step workflow, which is a great addition. The new AlfworldWorkflowV2 is well-structured and leverages the RewardPropagationWorkflow.

My main feedback revolves around several hardcoded values, particularly the multiplier 30 used for batch size calculations in the core configuration files. As noted in the new README, this is a temporary solution, but it's critical to address this to maintain the framework's generality. I've provided suggestions to make these values configurable by reading max_env_steps from the workflow's arguments.

Additionally, I've pointed out a few smaller issues in the new workflow implementation, such as other hardcoded values and an unused variable, to improve code quality and maintainability.

@pan-x-c pan-x-c requested a review from Copilot August 12, 2025 09:49
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces general multi-step workflow support for ALFWorld with Trinity-RFT framework, enabling step-wise training on environment interaction tasks. It refactors the existing ALFWorld workflow to use the RewardPropagationWorkflow base class and includes comprehensive documentation and examples.

  • Added StepWiseAlfworldWorkflow that inherits from RewardPropagationWorkflow for step-wise environment interactions
  • Enhanced base workflow classes with optional OpenAI client usage configuration
  • Added comprehensive documentation and example configurations for general multi-step training

Reviewed Changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
trinity/common/workflows/step_wise_workflow.py Added optional OpenAI client configuration and experience metrics tracking
trinity/common/workflows/envs/alfworld/alfworld_workflow.py Implemented new StepWiseAlfworldWorkflow using RewardPropagationWorkflow base class
trinity/common/workflows/init.py Exported the new StepWiseAlfworldWorkflow class
trinity/common/verl_config.py Fixed comment typo and synchronized train_batch_size configuration
examples/grpo_alfworld_general_multi_step/ Added complete example configuration and documentation for multi-step ALFWorld training
docs/sphinx_doc/source/tutorial/ Added comprehensive tutorials for general multi-step workflows and ReAct agents
README.md / README_zh.md Updated with links to new multi-step workflow tutorials

@hiyuchang
Copy link
Collaborator Author

/unittest-module-common

@github-actions
Copy link

Summary

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Other ❓ Flaky 🍂 Duration ⏱️
26 26 0 0 0 0 299ms

Tests

Test Name Status Flaky Duration
tests/common/config_test.py::TestConfig::test_all_examples_are_valid 2ms
tests/common/config_test.py::TestConfig::test_config_flatten 1ms
tests/common/config_test.py::TestConfig::test_continue_from_checkpoint_is_valid 1ms
tests/common/config_test.py::TestConfig::test_load_default_config 6ms
tests/common/experience_test.py::TestEID::test_eid_properties 1ms
tests/common/experience_test.py::TestExperience::test_action_mask_and_logprobs_type 1ms
tests/common/experience_test.py::TestExperience::test_assertions 1ms
tests/common/experience_test.py::TestExperience::test_dpo_experience 1ms
tests/common/experience_test.py::TestExperience::test_gather 1ms
tests/common/experience_test.py::TestExperience::test_multi_turn_experience 1ms
tests/common/experience_test.py::TestExperience::test_serialize_deserialize 1ms
tests/common/experience_test.py::TestExperience::test_single_turn_experience 1ms
tests/common/experience_test.py::TestExperience::test_to_dict 1ms
tests/common/experience_test.py::TestExperienceConversion::test_batch_conversion 1ms
tests/common/experience_test.py::TestExperienceConversion::test_dpo_experience_batch_conversion 1ms
tests/common/experience_test.py::TestExperienceConversion::test_experience_model_experience_conversion 1ms
tests/common/experience_test.py::TestExperienceConversion::test_multiturn_experience_batch_converstion 1ms
tests/common/vllm_test.py::ModelWrapperTest_0::test_generate 36ms
tests/common/vllm_test.py::ModelWrapperTest_1::test_generate 53ms
tests/common/vllm_test.py::ModelWrapperTest_2::test_generate 47ms
tests/common/vllm_test.py::ModelWrapperTest_3::test_generate 36ms
tests/common/vllm_test.py::ModelWrapperTest_4::test_generate 45ms
tests/common/vllm_test.py::TestAPIServer::test_api 24ms
tests/common/vllm_test.py::TestTokenizer::test_assistant_token_mask 1ms
tests/common/vllm_test.py::TestAPIServerToolCall_0_deepseek_r1::test_api_tool_calls 21ms
tests/common/vllm_test.py::TestAPIServerToolCall_1::test_api_tool_calls 19ms

Github Test Reporter by CTRF 💚

@hiyuchang hiyuchang merged commit 331ffd6 into agentscope-ai:main Aug 13, 2025
2 checks passed
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

Comments