datawhalechina/hello-agents · error · Exception

Error when set init goal {self.parsed_cdl['goal_cdl']}.

Error message

Error when set init goal {self.parsed_cdl['goal_cdl']}.

What it means

An exception raised by the symbolic geometry solver (src/gps/symbolic_solver.py) when _add_goals returns None while setting the problem's initial goal from the CDL's goal_cdl. The goal statement could not be converted into an internal goal node: its predicate may be unknown, its entities may not exist in the constructed diagram, or its syntax fails goal parsing. Since the goal is the solver's objective, the whole run aborts at initialization.

Source

Thrown at Co-creation-projects/BitSecret-GPSAgent/src/gps/symbolic_solver.py:396

            for instance in extend_constructions[predicate]:
                self._add_fact(predicate, instance, premise_ids, operation_id)

        # 5.Add facts
        operation_id = self._add_operation(('Preset', 'init_fact', None))
        for predicate, instance in self.parsed_cdl['relation_cdl']:
            if not self._pass_geometric_constraints(predicate, instance):
                raise Exception(f'EE check not passed when add init fact {(predicate, instance)}.')
            if (predicate, instance) in self.fact_id:
                continue
            fact_id, _ = self._add_fact(predicate, instance, (), operation_id)
            if fact_id is None:
                raise Exception(f'Error when add init fact {(predicate, instance)}.')

        # 6.Set goal
        init_goal_operation_id = self._add_operation(('Preset', 'init_goal', None))
        goal_ids = self._add_goals([self.parsed_cdl['goal_cdl']], None, init_goal_operation_id)
        if goal_ids is None:
            raise Exception(f"Error when set init goal {self.parsed_cdl['goal_cdl']}.")
        self._check_goals(goal_ids)

    def _add_fact(self, predicate, instance, premise_ids, operation_id):
        if predicate == 'Eq':
            instance = self._adjust_expr(instance)
            if instance is None or len(instance.free_symbols) == 0:
                return None, set()

        if (predicate, instance) in self.fact_id:
            return None, set()

        fact_id = len(self.facts)
        self.facts.append((predicate, instance, set(premise_ids), operation_id))
        self.fact_id[(predicate, instance)] = fact_id
        self.predicate_to_fact_instances[predicate].append(instance)
        self.operation_groups[operation_id].add(fact_id)

        goal_ids = set()

View on GitHub (pinned to 606a07d341)

Solutions

  1. Print parsed_cdl['goal_cdl'] and verify the goal predicate is one the solver supports and every referenced entity was constructed
  2. Fix the goal statement's syntax/entities in the CDL and re-run
  3. Guard before solving: assert the goal string parses with the library's parse_fact and its entities match constructed ones
  4. When generating CDL programmatically, validate the goal against the same grammar used for relations

Example fix

# before (goal references undeclared point)
# goal: Equal(LengthOfLine(AB), LengthOfLine(EF))  # E, F never constructed

# after
# construct E and F first, or change goal to:
# Equal(LengthOfLine(AB), LengthOfLine(CD))
Defensive patterns

Strategy: validation

Validate before calling

goal = parsed['goal_cdl']
name, paras = parse_fact(goal.replace(' ', ''))
assert name in supported_goal_predicates(), f'unsupported goal predicate: {name}'
assert entities_referenced(paras) <= constructed_entities(parsed), 'goal references undeclared entities'

Try / catch

try:
    solver.solve(problem_cdl)
except Exception as e:
    if 'Error when set init goal' in str(e):
        reject_problem(cdl=problem_cdl, reason=f'invalid goal: {parsed_goal}')
    raise

Prevention

When it happens

Trigger: Calling the solver on a CDL whose goal section uses a predicate outside the solver's goal grammar (e.g. 'ProveSomething(...)'), references entities not constructed (goal about line EF when E, F are undefined), or is syntactically malformed so parse fails inside _add_goals. Any of these yields goal_ids None and this raise.

Common situations: LLM-generated problems with invented goal predicates; copied problems from another solver dialect with different goal syntax; renamed entities in constructions but not in the goal; missing goal section producing a None/empty goal_cdl passed to _add_goals.

Related errors


AI-assisted analysis of datawhalechina/hello-agents@606a07d341 (2026-08-14). Data as JSON: /api/errors/72ad9177c055c09c. Report an issue: GitHub.