Skip to content

refactor agentjet job system#11

Merged
binary-husky merged 11 commits intomainfrom
refactor-agentjet-job
Mar 4, 2026
Merged

refactor agentjet job system#11
binary-husky merged 11 commits intomainfrom
refactor-agentjet-job

Conversation

@binary-husky
Copy link
Collaborator

No description provided.

@gemini-code-assist
Copy link

Summary of Changes

Hello, 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 refactors the core AgentJet job system to enhance its configurability and stability. It streamlines the naming of a key interchange server feature and overhauls the AgentJetJob class for more flexible configuration management. Additionally, a new multi-agent Werewolves game example is introduced, serving as a practical demonstration of the improved system's capabilities in handling complex, distributed agent training scenarios.

Highlights

  • Interchange Server Flag Renaming: The configuration flag enable_experimental_interchange_server has been renamed to enable_interchange_server across the codebase, indicating a move from experimental to a more stable feature.
  • AgentJetJob Class Refactoring: The AgentJetJob class in ajet/copilot/job.py has been significantly refactored to support a more flexible and dynamic configuration override mechanism, moving away from direct parameter assignments in its constructor. The tune method was also removed.
  • Default Configuration Updates: Default YAML configuration files (ajet_default.yaml, ajet_ts_default.yaml) have been updated to reflect the interchange server flag rename, adjust default model paths, and introduce new data and trainer common configurations. Chinese comments in various YAML files were also translated to English.
  • New Multi-Agent Werewolves Swarm Example: A comprehensive new example for a multi-agent Werewolves game has been added, demonstrating the use of the AgentJetJob system and SwarmClient for distributed training in a complex game environment.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • ajet/backbone/main_trinity.py
    • Updated the interchange server configuration flag name.
  • ajet/backbone/main_verl.py
    • Updated the interchange server configuration flag name in two locations.
  • ajet/backbone/main_vllm.py
    • Updated the interchange server configuration flag name.
  • ajet/backbone/trainer_verl.py
    • Updated the interchange server configuration flag name in a method and a commented line.
  • ajet/backbone/warm_up.py
    • Updated the interchange server configuration flag name.
  • ajet/copilot/job.py
    • Reordered imports and added new utility functions for nested attribute handling.
    • Refactored the AgentJetJob constructor to use a dynamic configuration override system.
    • Removed the tune method from the AgentJetJob class.
    • Updated build_job_from_yaml to use new experiment attributes.
  • ajet/default_config/ajet_default.yaml
    • Renamed the experimental interchange server flag to enable_interchange_server.
  • ajet/default_config/ajet_ts_default.yaml
    • Changed the default backbone from 'debug' to 'verl'.
    • Updated the default model path.
    • Renamed the experimental interchange server flag to enable_interchange_server.
    • Added new data and trainer_common configuration sections.
    • Translated comments from Chinese to English.
  • ajet/launcher.py
    • Updated the interchange server configuration flag name in an assertion.
  • ajet/swarm_cli.py
    • Updated the interchange server configuration flag name in an assertion.
  • ajet/tuner.py
    • Updated the interchange server configuration flag name in the constructor.
    • Modified an assertion message related to the interchange server.
    • Renamed the internal method _enable_experimental_interchange_server to _enable_interchange_server.
  • ajet/tuner_lib/experimental/as_swarm_client.py
    • Updated the sample collection method attribute name in _check_throttle_policy.
  • ajet/utils/core_env_vars.py
    • Updated the interchange server configuration flag name.
  • docs/en/support_agentscope.md
    • Updated the interchange server configuration flag name in documentation.
  • docs/en/support_http.md
    • Updated the interchange server configuration flag name in documentation.
  • docs/en/support_langchain.md
    • Updated the interchange server configuration flag name in documentation.
  • docs/en/support_oaisdk.md
    • Updated the interchange server configuration flag name in documentation.
  • tests/bench/benchmark_appworld/benchmark_appworld.yaml
    • Translated comments from Chinese to English.
  • tests/bench/benchmark_appworld/benchmark_appworld_2nodes.yaml
    • Translated comments from Chinese to English.
  • tests/bench/benchmark_appworld/benchmark_appworld_oai_sdk.yaml
    • Translated comments from Chinese to English.
  • tests/bench/benchmark_countdown/benchmark_countdown.yaml
    • Translated comments from Chinese to English.
  • tests/bench/benchmark_learn2ask/benchmark_learn2ask.yaml
    • Translated comments from Chinese to English.
  • tests/bench/benchmark_math/benchmark_math.yaml
    • Translated comments from Chinese to English.
  • tests/bench/benchmark_math/benchmark_math_oai_sdk.yaml
    • Translated comments from Chinese to English.
  • tests/bench/benchmark_math/benchmark_math_raw_http.yaml
    • Translated comments from Chinese to English.
  • tutorial/example_appworld/appworld.yaml
    • Translated comments from Chinese to English.
  • tutorial/example_appworld/appworld_oai_sdk.yaml
    • Translated comments from Chinese to English.
  • tutorial/example_countdown/countdown.yaml
    • Translated comments from Chinese to English.
  • tutorial/example_deep_finance/deep_finance.yaml
    • Translated comments from Chinese to English.
  • tutorial/example_deep_finance/yaml_template/deep_finance_template.yaml
    • Translated comments from Chinese to English.
  • tutorial/example_deep_finance/yaml_template/deep_finance_template_maxlen.yaml
    • Translated comments from Chinese to English.
  • tutorial/example_deep_finance/yaml_template/infer.yaml
    • Translated comments from Chinese to English.
  • tutorial/example_feedback_tracing/example_feedback_tracing.yaml
    • Translated comments from Chinese to English.
  • tutorial/example_learn2ask/learn2ask.yaml
    • Translated comments from Chinese to English.
  • tutorial/example_rubrics_judge/r_judge.yaml
    • Translated comments from Chinese to English.
  • tutorial/example_werewolves_swarm/agent_roll.py
    • Added new file defining the agent rollout logic for the Werewolves swarm example.
  • tutorial/example_werewolves_swarm/game.py
    • Added new file implementing the core game logic for the Werewolves swarm example.
  • tutorial/example_werewolves_swarm/prompt.py
    • Added new file containing English and Chinese prompts for the Werewolves swarm game.
  • tutorial/example_werewolves_swarm/start.py
    • Added new file defining the main entry point and workflow for the Werewolves swarm example.
  • tutorial/example_werewolves_swarm/structured_model.py
    • Added new file defining Pydantic models for structured outputs in the Werewolves swarm game.
  • tutorial/example_werewolves_swarm/utils.py
    • Added new file containing utility functions for the Werewolves swarm game, including player management and voting.
  • tutorial/example_werewolves_swarm/werewolves.md
    • Added new documentation file for the Werewolves swarm example.
  • tutorial/example_werewolves_swarm/werewolves.yaml
    • Added new configuration file for the Werewolves swarm example.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

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

@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 significant and valuable refactoring of the AgentJetJob class, making it more flexible by loading configurations from a base YAML file and allowing overrides via keyword arguments. This is a great improvement for usability. The consistent renaming of enable_experimental_interchange_server to enable_interchange_server across the codebase improves clarity. The removal of the tune method from AgentJetJob is a good design choice, separating configuration from execution. The addition of the new werewolves_swarm example is a great showcase of the system's capabilities. However, the refactoring of AgentJetJob has introduced a critical bug in the initialization logic that needs to be addressed. I've also noted a few minor issues in the new example code.

Comment on lines +79 to 80
self.config_as_dict: dict = self.build_job_from_yaml(base_yaml_config)
self.config = Config.update_from_dict_recursive(Config(), self.config_as_dict)

Choose a reason for hiding this comment

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

critical

There's a critical bug in the __init__ method's logic. The call to self.build_job_from_yaml(base_yaml_config) on line 79 happens before the instance attributes it depends on (like self.experiment_name, self.backbone, and self.experiment_dir) are initialized. These attributes are only assigned values later in the method.

This will lead to an AttributeError when build_job_from_yaml is called, as it tries to access these uninitialized attributes. The logic has a circular dependency:

  1. build_job_from_yaml is called to create self.config.
  2. build_job_from_yaml needs attributes like self.experiment_dir.
  3. The final value of self.experiment_dir is determined by the override logic (lines 112-128).
  4. The override logic needs self.config to get the base value from the YAML.

This initialization flow needs to be re-architected to resolve this circular dependency. A possible approach is to first determine the values for parameters required for loading the configuration (like experiment_name, backbone, experiment_dir) by checking the __init__ arguments, and then use them to call read_ajet_hierarchical_config. After the config is loaded, the rest of the parameters can be overridden.

Comment on lines +58 to +59
except:
pass

Choose a reason for hiding this comment

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

high

Using a bare except: is dangerous as it catches all exceptions, including system-exiting ones like SystemExit and KeyboardInterrupt, making it hard to debug and stop the program. It's better to catch Exception at the very least and log the error for debugging purposes.

Suggested change
except:
pass
except Exception as e:
print(f"Error during rollout for task {task.task_id}: {e}")

default_yaml = None
self.config_as_dict: dict = self.build_job_from_yaml(default_yaml)
logger.warning(f"Reading config from {base_yaml_config}.")
time.sleep(1)

Choose a reason for hiding this comment

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

medium

The time.sleep(1) here is a code smell. Sleeps like this are often used to work around race conditions or to ensure a log message is visible before a potential crash. This can hide underlying issues and make the code's behavior dependent on timing. It would be better to identify and fix the root cause rather than using a sleep.

Comment on lines +106 to +112
default_model = OpenAIChatModel(
model_name="/mnt/data_cpfs/model_cache/modelscope/hub/Qwen/Qwen/Qwen3-235B-A22B-Instruct-2507/",
stream=False,
client_args={"base_url": "http://22.17.52.4:2888/v1"},
api_key="no_api_key",
generate_kwargs={"temperature": 0.01},
)

Choose a reason for hiding this comment

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

medium

The default_model configuration contains a hardcoded model path and a hardcoded URL. This makes the example less portable and harder to run in different environments. It would be better to fetch these values from environment variables or a configuration file. You'll need to add import os at the top of the file.

Suggested change
default_model = OpenAIChatModel(
model_name="/mnt/data_cpfs/model_cache/modelscope/hub/Qwen/Qwen/Qwen3-235B-A22B-Instruct-2507/",
stream=False,
client_args={"base_url": "http://22.17.52.4:2888/v1"},
api_key="no_api_key",
generate_kwargs={"temperature": 0.01},
)
default_model = OpenAIChatModel(
model_name=os.getenv("AJET_DEFAULT_MODEL_PATH", "/mnt/data_cpfs/model_cache/modelscope/hub/Qwen/Qwen/Qwen3-235B-A22B-Instruct-2507/"),
stream=False,
client_args={"base_url": os.getenv("AJET_DEFAULT_MODEL_URL", "http://22.17.52.4:2888/v1")},
api_key="no_api_key",
generate_kwargs={"temperature": 0.01},
)

@binary-husky binary-husky force-pushed the refactor-agentjet-job branch from 5a55295 to 76d0e3f Compare March 4, 2026 09:01
@binary-husky binary-husky merged commit d10b5bc into main Mar 4, 2026
0 of 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.

1 participant