FoundationAgents/MetaGPT · error · NoMoneyException

Insufficient funds: {self.cost_manager.max_budget}

Error message

Insufficient funds: {self.cost_manager.max_budget}

What it means

Team._check_balance compares the CostManager's accumulated total_cost against max_budget (set by Team.invest). When spend reaches or exceeds the budget, it raises NoMoneyException with the budget in the message. This is the run loop's hard stop for API spending.

Source

Thrown at metagpt/team.py:100

    def hire(self, roles: list[Role]):
        """Hire roles to cooperate"""
        self.env.add_roles(roles)

    @property
    def cost_manager(self):
        """Get cost manager"""
        return self.env.context.cost_manager

    def invest(self, investment: float):
        """Invest company. raise NoMoneyException when exceed max_budget."""
        self.investment = investment
        self.cost_manager.max_budget = investment
        logger.info(f"Investment: ${investment}.")

    def _check_balance(self):
        if self.cost_manager.total_cost >= self.cost_manager.max_budget:
            raise NoMoneyException(self.cost_manager.total_cost, f"Insufficient funds: {self.cost_manager.max_budget}")

    def run_project(self, idea, send_to: str = ""):
        """Run a project from publishing user requirement."""
        self.idea = idea

        # Human requirement.
        self.env.publish_message(Message(content=idea))

    def start_project(self, idea, send_to: str = ""):
        """
        Deprecated: This method will be removed in the future.
        Please use the `run_project` method instead.
        """
        warnings.warn(
            "The 'start_project' method is deprecated and will be removed in the future. "
            "Please use the 'run_project' method instead.",
            DeprecationWarning,
            stacklevel=2,

View on GitHub (pinned to 11cdf466d0)

Solutions

  1. Raise the budget: company.invest(10.0) or metagpt --investment 10.0 and re-run/recover
  2. Use cheaper llm models in config (api_type/model settings) to slow spend
  3. Reduce n_round or number of hired roles to cap total LLM calls

Example fix

// before
company.invest(0.5)  # NoMoneyException mid-run

// after
company.invest(10.0)
await company.run(n_round=n_round, idea=idea)
Defensive patterns

Strategy: try-catch

Validate before calling

if company.cost_manager.total_cost + estimated_run_cost > company.cost_manager.max_budget:
    company.invest(company.cost_manager.total_cost + estimated_run_cost + buffer)

Try / catch

from metagpt.exception import NoMoneyException
try:
    await company.run(n_round=n_round, idea=idea)
except NoMoneyException:
    company.invest(company.cost_manager.max_budget * 2)  # top up and resume via --recover-path
    logger.warning("budget exhausted; re-run with --recover-path to continue")

Prevention

When it happens

Trigger: company.invest(0.5) then running enough LLM calls that total_cost >= 0.5; also fires when investment was never raised from a tiny default while running a full software-company pipeline.

Common situations: Setting --investment too low for the number of roles/rounds; long PRD+design+code runs consuming many tokens; expensive models (e.g. large-context GPT-4 class) exhausting a small budget quickly.

Related errors


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