datawhalechina/hello-agents · error · Exception
'{theorem}' has wrong number of parameters (expected {len(se
Error message
'{theorem}' has wrong number of parameters (expected {len(self.parsed_gdl["Theorems"][theorem_name]['paras'])}). What it means
Raised in _parse_theorem when the theorem string supplies a non-zero number of parameters that does not equal len(parsed_gdl['Theorems'][name]['paras']) — the arity declared in the GDL theorem definition. The solver needs an exact positional mapping between supplied parameters and the theorem's declared parameters to build the substitution dict for premises and conclusion, so any arity mismatch is fatal. Supplying zero parameters is allowed and defers to other checks (errors 123/124).
Source
Thrown at Co-creation-projects/BitSecret-GPSAgent/src/gps/symbolic_solver.py:1272
except Exception as e:
e_msg = (f"Error '{repr(e)}' occurred while parsing the theorem '{theorem}'. "
f"The theorem format is incorrect.")
raise Exception(e_msg)
if theorem_name not in self.parsed_gdl["Theorems"]:
e_msg = f"Unknown theorem name: '{theorem_name}'."
raise Exception(e_msg)
error_paras = set([char for char in theorem_paras if not char.isupper()])
if len(error_paras) > 0:
e_msg = (f"Theorem parameters must be uppercase letters and , only. "
f"The current theorem contains invalid characters '{str(error_paras)}'.")
raise Exception(e_msg)
if len(theorem_paras) != 0 and len(theorem_paras) != len(self.parsed_gdl["Theorems"][theorem_name]['paras']):
e_msg = (f"'{theorem}' has wrong number of parameters "
f"(expected {len(self.parsed_gdl["Theorems"][theorem_name]['paras'])}).")
raise Exception(e_msg)
if len(theorem_paras) == 0:
theorem_paras = None
return theorem_name, theorem_paras
def apply(self, theorem):
old_fact_id = len(self.facts)
old_goal_id = len(self.goals)
old_goal_status = self.status_of_goal.copy()
theorem_name, theorem_paras = self._parse_theorem(theorem)
if theorem_paras is not None:
theorem_gdl = self.parsed_gdl['Theorems'][theorem_name]
replace = dict(zip(theorem_gdl['paras'], theorem_paras))
premise_ids = set()
for gpl_one_term in theorem_gdl['premises_gpl']: # run gdl with theorem parameter
product = gpl_one_term['product']View on GitHub (pinned to 606a07d341)
Solutions
- Read the expected count from solver.parsed_gdl['Theorems'][name]['paras'] and supply exactly that many uppercase letters.
- If unsure of the signature, call apply with no parameters (when the theorem is not in special_theorem and its name avoids perimeter/area/similar/congruent) and let the solver enumerate instances.
- Check for accidentally merged/split parameters (e.g. 'AB' counts as two params A and B).
Example fix
# before
solver.apply('congruent_triangle(A,B,C)') # GDL expects 6 params
# after
n = len(solver.parsed_gdl['Theorems']['congruent_triangle']['paras'])
# n == 6
solver.apply('congruent_triangle(A,B,C,D,E,F)') Defensive patterns
Strategy: validation
Validate before calling
def check_theorem_arity(solver, theorem):
name = theorem.replace(' ', '').split('(')[0]
expected = len(solver.parsed_gdl['Theorems'][name]['paras'])
paras = theorem.split('(', 1)[1].rsplit(')', 1)[0] if '(' in theorem else ''
actual = len([c for c in paras if c.isupper()])
assert actual == 0 or actual == expected, f'expected {expected}, got {actual}' Try / catch
try:
solver.apply(theorem)
except Exception as e:
if 'wrong number of parameters' in str(e):
# re-emit with the arity printed in the message and retry Prevention
- Always read arity from parsed_gdl['Theorems'][name]['paras'] instead of guessing.
- Include the parameter count in each theorem's tool description given to the LLM.
- Wrap apply() in a helper that formats 'name(' + ','.join(points[:n]) + ')'.
When it happens
Trigger: Calling apply('midsegment(A,B)') when the GDL defines midsegment with 6 parameters; passing 3 of 4 points of a quadrilateral theorem; counting commas incorrectly because multi-letter tokens were collapsed to per-character params.
Common situations: LLM agents guessing parameter counts instead of reading the theorem's declared signature; GDL files updated to add a parameter while prompts still show the old count.
Related errors
- Unknown theorem name: '{theorem_name}'.
- Theorem parameters must be uppercase letters and , only. The
- When using the 'apply' tool with theorem '{theorem_name}', t
- When the theorem name contains 'perimeter', 'area', 'similar
- Unknown relation type '{relation}'.
AI-assisted analysis of datawhalechina/hello-agents@606a07d341 (2026-08-14).
Data as JSON: /api/errors/ddbb6303cdd33839.
Report an issue: GitHub.