FoundationAgents/MetaGPT · error · ValueError

Please set your config in config2.yaml

Error message

Please set your config in config2.yaml

What it means

Error "Please set your config in config2.yaml" thrown in FoundationAgents/MetaGPT.

Source

Thrown at metagpt/utils/yaml_model.py:47

    def from_yaml_file(cls, file_path: Path) -> "YamlModel":
        """Read yaml file and return a YamlModel instance"""
        return cls(**cls.read_yaml(file_path))

    def to_yaml_file(self, file_path: Path, encoding: str = "utf-8") -> None:
        """Dump YamlModel instance to yaml file"""
        with open(file_path, "w", encoding=encoding) as file:
            yaml.dump(self.model_dump(), file)


class YamlModelWithoutDefault(YamlModel):
    """YamlModel without default values"""

    @model_validator(mode="before")
    @classmethod
    def check_not_default_config(cls, values):
        """Check if there is any default config in config2.yaml"""
        if any(["YOUR" in v for v in values]):
            raise ValueError("Please set your config in config2.yaml")
        return values

View on GitHub (pinned to 11cdf466d0)

Solutions

  1. Create a config2.yaml file in the MetaGPT config directory (~/.metagpt or the repo config path) and set the required configuration keys there.
  2. Alternatively pass the configuration directly in code instead of relying on config2.yaml.

Example fix

# Create ~/.metagpt/config2.yaml with your settings, e.g.:
# llm:
#   api_type: 'openai'
#   model: 'gpt-4'
#   api_key: 'YOUR_KEY'

When it happens

Trigger: Raised by the YamlModelWithoutDefault validator when any parsed config value still contains the placeholder substring 'YOUR' (e.g. 'YOUR_API_KEY'), meaning config2.yaml was copied from the template without real values filled in.

Common situations: Running MetaGPT after creating ~/.metagpt/config2.yaml or config/config2.yaml from the template without replacing placeholders such as YOUR_API_KEY with actual credentials.


AI-assisted analysis of FoundationAgents/MetaGPT@11cdf466d0 (2026-08-14). Data as JSON: /api/errors/49480f277bf8375f. Report an issue: GitHub.